Mojo struct
TMAProducerPipeline
struct TMAProducerPipeline[dtype: DType, config: FA4Config[config.qkv_dtype, rope_dtype=config.rope_dtype, scale_dtype=config.scale_dtype], is_k: Bool = True]
Unified producer pipeline for K and V TMA loading.
K loading (is_k=True): Can be staged (num_qk_stages chunks), uses k_major layout. V loading (is_k=False): Always complete (qk_stage=0), uses mn_major layout.
Fieldsβ
- βpipeline (
StagedPipeline[config.num_kv_stages, TMAProducerPipeline[dtype, config, is_k].num_qk_stages_effective]): - βsmem (
TMAProducerPipeline[dtype, config, is_k].SMemType):
Implemented traitsβ
AnyType,
Copyable,
ImplicitlyCopyable,
ImplicitlyDestructible,
Movable,
RegisterPassable,
TrivialRegisterPassable
comptime membersβ
bytesβ
comptime bytes = TMAProducerPipeline[dtype, config, is_k].tile_bytes
elementsβ
comptime elements = TMAProducerPipeline[dtype, config, is_k].tile_layout.size()
elements_fullβ
comptime elements_full = (TMAProducerPipeline[dtype, config, is_k].elements * config) if is_k else TMAProducerPipeline[dtype, config, is_k].elements
KPairTypeβ
comptime KPairType = TMAProducerPipeline[dtype, config, is_k].PairType
num_qk_stages_effectiveβ
comptime num_qk_stages_effective = config.num_qk_stages if is_k else 1
PairTypeβ
comptime PairType = TMADestination[dtype, TMAProducerPipeline[dtype, config, is_k].tile_layout.size()]
SMemTypeβ
comptime SMemType = UnsafePointer[Scalar[dtype], MutAnyOrigin, address_space=AddressSpace.SHARED]
tile_bytesβ
comptime tile_bytes = (TMAProducerPipeline[dtype, config, is_k].elements * size_of[dtype]())
tile_layoutβ
comptime tile_layout = tile_layout_k_major[dtype, config.k_rows_per_cta(), config.BK0, config.swizzle_mode]() if is_k else tile_layout_mn_major[dtype, config.v_cols_per_cta(), config.BK1, config.swizzle_mode]()
Methodsβ
__init__β
__init__(mbar: UnsafePointer[SharedMemBarrier, MutAnyOrigin, address_space=AddressSpace.SHARED], smem: UnsafePointer[Scalar[dtype], MutAnyOrigin, address_space=AddressSpace.SHARED]) -> Self
__init__(pipeline: StagedPipeline[config.num_kv_stages, TMAProducerPipeline[dtype, config, is_k].num_qk_stages_effective], smem: UnsafePointer[Scalar[dtype], MutAnyOrigin, address_space=AddressSpace.SHARED]) -> Self
get_smemβ
get_smem[*, qk_stage: Int = 0](self) -> TMAProducerPipeline[dtype, config, is_k].SMemType
Get smem pointer for current stage.
Returns:
TMAProducerPipeline[dtype, config, is_k].SMemType
get_tileβ
get_tile[*, qk_stage: Int = 0](self) -> TMAProducerPipeline[dtype, config, is_k].PairType
Get TMA destination for this stage.
Returns:
TMAProducerPipeline[dtype, config, is_k].PairType
get_tile[*, qk_stage: Int = 0](self, e: Int32) -> TMAProducerPipeline[dtype, config, is_k].PairType
Get TMA destination with optional expect_bytes.
Returns:
TMAProducerPipeline[dtype, config, is_k].PairType
acquireβ
acquire[*, qk_stage: Int = 0](self)
Wait for consumer to release the buffer.
commit_stepβ
commit_step(mut self)
Step the pipeline. Commit is handled by tma_op.async_copy.
get_k_smemβ
get_k_smem[*, qk_stage: Int](self) -> TMAProducerPipeline[dtype, config, is_k].SMemType
Returns:
TMAProducerPipeline[dtype, config, is_k].SMemType
get_kβ
get_k[*, qk_stage: Int](self) -> TMAProducerPipeline[dtype, config, is_k].PairType
Returns:
TMAProducerPipeline[dtype, config, is_k].PairType
get_k[*, qk_stage: Int](self, e: Int32) -> TMAProducerPipeline[dtype, config, is_k].PairType
Returns:
TMAProducerPipeline[dtype, config, is_k].PairType
acquire_kβ
acquire_k[*, qk_stage: Int](self)
get_v_smemβ
get_v_smem(self) -> TMAProducerPipeline[dtype, config, is_k].SMemType
Returns:
TMAProducerPipeline[dtype, config, is_k].SMemType
get_vβ
get_v(self, e: Int32) -> TMAProducerPipeline[dtype, config, is_k].PairType
Returns:
TMAProducerPipeline[dtype, config, is_k].PairType
acquire_vβ
acquire_v(self)
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!