vllm.models.glm5next.nvidia.specialized_decode.indexer_query
¶
The indexer's per-token epilogue in one kernel: key LayerNorm, query Hadamard rotation and FP8 quant, head-weight scaling, and the zero padding of the query heads and weights that DeepGEMM's MQA logits need (stock: five kernels).
One warp per query head, four values per lane: the Hadamard stages of strides 1
and 2 stay in a lane, the others pair lanes l and l ^ (stride / 4). The
butterflies, the rounding and the power-of-two scale (the stock kernel's
accurate log2, read off the exponent bits where that is exact) follow
fwht128_quant_fp8 bit for bit.
Functions:
-
hadamard_quant–One query head, a warp's four values per lane (two BF16x2 words), as
-
indexer_query–Returns (q_fp8 [M, padded, 128], weights [M, padded], key [M, 128]).
-
store_weight–w_out[t, head] = value, rounded to BF16 (as.to(torch.bfloat16))
_exponent(x)
¶
ceil(log2(x)) with the stock kernel's accurate log2, for positive x.
From the bits unless the mantissa is barely above a power of two (where the rounded log2 can land on the exponent itself) or x is not normal.
Source code in vllm/models/glm5next/nvidia/specialized_decode/indexer_query.py
hadamard_quant(got, lane)
¶
One query head, a warp's four values per lane (two BF16x2 words), as
fwht128_quant_fp8: (the lane's FP8x4 word, the head's power-of-two scale).
Source code in vllm/models/glm5next/nvidia/specialized_decode/indexer_query.py
indexer_query(q, k, weights, norm, scale, padded, weights_dtype=torch.float32)
¶
Returns (q_fp8 [M, padded, 128], weights [M, padded], key [M, 128]).
Parameters:
-
(q¶Tensor) –[M, heads * 128] BF16 indexer query.
-
(k¶Tensor) –[M, 128] BF16 indexer key before its LayerNorm.
-
(weights¶Tensor) –[M, heads] FP32 head weights.
-
(norm¶Module) –the key LayerNorm module (FP32 weight and bias).
-
(scale¶float) –the folded softmax and head-count scale.
-
(padded¶int) –heads after zero padding.
-
(weights_dtype¶dtype, default:float32) –FP32, or BF16 for consumers that round them to BF16.
Source code in vllm/models/glm5next/nvidia/specialized_decode/indexer_query.py
store_weight(w_out, t, head, value, padded, bf16)
¶
w_out[t, head] = value, rounded to BF16 (as .to(torch.bfloat16))
when bf16.