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
mamba2_ssd_state_sm100
The chunked Mamba-2 scan's chunk state on SM100 (B200).
S[slot, h, p, n] = sum_t exp2(cs_last - cs_t) dt_t x[t, h, p] B[t, g, n]
over each chunk slot's tokens, on the chunked scan's varlen contract
(mamba2_ssd_chunked): x and B are rows of the packed conv output read by
TMA at the slot's first token, dt and cs its fp32 [H, slots, CHUNK]
vectors, and S fp32 [slots, H, P, N] for the state passing. A slot's dt is
0 past its sequence's end and its cs is flat there, so cs_last is
cs[CHUNK - 1] and rows past the end weigh 0.
A persistent CTA walks work items of one slot and two heads of one group. Per 128-token row block the load warp brings B's two 64-column N spans and the item's x spans; the scale warps write w_t x into a second slot, row t scaled in place in its swizzle (a 128-byte row stays one row); the MMA warp issues S^T[n, p] += B^T (w x) with both operands MN-major (M 128 = N, N 64 = P a head, K 16 tokens an instruction); the epilogue reads S^T by TMEM lane n and stores each p's 32 lanes as one 128-byte run.
This is the Moka component Kernels/test/gpu/Moka/kernels/mamba2/ ssd_state_varlen_plan.mojo, statement for statement, with no Moka in it.
comptime values
B_B
comptime B_B = 0
B_BF
comptime B_BF = 21
B tiles land here; the fixup then publishes them on B_B.
B_DC
comptime B_DC = 12
B_S
comptime B_S = 16
B_TFREE
comptime B_TFREE = 20
B_W
comptime B_W = 8
B_X
comptime B_X = 4
NB_FIX
comptime NB_FIX = 2
NB_TPTR
comptime NB_TPTR = 1
OFF_B
comptime OFF_B = 0
OFF_BARS
comptime OFF_BARS = 206848
OFF_CS
comptime OFF_CS = 201728
OFF_DT
comptime OFF_DT = 196608
OFF_TMEM
comptime OFF_TMEM = 207040
OFF_W
comptime OFF_W = 131072
OFF_X
comptime OFF_X = 65536
SLOT
comptime SLOT = 32768
SMEM_BYTES
comptime SMEM_BYTES = 207056
StPtr
comptime StPtr = Pointer[SsdStateParams, ImmUntrackedOrigin]
THREADS
comptime THREADS = 384
TMEM_COLS
comptime TMEM_COLS = 256
Structs
-
SsdStateParams: TMA descriptors and uniform scalars, passed as one grid constant.
Functions
-
ssd_state_sm100: Computes the chunk state of every used chunk slot and head. -
ssd_state_sm100_kernel: Grid min(SMS, items), block THREADS: warps 0-3 scale, 4-7 epilogue, 8 mma, 9 load, 10-11 B fixup.