vllm.models.flint.ops.qkv_fused
¶
Fused decode qkv for Flint at M <= 8 tokens (CuTe DSL), two kernels:
fused_add_rms_norm(orrms_normfor the first layer) writing the normalized activationsxnand the new residual; it releases its PDL dependents immediately so the second kernel's weights stream in meanwhile.- the qkv GEMV (same fragment math, K split and summation order as
nvfp4_gemvat M <= 8) whose 16-row CTAs form one cluster per head and send their BF16 rows to rank 0 through DSMEM, which applies per-head q/k RMSNorm, NeoX RoPE (FP32 cos/sin table, FP32 math) and the paged KV-cache write likeqk_norm_rope_cache.
Numerics are those of norm.fused_add_rms_norm / norm.rms_norm ->
GEMV -> qk_norm_rope_cache; the per-head q/k norm sums its squares in a
different order, so q/k can differ from that path by one BF16 ulp.
Functions:
-
flint_qkv_fused–Residual-add RMSNorm + qkv GEMV + q/k norm, RoPE, cache write for
-
no_rope_table–Placeholder fp32 cos|sin argument for kernels compiled without RoPE.
flint_qkv_fused(x, residual, norm_weight, eps, weight, weight_scale, global_scale, q_norm_weight, k_norm_weight, qk_eps, cos_sin_cache, positions, k_cache, v_cache, slot_mapping, num_q_heads, num_kv_heads)
¶
Residual-add RMSNorm + qkv GEMV + q/k norm, RoPE, cache write for
M <= 8 tokens.
Parameters:
-
(x¶Tensor) –[M, 2048] bf16 attention input (contiguous).
-
(residual¶Tensor | None) –[M, 2048] bf16 residual, or None for the first layer.
-
(norm_weight¶Tensor) –Input RMSNorm weight.
-
(eps¶float) –Input RMSNorm epsilon.
-
(weight¶Tensor) –qkv weight, NVFP4 (uint8 [N, 1024]) or BF16 [N, 2048].
-
(weight_scale¶Tensor | None) –NVFP4 128x4-swizzled block scales (None for BF16).
-
(global_scale¶Tensor | None) –NVFP4 fp32 global scale (None for BF16).
-
(q_norm_weight¶Tensor) –Per-head q RMSNorm weight.
-
(k_norm_weight¶Tensor) –Per-head k RMSNorm weight.
-
(qk_eps¶float) –q/k RMSNorm epsilon.
-
(cos_sin_cache¶Tensor | None) –[max_pos, 128] fp32 (cos | sin), or None (no RoPE).
-
(positions¶Tensor) –[M] int64.
-
(k_cache¶Tensor) –[blocks, block_size, kv_heads, 128] view.
-
(v_cache¶Tensor) –Same shape and strides as
k_cache. -
(slot_mapping¶Tensor) –[<= M] int64; negative slots and tokens beyond it are not written.
-
(num_q_heads¶int) –Number of q heads.
-
(num_kv_heads¶int) –Number of KV heads.
Returns:
Source code in vllm/models/flint/ops/qkv_fused.py
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 | |
no_rope_table(device)
¶
Placeholder fp32 cos|sin argument for kernels compiled without RoPE.