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 module

output_writer_trait

Output-writer trait surface for the SM100 structured matmul epilogue.

This module defines the pluggable boundary that lets BlackwellMatmulSM100Kernel emit its accumulator tiles through an injected writer policy, instead of hard-referencing a concrete writer struct. This breaks the source dependency from matmul_kernels.mojo onto rs_output_writer.mojo, so the reduce-scatter writer can later move to a closed-source tree.

OutputWriter is the policy the kernel takes as a comptime parameter (output_writer_type). It carries:

  • needs_sync: Bool: whether the epilogue must wrap the write in a cross-GPU barrier (reduce-scatter) or not (local store).
  • num_peers: Int: number of C TMA descriptors the kernel must supply in c_tma_ops (1 for the local store, one per peer for reduce-scatter).
  • write_batched[...]( c_tma_ops, c_tiles, stage, tile_coord, shape, alpha ): a static method that constructs the concrete writer and writes one batched output tile. Construction lives inside the policy, where the concrete writer type is named and non-erased; the kernel only passes the c_tma_ops array pointer plus the shared-typed SMEM tiles / stage.

Why a static-method policy rather than injecting the concrete writer type or a trait-typed writer value:

  • A Mojo struct parameter default cannot reference the kernel's Self.-derived aliases (opc, SmemType.Output*, ...), and the kernel's callers cannot reconstruct that config-derivation to spell the full writer type at the injection site. So the concrete writer must be resolved inside the kernel.
  • A trait associated type / value erases to its declared bound, so a writer obtained as a trait-typed value cannot have write_batched called on it (its associated CTileArray / Stage arg types are opaque, and matching a by-value-Tuple requirement against an @always_inline impl trips a parameter-origin mismatch). Keeping the construct-and-write step inside the policy static method dodges erasure entirely: there the writer is concrete, and c_tiles / stage are the shared SMemTileArray2DRowMajor[...] / OutputStage[opc] types both writers already use.

Note (interim design): folding construction + write into one policy static method is a temporary approach. It is expected to fold into the upstream TileConsumer/TileOperation traits once those land a non-erasing pluggable-writer shape.

Target hardware: SM100 (B200).

Traits

  • OutputWriter: Injected output-writer policy for BlackwellMatmulSM100Kernel.

Was this page helpful?