vllm.models.deepseek_v41.common.ops.fused_compress_quant_cache ¶
V4.1 state saving/compression and independently schedulable cache insertion.
Functions:
-
fused_save_compress_norm–Pool each closed group into a normalized BF16 latent; save FP32 states.
-
rope_quant_insert–Apply GPT-J RoPE and publish a latent to the compressed KV cache.
fused_save_compress_norm(kv_score, positions, state_cache, slot_mapping, query_start_loc, token_to_req_indices, rms_norm_weight, rms_norm_eps, compress_ratio, latent_out) ¶
Pool each closed group into a normalized BF16 latent; save FP32 states.
The latent feeds the main-cache insert and the indexer K path, which the attention layer schedules on separate streams.
Ratio 2 keeps one ring block per request holding the open group's rows: position p lives in row p % capacity and slot_mapping encodes block * capacity + p % capacity. The grid has one program per request followed by one per pair of packed tokens. A request program handles the group that the chunk's first token closes with its predecessor's ring row, then stores the chunk's last capacity rows to the ring; because the same program does both, ring reads and writes never race. A pair program handles the group that ends inside its pair, reading both rows from the raw input. Ratio 1 has no ring and one program per token; slot_mapping then only marks valid tokens.
Parameters:
-
(kv_score¶Tensor) –FP32 [tokens, 512] for CR1, [tokens, 1024] for CR2.
-
(positions¶Tensor) –Absolute positions of the packed request tokens.
-
(state_cache¶Tensor | None) –Ring FP32 [blocks, capacity, 1024] KV/score states (CR2).
-
(slot_mapping¶Tensor) –Ring slots (CR2) or main-cache slots (CR1).
-
(query_start_loc¶Tensor | None) –[num_reqs + 1] token offsets of each request's chunk.
-
(token_to_req_indices¶Tensor | None) –Request indices for the packed token rows.
-
(rms_norm_weight¶Tensor) –BF16 [512] normalization weight.
-
(rms_norm_eps¶float) –RMSNorm epsilon.
-
(compress_ratio¶int) –Group size, either 1 or 2.
-
(latent_out¶Tensor) –BF16 [tokens, 512], written only at valid group boundaries.
Source code in vllm/models/deepseek_v41/common/ops/fused_compress_quant_cache.py
rope_quant_insert(latent, positions, cos_sin_cache, kv_cache, slot_mapping, compress_ratio, fp8_scale=None) ¶
Apply GPT-J RoPE and publish a latent to the compressed KV cache.
The BF16 latent supplies both NoPE quantization and RoPE input. It is read only for valid slots at group boundaries. The cache dtype selects the layout: uint8 is the fp8_ds_mla paged layout (576 value bytes and eight segregated UE8M0 scale bytes per token, including one zero padding scale); bfloat16 and float8_e4m3fn are the plain [448 NoPE | 64 RoPE] rows read by FlashInfer, the latter scaled by the per-tensor fp8_scale.