vllm.models.kimi_k3.nvidia.ops.dsa_indexer
¶
Fused Triton prologues for the Kimi K3.1 DSA layer, replacing the small
launch-bound kernels between the projection GEMMs and sparse_attn_indexer.
The quant helpers and dsa_fused_prologue follow fused_norm_rope in
deepseek_v32/common/kernels.py (without RoPE); they are copied so this
model does not depend on another model's private kernels.
Functions:
-
dsa_fused_prologue–fused_norm_ropefor the NoPE Kimi K3.1 DSA layer: the q_a / kv_a -
indexer_k_norm_quant_insert–LayerNorm + FP8 quant + cache insert of the indexer key, and the -1
-
indexer_q_quant_fold_weights–Quantize
index_q[T, H, D]to FP8 per head (ue8m0 scales) and
dsa_fused_prologue(q_c, kv_c, k_pe, index_k, q_norm_weight, kv_norm_weight, k_norm_weight, k_norm_bias, eps, topk_indices_buffer, mla_cache, mla_slot_mapping, index_cache, index_slot_mapping)
¶
fused_norm_rope for the NoPE Kimi K3.1 DSA layer: the q_a / kv_a
RMSNorms, the fp8_ds_mla insert of [kv_c_normed | k_pe], the indexer key
LayerNorm + FP8 insert and the -1 fill of the top-k rows, in one launch.
mla_cache ([num_blocks, block_size, 656]) and index_cache
([num_blocks, block_size, head_dim + 4]) are uint8, possibly strided
page views of a packed cache; None (profile runs) skips the insert. Rows
past a slot mapping or with a negative slot are not inserted.
Returns (q_c_normed, kv_c_normed).
Source code in vllm/models/kimi_k3/nvidia/ops/dsa_indexer.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 | |
indexer_k_norm_quant_insert(k, norm_weight, norm_bias, norm_eps, slot_mapping, kv_cache, topk_indices_buffer, num_tokens)
¶
LayerNorm + FP8 quant + cache insert of the indexer key, and the -1
fill of the top-k rows [:num_tokens].
kv_cache is [num_blocks, block_size, head_dim + 4] uint8, possibly
a strided page view of a packed cache. Rows past slot_mapping or with
a negative slot are not inserted.
Source code in vllm/models/kimi_k3/nvidia/ops/dsa_indexer.py
indexer_q_quant_fold_weights(index_q, index_weights, weight_scale, padded_num_heads)
¶
Quantize index_q [T, H, D] to FP8 per head (ue8m0 scales) and
fold each head's scale into index_weights [T, H] together with
weight_scale.
Returns (q_fp8 [T, P, D], weights [T, P] fp32) where P =
padded_num_heads; heads [H, P) are zero.