IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Mojo trait

CommTuningConfig

Tuning-table entry for a multi-GPU communication collective.

Extends TuningConfig with the four dimensions that drive kernel-launch selection: SM version, GPU count, total data size, and thread-block count. Implement this trait to supply custom tuning tables to dispatch_select_comm_config.

Implemented traits​

AnyType, Copyable, ImplicitlyCopyable, ImplicitlyDeletable, Movable, RegisterPassable, TrivialRegisterPassable, TuningConfig, Writable

Required methods​

__init__​

def __init__(out self, *, copy: Self)

Create a new instance of the value by copying an existing one.

Args:

  • ​copy (_Self): The value to copy.

Returns:

_Self

def __init__(out self, *, deinit move: Self)

Create a new instance of the value by moving the value of another.

Args:

  • ​move (_Self): The value to move.

Returns:

_Self

get_num_blocks​

def get_num_blocks(self) -> Int

Returns the number of thread blocks to launch for this configuration.

Returns:

Int: The thread-block count, which must not exceed 512 (MAX_NUM_BLOCKS_UPPER_BOUND).

get_num_bytes​

def get_num_bytes(self) -> Int

Returns the maximum input size in bytes covered by this entry.

dispatch_select_comm_config selects the first entry whose get_num_bytes() is at least the actual transfer size.

Returns:

Int: The upper-bound byte count for this tuning entry, or -1 for the default (catch-all) entry.

get_sm_version​

def get_sm_version(self) -> StaticString

Returns the SM version string this entry targets.

Returns:

StaticString: A string such as "sm_90a" or "sm_100a", or "default" for the architecture-agnostic fallback entry.

get_ngpus​

def get_ngpus(self) -> Int

Returns the GPU count this entry targets.

Returns:

Int: The number of participating GPUs, or -1 for the default (catch-all) entry.

Provided methods​

copy​

def copy(self) -> Self

Explicitly construct a copy of self, a convenience method for Self(copy=self) when the type is inconvenient to write out.

Overriding this method is not allowed.

Returns:

_Self: A copy of this value.

write_to​

def write_to(self, mut writer: T)

Write this value's text representation to a writer.

This method is called by print(), String(), and format strings to convert the value to text. Override this method to define how your type appears when printed or converted to a string.

The default implementation uses reflection to format all fields as TypeName(field1=value1, field2=value2, ...), calling write_to() on each field. All fields must conform to Writable.

Example:

@fieldwise_init
struct Point(Writable):
    var x: Float64
    var y: Float64

    def write_to(self, mut writer: Some[Writer]):
        writer.write("(", self.x, ", ", self.y, ")")

Args:

  • ​writer (T): The destination for formatted output.

write_repr_to​

def write_repr_to(self, mut writer: T)

Write this value's debug representation to a writer.

This method is called by repr(value) or the "{!r}" format specifier and should produce unambiguous, developer-facing output that shows the internal state of the value.

The default implementation uses reflection to format all fields as TypeName(field1=value1, field2=value2, ...), calling write_repr_to() on each field. All fields must conform to Writable.

Example:

@fieldwise_init
struct Point(Writable):
    var x: Float64
    var y: Float64

    def write_repr_to(self, mut writer: Some[Writer]):
        writer.write("Point: x=", self.x, ", y=", self.y)

Notes: Mojo's repr always prints single quotes (') at the start and end of the repr. Any single quote inside a string should be escaped (\').

Args:

  • ​writer (T): The destination for formatted output.