vllm.models.deepseek_v41.common.ops.indexer_k_store
¶
Indexer K production for DeepSeek V4.1 kv-source layers.
In v4.1 the index key is derived from the main compressor's latent:
k = k_norm(wk(latent)) (reference model.py Indexer.forward), then RoPE'd
at the group's first-token position and MXFP4/FP8-quantized into the paged
indexer K cache. The wk(latent) GEMM runs in torch; this kernel fuses the
remaining k_norm → RoPE → quant → paged store, one program per token.
Unlike the legacy (v4.0) indexer path there is no per-token pooling from a
compressor state cache: the latent already stands for a whole group, so only
group-boundary tokens (position + 1) % compress_ratio == 0 produce a key.
Functions:
-
indexer_k_norm_rope_store–k_norm → RoPE → quant → paged store for indexer keys.
indexer_k_norm_rope_store(k_pre, positions, cos_sin_cache, rms_norm_weight, rms_norm_eps, k_cache, kv_slot_mapping, compress_ratio, use_fp4_cache)
¶
k_norm → RoPE → quant → paged store for indexer keys.
Parameters:
-
(k_pre¶Tensor) –[num_tokens, 128] bf16, the
wk(latent)projection. Only group-boundary rows are read. -
(positions¶Tensor) –[num_tokens] int64 token positions.
-
(cos_sin_cache¶Tensor) –[max_pos, rope_head_dim] GPT-J layout (cos half, then sin half), from the layer's compress-RoPE instance.
-
(rms_norm_weight¶Tensor) –[128] k_norm weight.
-
(rms_norm_eps¶float) –Epsilon of the k_norm RMSNorm.
-
(k_cache¶Tensor) –uint8 paged indexer cache [num_blocks, block_size, row_bytes].
-
(kv_slot_mapping¶Tensor) –[num_tokens] slots in the indexer cache (-1 = skip).
-
(compress_ratio¶int) –group size; keys are emitted at group boundaries.
-
(use_fp4_cache¶bool) –MXFP4 (2 nibbles/byte + ue8m0 per 32) when True, else per-token FP8 with a single fp32 scale (four packed ue8m0 bytes under
mqa_logits_use_mx_scales).
Source code in vllm/models/deepseek_v41/common/ops/indexer_k_store.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |