Repository navigation
[Engine] Inkling 2 drafter: lend prompt scratch to the expert cache - #316
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
…r too With --draft-model, Inkling 2 kept its prompt batch's scratch in VRAM for the whole run (one layout), because the drafter's features were strided by the prompt batch's rows: 546 MiB on an RTX 2070 Super at --prompt-batch 1024, where the drafter's run without it has 32 MiB for the few tokens' layout. The features are now strided by the rows of the layout in use (buf_rows_), which is the prompt batch's in one layout as before, so the two scratch layouts (VecSzn's, as Qwen3.6 has them) and the lending to the expert cache between prompts are on with the drafter as well. Placement only: every call computes the same values in the same order; the features sit at another stride in the few tokens' layout. 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 keeps a small scratch for decode and lends the prompt batch's scratch to the expert cache between prompts.
With the DSpark drafter (
--draft-model) this was off, because the drafter's features were laid out by the promptbatch's rows. So with the drafter the whole prompt scratch (546 MiB at
--prompt-batch 1024) stayed in VRAM whileanswering.
With this PR the drafter's features follow the scratch layout in use, so the lending works with the drafter too.
Decode tok/s, mean of 3 runs (RTX 2070 Super 8 GB, Inkling 2 Mini IQ4_NL, drafter Q8_0,
--prompt-batch 1024 --vram-reserve-mib 768, 256 tokens written; three texts in place of the memorized benchmark text: code (C++ source of this engine), a multi-turn chat in the model's template, and novel prose (Pride and Prejudice, from chapter 20; a well-known book, so its drafts are kept more often)):Experts in VRAM after the request, and the share of drafts kept (same runs, mean):
Prompt tok/s (same runs)
Each run (tok/s)
Earlier runs on a memorized benchmark text (not comparable: drafts kept ~99% after 2K+)
Experts in VRAM after the request, RTX 2070 Super 8 GB, Inkling 2 Mini IQ4_NL, drafter Q8_0,
--prompt-batch 1024 --vram-reserve-mib 768(the speed runs below; one engine a request):Prompt tok/s, mean of 3 runs (RTX 2070 Super 8 GB, IQ4_NL, drafter Q8_0,
--prompt-batch 1024 --vram-reserve-mib 768):Decode tok/s, mean of 3 runs (RTX 2070 Super 8 GB, IQ4_NL, drafter Q8_0,
--prompt-batch 1024 --vram-reserve-mib 768):Output bits are unchanged (frozen identity below).
Related discussion
none
Approach
ds_tap_is allocated per layout (assign_scratch(),buf_rows_rows), but three places indexed it with theprompt batch's row count. They now use
buf_rows_. In one layoutbuf_rows_equals the prompt batch, so nothingchanges there.
scores_apart()no longer excludes the drafter, so the two layouts and the lending are on with it.STRATA_VMM_RELEASE_WITH_ADDRESSES).Validation
Passed:
(
STRATA_GPU_EXPERTS=600 STRATA_FREEZE_EXPERTS=1),STRATA_SPEC_FIXED=1,--draft-model, greedy token ids,2,048 + 128 and 8,192 + 128 tokens: SAME.
on under the freeze: SAME for both prompts. Without the drafter that build is SAME as main too.
e2e-nw.sh, 3 rounds).Failed:
Not run:
without it).
Limits
--vram-reserve-mib 768: at the default reserve, main ends some drafter requests withcudaGraphInstantiate: out of memory(fixed separately in [Engine] Retry instead of failing when a CUDA graph is out of VRAM #301), which spoils a speed comparison.without the drafter.
cudaGraphInstantiate: out of memoryon main and here; [Engine] Retry instead of failing when a CUDA graph is out of VRAM #301fixes that separately.
🤖 Generated with Claude Code