For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo module
attention_utils
Shared SM100 attention primitives used by both MHA and MLA kernels.
This module contains generic SM100 (Blackwell) GPU primitives including:
- TMEM access helpers (TMemTile, STMatrixLayout)
- Pipeline synchronization (StagedPipeline, RolePipeline, etc.)
- FTZ arithmetic (add_ftz, sub_ftz, mul_ftz, etc.)
- Barrier helpers (FA4MiscMBars)
- MMA building blocks (bulk_mma, SM100TensorAccumulator)
- Masking utilities (apply_mask, apply_oob_mask)
comptime values
ConsumerPipeline
comptime ConsumerPipeline = RolePipeline[_, False, _, _, _]
FP32_EXP_BIAS
comptime FP32_EXP_BIAS = 127
KConsumerPipeline
comptime KConsumerPipeline = TMAConsumerPipeline[_, _]
KPipeline
comptime KPipeline = StagedPipeline[_, _]
KProducerPipeline
comptime KProducerPipeline = TMAProducerPipeline[_, _]
KVPipeline
comptime KVPipeline = StagedPipeline[_, _]
LocalLT
comptime LocalLT[dtype: DType, layout: Layout, element_layout: Layout = Layout(IntTuple(Int(1)), IntTuple(Int(1)))] = LayoutTensor[dtype, layout, MutAnyOrigin, address_space=AddressSpace.LOCAL, element_layout=element_layout]
Parameters
LocalTensor
comptime LocalTensor[dtype: DType, layout: Layout[shape_types, stride_types]] = TileTensor[dtype, Layout[shape_types, stride_types], MutUntrackedOrigin, address_space=AddressSpace.LOCAL]
Parameters
- dtype (
DType): - layout (
Layout[shape_types, stride_types]):
MBarType
comptime MBarType = Pointer[SharedMemBarrier, MutAnyOrigin, address_space=AddressSpace.SHARED]
ProducerPipeline
comptime ProducerPipeline = RolePipeline[_, producer_sub_stages=_, consumer_sub_stages=_, cta_group=_]
SharedMemPointer
comptime SharedMemPointer[type: AnyType] = Pointer[type, MutAnyOrigin, address_space=AddressSpace.SHARED]
Parameters
- type (
AnyType):
SharedMemTensor
comptime SharedMemTensor[dtype: DType, layout: Layout[shape_types, stride_types]] = TileTensor[dtype, Layout[shape_types, stride_types], MutUntrackedOrigin, address_space=AddressSpace.SHARED]
Parameters
- dtype (
DType): - layout (
Layout[shape_types, stride_types]):
VConsumerPipeline
comptime VConsumerPipeline = TMAConsumerPipeline[_, _, False]
VPipeline
comptime VPipeline = StagedPipeline[_]
VProducerPipeline
comptime VProducerPipeline = TMAProducerPipeline[_, _, False]
Structs
-
FA4MiscMBars: Manages all mbarrier resources for FA4. -
MBarPipeline: Manages a paired set of producer/consumer mbarriers for pipeline synchronization. -
RolePipeline: Unified producer/consumer pipeline for barrier synchronization. -
SM100TensorAccumulator: Performs theC = A @ Btensor contraction on SM100 usingtcgen05.mmainstructions. -
StagedPipeline: Unified pipeline for K, V, and KV tile barrier management. -
STMatrixLayout: Layout for usingst_matrixfor writing the final accumulator to smem. -
STMatrixOffsets: Precomputed TMEM and local-fragment offsets for onest_matrixrepeat column. -
TMAConsumerPipeline: Unified consumer pipeline for K and V TMA consumption. -
TMADestination: Pairs a shared memory TileTensor with a barrier for TMA operations. -
TMAProducerPipeline: Unified producer pipeline for K and V TMA loading. -
TMemTile: Represents a tile in SM100 tensor memory (TMEM) and provides async load/store helpers.
Functions
-
add_ftz: Returns the flush-to-zero sum of two float32 values. -
add_ftz_rm: Returns the round-to-nearest-even flush-to-zero sum of twof32x2vectors. -
apply_mask: Applies bitmask, computed, and out-of-bounds masking strategies to a row ofBNattention scores. -
apply_oob_mask: Applies the out-of-bounds key mask to a pair of attention scores. -
blasst_vote_unanimous: Reads the BLASST per-warp skip votes for(wg, phase)and ANDs them. -
break_into_powers_of_two: Callsfuncfor each power-of-two-sized chunk ofN, plus a finalpow_two=0call for pipeline cleanup. -
bulk_mma: Issues a full-tile SS (both operands in SMEM) non-warp-specializedtcgen05.mmacontraction. -
bulk_mma_partial: Issues a partial-K TS contraction for a partially-loaded last KV tile, non-warp-specialized. -
bulk_mma_ss_partial: Issues a partial-K SS contraction for a partially-loaded last KV tile, non-warp-specialized. -
bulk_mma_ws: Issues a full-tile SS (both operands in SMEM) warp-specializedtcgen05.mma.wscontraction. -
bulk_mma_ws_partial: Issues a partial-K SS warp-specialized contraction for a partially-loaded last KV tile. -
bulk_mma_ws_ts: Issues a full-tile TS (A in TMEM, B in SMEM) warp-specializedtcgen05.mma.wscontraction. -
bulk_mma_ws_ts_partial: Issues a partial-K TS warp-specialized contraction for a partially-loaded last KV tile. -
cluster_remote_smem_addr: Map a local.sharedbyte address to peerpeer_rank's window in the cluster. -
clusters_per_wave: Number of size-cluster_sizethread-block clusters that fit on the target Blackwell datacenter GPU in ONE wave, honoring GPC co-residency. -
combine_pack_o_row: LSE-combineown * scale_own + peer * scale_peerovernf32 O lanes, cast to the 2-byteoutput_type, and pack inton // 2u32 lanes. -
cumulative_power_of_two: Returns the cumulative sum of the firstipower-of-two components ofN. -
elect_mma_arrive: Arrive at the mbar pointer for the MMA instruction. -
exp2_emulation: Computes2^xfor anf32x2vector via a degree-3 polynomial approximation. -
expect_bytes_pred: Issuembarrier.arrive.expect_tx.shared::cta.b64predicated onpred != 0. -
extract_power_of_two: Returns thei-th power-of-two component when decomposingNinto decreasing powers of two. -
fma_ftz: -
intrin: Wraps a ternary float32 PTX intrinsic (e.g.max.f32). -
intrin_ftz: Wraps a flush-to-zero (FTZ) binary float32 PTX intrinsic. -
intrin_ftz_x2: Wraps a flush-to-zero (FTZ) binaryf32x2PTX intrinsic. -
llvm_opaque_tid: Returns the opaque thread ID via thellvm.nvvm.read.ptx.sreg.tid.xintrinsic. -
load_cluster_smem: Loadwidthelements from peerpeer_rank's shared memory atlocal_ptr. -
mask_select8: Masks 8 contiguous scores against one byte of a 32-column bitmask. -
max_ftz: Returns the flush-to-zero maximum of two float32 values. -
maximum: ReducesBNfloat32 scores intowidthlane-maxima using FTZ max. -
mul_ftz: Returns the flush-to-zero product of two float32 values. -
o_store_tma_blocks_per_op: Box size (swizzle-granularity blocks per batched O-store TMA). -
pack_row: Cast thewf32 O laneso_vals[start : start + w]tooutput_typeand pack them into one 16 B SWIZZLE_NONE store register (exactly four u32). -
peel_mask: Determine which mask strategy applies to the peeled first iteration. -
scale_pack_o_row: Scale thewf32 O laneso_vals[start : start + w]byinv_row_sum, cast to the 2-byteoutput_type, and pack intow // 2u32 lanes (the row-major 16 B SWIZZLE_NONE store register). -
splitk_num_partitions: The split-K partition countPthis CTA must divide its KV range by. -
splitk_p_ladder: The rung ladder of split-K partition countsP, shared by the producer and the consumer of a workspace split-K launch. -
splitk_partition_idx: This CTA's split-K partition index[0, splitk_partitions). -
splitk_window: Front-loaded balanced split of the combined K-tile range[0, T). -
st_shared_v4_b32: Explicit 16 Bst.shared.v4.b32(oneSTS.128) todst[elem_off]. -
store_cluster_smem: Storevalinto peerpeer_rank's shared memory atlocal_ptr. -
store_global_pred: Issue a global store predicated onpred != 0. -
sub_ftz: Returns the flush-to-zero difference of two float32 values. -
sum: Reduces aBN-element local tensor into a width-2 SIMD vector via vectorized accumulation.