vllm.models.kimi_k3.nvidia.specialized_decode.cutedsl.dsa.index
¶
DSA indexer inputs of one decode step, one 256-thread CTA per token:
- the indexer query [32, 128] (the BF16 wq_b projection of the normalized q_c) in FP8 with one power-of-two scale per head, the scale folded into the head weights wv * scale / sqrt(32 * 128) as indexer_q_quant_fold_weights computes them, in the BF16 SM100's MQA logits take (mqa_logits_mx_inputs);
- the shared indexer key: LayerNorm (FP32) of the wk projection, BF16, then FP8 with
a power-of-two scale into the indexer cache, as indexer_k_norm_quant_insert writes
it: per block, the FP8 keys of its tokens, then their scales: FP32, or (
mx: the SM100 MQA logits kernels' MX scales, mqa_logits_use_mx_scales) the scale's exponent as four equal packed UE8M0 bytes.
A half-warp owns one head (8 columns per lane); warp 0's low half also owns the key.
MXFP4 indexer cache (68 B/token: cache.shape[2] == FP4_ENTRY, configured with
indexer_kv_dtype='mxfp4', kimi_k3_indexer_uses_fp4): the query and the key are MXFP4
as the writers of nvidia/ops/dsa_indexer_mxfp4.py make them (_mxfp4_quant: one
UE8M0 scale per 32 values, E2M1 round to nearest even with saturation), the head
weights only take the indexer weight scale (the MX scales stay in the logits MMA),
and the cache block is [64 x 64 B E2M1 | 64 x 4 UE8M0]. The FP4 query lives in the
FP8 query's rows (FP4_QUERY_ROW bytes per row): [32 heads x 64 B E2M1 | 32 heads x
4 UE8M0] (fp4_query_views).
Classes:
-
DsaIndex–key/weight: column offsets of the wk and wv projections in the packed
Functions:
-
e2m1x2–One byte of two E2M1 (round to nearest even, satfinite),
lowin the low -
fp4_query_views–The MXFP4 query in the FP8 query buffer
q_rows[>= rows, 32, 128] uint8: -
gather_bytes–The word of the bytes of lanes lane, lane + stride, + 2 stride, + 3 stride
-
group_max–Max over aligned groups of
laneslanes. -
insert_fp4_key–MXFP4 of the key's 8 columns per lane into its slot (the low half-warp
-
insert_key–One warp: LayerNorm (FP32) of row
token's wk projection (at column -
is_fp4_cache–Whether an indexer cache (torch or static cute shape) holds MXFP4 keys.
-
mxfp4_scale–(1 / scale, UE8M0 byte) of an MXFP4 block with absolute maximum
amax: -
quantize_fp4_query–MXFP4 of
per_lane(4 or 8) consecutive columns of one head, columns
DsaIndex
¶
key/weight: column offsets of the wk and wv projections in the packed
projection row; mx: key scales as packed UE8M0 (MX) bytes.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/index.py
e2m1x2(low, high)
¶
One byte of two E2M1 (round to nearest even, satfinite), low in the low
nibble.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/index.py
fp4_query_views(q_rows, rows)
¶
The MXFP4 query in the FP8 query buffer q_rows [>= rows, 32, 128] uint8:
(E2M1 [rows, 32, 64] uint8, UE8M0 x4 [rows, 32] int32), row stride 4 KiB.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/index.py
gather_bytes(byte, lane, stride)
¶
The word of the bytes of lanes lane, lane + stride, + 2 stride, + 3 stride (the first lane's in the low byte; valid in that first lane).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/index.py
group_max(value, lanes)
¶
Max over aligned groups of lanes lanes.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/index.py
insert_fp4_key(normed, amax, cache, slot, lane)
¶
MXFP4 of the key's 8 columns per lane into its slot (the low half-warp writes): E2M1 at token * 64, the four UE8M0 bytes at 64 * 64 + token * 4.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/index.py
insert_key(projected, key, norm_w, norm_b, cache, slots, token, eps, mx, lane)
¶
One warp: LayerNorm (FP32) of row token's wk projection (at column
key), BF16, FP8 with a power-of-two scale into its indexer cache slot (the
low half-warp writes; mx: packed UE8M0 scales). Nothing for a slot < 0.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/index.py
is_fp4_cache(cache)
¶
Whether an indexer cache (torch or static cute shape) holds MXFP4 keys.
mxfp4_scale(amax)
¶
(1 / scale, UE8M0 byte) of an MXFP4 block with absolute maximum amax:
scale = 2^clamp(ceil(log2(max(amax, 6 * 2^-126) / 6)), -127, 127), by the
instructions Triton emits for the MXFP4 writer (ops/dsa_indexer_mxfp4._mxfp4_quant):
div.full, libdevice log2f, cvt.rpi, ex2.approx, div.full. Bit-exact with it,
rounding of the log2 near powers of two included.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/index.py
quantize_fp4_query(values, per_lane, row, head, part, lane)
¶
MXFP4 of per_lane (4 or 8) consecutive columns of one head, columns
part * per_lane on, into the FP4 query row at pointer row: E2M1 at
head * 64, the head's four UE8M0 bytes at FP4_SCALES + head * 4 (written by
the lane of part 0; the head's parts are consecutive aligned lanes).