Repository navigation
[Engine] Inkling 2 drafter: load Q4_0 and IQ4_NL drafter files - #321
Open
okada-shogo wants to merge 1 commit into
Open
okada-shogo wants to merge 1 commit into
okada-shogo wants to merge 1 commit into
Conversation
…ard multiplies The drafter's loader took its layers' matrices only as BF16 or Q8_0, though they go through lin() like the target's. It now takes any type native_mmvq_supported() names, so a drafter file requantized to Q4_0 or IQ4_NL (llama-quantize, keeping markov_w1, joint_proj and dspark_hidden_out in BF16) loads: 455 MiB of drafter weights in VRAM instead of 580 (RTX 2070 Super), 28 more experts in the cache. Q8_0 and BF16 files load as before. The target checks every draft. A smaller drafter changes two things the tokens can follow on an 8 GB card: which drafts are kept (windows of other lengths round near-ties apart, as drafter on vs off already does), and which experts the larger cache computes on the card rather than on the CPU, as any change of the VRAM reserve does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem and result
Inkling 2's DSpark drafter (
--draft-model) loaded its layers' matrices only as BF16 or Q8_0. They run through thesame matrix kernels as the model's own weights, so a smaller file works too. A Q4_0 or IQ4_NL drafter made from the
Q8_0 one (llama-quantize, keeping three small BF16 tensors) is 125 MiB smaller in VRAM, and the expert cache gets it.
With this PR such a file loads. Q8_0 and BF16 drafters load as before.
Decode tok/s, mean of 10 cases (code, chat and prose text; decode after 302, 2,048 and 8,192 tokens at 32K context, and
code after 32,768 tokens), 3 rotated rounds each, 256 tokens written,
--prompt-batch 1024 --vram-reserve-mib 768 --prompt-int8,STRATA_PREFILL_NVFP4=w4a8 STRATA_INK_FAST_CTRL=1 STRATA_INK_PRESTAGE=1. Change is the mean of theper-case changes against the Q8_0 drafter:
The gain is small: about +1 to +2% on average, from the 28 to 57 more experts in VRAM. Single cases move from -10% to +13%
because the share of drafts kept changes from run to run (the draft policy follows measured times), so read the
means. Prompt speed is the same (within 1%). The drafter's acceptance with the 4-bit files is about the same as with
Q8_0 (the tables below).
RTX 2070 Super 8 GB: every case (decode and prompt tok/s, drafts kept, each run)
IQ4_NL: decode tok/s (mean of runs), change vs Q8_0; acceptance = drafts kept / drafted
IQ4_NL: prompt tok/s (mean)
IQ4_NL: each run, decode tok/s
RTX 2070 8 GB (second box): every case (decode and prompt tok/s, drafts kept, each run)
UD-Q2_K_XL: decode tok/s (mean of runs), change vs Q8_0; acceptance = drafts kept / drafted
UD-Q2_K_XL: prompt tok/s (mean)
UD-Q2_K_XL: each run, decode tok/s
RX 9070 XT 16 GB (HIP): every case (decode and prompt tok/s, drafts kept, each run)
IQ4_NL: decode tok/s (mean of runs), change vs Q8_0; acceptance = drafts kept / drafted
IQ4_NL: prompt tok/s (mean)
IQ4_NL: each run, decode tok/s
UD-Q2_K_XL: decode tok/s (mean of runs), change vs Q8_0; acceptance = drafts kept / drafted
UD-Q2_K_XL: prompt tok/s (mean)
UD-Q2_K_XL: each run, decode tok/s
Related discussion
none
Approach
ds_load()takes a drafter matrix in any typenative_mmvq_supported()names, besides BF16. Everything else(the fold, the head screen, the Markov head) is unchanged.
llama-quantize --allow-requantize --tensor-type markov_w1=bf16 --tensor-type joint_proj=bf16 --tensor-type dspark_hidden_out=bf16 --tensor-type dspark_fuse=f32 dspark-Inkling-2-Mini-Q8_0.gguf out.gguf Q4_0(or
IQ4_NL).Validation
Passed:
STRATA_GPU_EXPERTS=1800IQ4_NL,2600UD-Q2_K_XL,
STRATA_FREEZE_EXPERTS=1),STRATA_SPEC_FIXED=1, the settings above, greedy 128 tokens after code,chat and prose prompts of 302 and 2,048 tokens: the Q8_0, Q4_0 and IQ4_NL drafters each give the same tokens as no
drafter, 36 of 36.
all 12 cases. Against no drafter they differ in 11 of 12, as main's Q8_0 drafter already does on 8 GB cards (windows
of other lengths round near-ties apart).
Failed:
Not run:
native_mmvq_supported()(this repo builds no Metal backend).measured.
Limits
cudaGraphInstantiate: out of memory([Engine] Retry instead of failing when a CUDA graph is out of VRAM #301's case; main's Q8_0 drafter hits it too at the default reserve).drafter takes ~300 experts' VRAM and its prompt features cost prompt speed); this PR does not change that.
run with the Q8_0 drafter: other drafts give windows of other lengths, which round near-ties apart (as drafter on
vs off already does there), and the larger expert cache computes other experts on the card instead of the CPU.
🤖 Generated with Claude Code