Commit d21c442
committed
feat(fold): Tier D1 — bf16 merged-QKV default-ON across dense/coder/dflash/Gemma
Executes Tier D1 of the cross-arch merged-GEMM fold plan
(.agents/specs/arch-fusion-fold-plan-2026-07-30.md). The q/k/v projections that
SHARE the layer input collapse to ONE bf16 vt::MatmulBT over the merged
[Nq+Nk+Nv,H] owner + a contiguous vt::QkvSplit (the OLMo-2/Granite/StableLM
exemplar), replacing three per-shard GEMMs (folds the tiny GQA k/v GEMMs into one
wide tensor-core GEMM, -2 launches/layer).
The shared gate Qwen3QkvMergeEnabled() (alias MergedQkvEnabled(), env
VT_QWEN3_QKV_MERGE, dense_attn_block.h) FLIPPED default-ON. Consumers folded:
qwen3_dense (dense_attn_block.h), qwen3_coder (inherits via the shared dense
AttnBlock, qwen3_moe.cpp), qwen3_dflash (qwen3_dflash.cpp), Gemma-1/2/3/4
(gemma*.cpp). No loader concat — every consumer already packs the merged
qkv_proj owner. RoPE UNCHANGED (no RopeNeox->RopeFromCache swap; the compounding
second-1-ULP-flip hazard avoided). dflash_gguf (keep-quant merged instance) is
OUT of D1 scope. VT_QWEN3_QKV_MERGE=0 restores the byte-identical 3-shard A/B in
the same binary.
The merge is bit-exact GEMM math (wider N): tests/vt/test_ops_qkv_merge.cpp (CPU,
RED-first) byte-compares merged MatmulBT+QkvSplit == three separate MatmulBT
across GQA/MHA/MQA/wide-head shapes (a wrong split offset fails the check). The
ONLY byte effect is the downstream FA2 1-ULP on the 0.6B genuine bf16 near-tie,
so the whole family batched behind ONE 0.6B near-tie golden regen.
Golden regen (0.6B ONLY): the default flip shifted the 0.6B anchor at 2
divergence points (p5 tok11, p10 tok10; greedy cascades) -> regenerated via
scripts/qwen3-neartie-gap.py teacher-forcing the vLLM oracle, all tokens within
the near-tie band (max gap 0.125 nats). Qwen3-4B our_ids.npy UNCHANGED (0 diffs,
measured-neutral) + qwen3coder UNCHANGED (0 diffs).
GATED (DGX GB10 sm_121a, RelWithDebInfo + cutlass-4.5.0 + triton, one flock):
test_ops_qkv_merge 2/2*14; test_qwen3_paged_engine 0.6B 16/16 + 4B 16/16;
test_qwen3coder_paged_engine 6/6; test_gemma2_forward SACRED 48/48
(global+sliding); test_gemma4_paged_engine STRICT 32/32; shared-header canary
test_qwen27_paged_engine 235/235 UNCHANGED. All four record checkers rc=0.
FOLLOWING_AGENTS_PROTOCOL
Assisted-by: Claude Code:claude-opus-4-8 [ClaudeCode]1 parent 08eec2a commit d21c442
14 files changed
Lines changed: 295 additions & 40 deletions
File tree
- .agents
- specs
- docs
- include/vllm/model_executor/models
- src/vllm/model_executor/models
- tests
- parity/goldens/qwen3_greedy_0_6b
- vt
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | | - | |
102 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
103 | 104 | | |
| 105 | + | |
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34351 | 34351 | | |
34352 | 34352 | | |
34353 | 34353 | | |
| 34354 | + | |
| 34355 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
109 | 121 | | |
110 | 122 | | |
111 | 123 | | |
| |||
0 commit comments