perf(qwen3.6): Q4_K on-read LM head — requantize the Q6_K output projection at load#308
Open
minion1227 wants to merge 1 commit into
Open
perf(qwen3.6): Q4_K on-read LM head — requantize the Q6_K output projection at load#308minion1227 wants to merge 1 commit into
minion1227 wants to merge 1 commit into
Conversation
…ection at load The output projection (LM head, vocab 248320 x hidden 2048) is the single largest weight read per decoded token and ships as Q6_K (6.5625 bpw). Requantize it to Q4_K (4.5 bpw) once at model load, then decode on-read through the existing int8 dp4a Q4_K MMVQ path, trimming that per-token read ~31%. - New kernels/csrc/cuda/quant/lmhead_requant.cu: a per-32-value affine k-quant fit (weighted least-squares over a short offset ladder) emitting standard Q4_K super-blocks; runs once at load. Scoped to the Qwen3.6 output (vocab 248320) so the Qwen3-30B guard model is left on its original path. - SPARKINFER_LMHEAD_Q4K=0 restores the Q6_K path. RTX 5090 (sm_120), same-box A/B: +3.4% (128-ctx) / +3.3% (512) / +3.1% (4k) decode, no regression at any context. Accuracy vs llama.cpp (pinned ref, teacher-forced): top-1 0.970 (bar >=0.90), KL 0.0197 nats (bar <=0.20). PPL 2.83 -> 2.86.
081b78f to
f3aa786
Compare
1 task
Member
⏸ Merge conflict — rebase before evalThis branch conflicts with Please rebase onto |
Member
|
The round's |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Requantize the Qwen3.6 output projection (LM head) from Q6_K to Q4_K once at model load, then decode it on-read via the existing int8 dp4a Q4_K MMVQ. The LM head (
vocab 248320 × hidden 2048) is the single largest weight read per decoded token; Q6_K→Q4_K trims that read ~31% (6.5625 → 4.5 bpw).Why
The output projection runs once per token and is the largest single weight read on the decode path (~11–12% of decode bandwidth). Every other big projection already runs int8 dp4a / split-K; the LM head was still full Q6_K on-read.
How
kernels/csrc/cuda/quant/lmhead_requant.cu— a per-32-value affine k-quant fit (weighted least-squares over a short offset ladder) that emits standard Q4_K super-blocks. Runs once at load; no per-token cost.qwen35.cpp) — dequant the Q6_K output → requant to Q4_K → swap in, setlm_head_type = 12. Scoped to the Qwen3.6 output (vocab 248320), so the Qwen3-30B guard model stays on its original path.launch_mmvq_q4k_f32against the pre-quantized Q8_1 activation.SPARKINFER_LMHEAD_Q4K=0restores the Q6_K path.Results — RTX 5090 (sm_120), same-box A/B (
SPARKINFER_LMHEAD_Q4K=0vs=1)No regression at any context (uniform +3%, since it only shrinks a per-token read).
Accuracy vs llama.cpp (pinned reference
6f4f53f, teacher-forced, 100 positions):Correctness stays well inside the gate because the reduction is confined to the final projection and the k-quant fit is weighted toward the high-magnitude logits.