Repository navigation
nemotron hip: prompt-cache states key the token the MTP head absorbed (#4999) - #5003
BlivionIaG wants to merge 1 commit into
Conversation
…ashhart#4999) A non-final prompt chunk absorbs its last row into the MTP head with the token after it, but the cache keyed a state at a cut by the tokens before it only. A prompt that matched through the cut and differed at the next token resumed there and re-absorbed that row with its own token, writing the head's K/V in the last adopted page, which the cache and other streams hold. With the head loaded the cache rules take a lookahead of one token, as GLM and Flash Next do: a state resumes only where its next token repeats, the head's rows are complete at the resume point, and the resumed absorb, its flag and the hidden row kept in each snapshot for it go. Without the head the rules and resumes are unchanged. The host test resumes two prompts that share 512 tokens and differ at token 512 through the real cache, page swaps and prompt chunks, and checks the first stream's head rows. The GPU invariance check calls the cache with its salt and the seed lane's key again.
|
I independently trial-merged zig build test-nemotron-hip-resume-host test-nemotron-hip-faults-host test-hip-followers-host check-native-hip-host -Dhip=true -Dfixed-cpu -j2 --summary all
zig build test-prompt-cache-host test-prompt-cache-miss-host test-cache-agent-host -Dhip=true -Dfixed-cpu -j2 --summary allThe shared-cache targets passed 804/804. This was a host and cross-compile check. The served HIP result remains the AMD device evidence. Igor Lessio - AIFLOW LABS |
|
Thanks, @BlivionIaG. The lookahead key now covers the token already absorbed by the head, and resume no longer rewrites that shared row. The focused regression and no-head control support the fix; the posted readback shows why it matters even though those token hashes stayed equal. The source is ready to land, with changelog integration on our side. The unrun concurrency, draft-off and TP cells remain separate qualification limits.
|
What this changes
Before: with the MTP head loaded, a prompt matching a kept Nemotron HIP state through the cut, but not at the token after it, resumed at the cut. It then re-absorbed the head's row at
cut - 1with its own token, writing into the last adopted page. That page is shared with the prompt cache and with other streams.After: with the head loaded, the cache rules take a one-token lookahead, as GLM and Flash Next do. A state resumes only when the token after it repeats, and the head's rows are already complete at the resume point (
mtp_len = from). The resumed absorb, itsresumedflag and the hidden row that each snapshot kept for it are removed. Without the head, the rules and resumes are unchanged.atc overlap --json(base upstream/maind1ff890729, 2026-11-25T07:39Z, complete on the named PRs): glm cuda: a GB10 holds the BF16 linears exactly in 12 bits a weight #3509 and CUDA: an int4 W4A16 kernel for GPTQ group-128 routed experts and the LM head #4183 conflict onCHANGELOG.mdonly, since both add a line at the top of Unreleased; the rest are clean.Checks on this head
e6f48fa395(one commit ond1ff890729)python3 tools/zig/lean_check.py: 165 on the base and 165 on this head, 0 new. All 165 are inherited.tools/pr_check.py --base d1ff890729: 0 errors and 1 advisory warning (no PR number yet).-Dhip=true:zig build test-nemotron-hip-resume-host: 5/5 pass. Fails on main withexpected 612, found 9512. That run used the test with main'sbeginlines andprefix.initsignature.test-nemotron-hip-faults-host: 6/6.test-hip-followers-host: 12/12.check-native-hip-host: builds.zig fmt --check build.zig zigandgit diff --check: clean.tf-nemotron-hip-test invariancepasses. A served prompt-cache resume at 128/193 plus 4 decode steps matches a fresh prefill bit for bit (Mamba state, final row, model K/V and logits). This test calledprefix.beginwithout the salt and kept nothing, because the seed lane had no key; both are fixed here.zig build test test-goldenin full, because the shared workstation's build lock was busy; I ran the named steps above instead. Metal and CUDA are not reached by this change.Receipt
Main against branch: AMD Radeon PRO V620 (gfx1030), ROCm 7.14, Zig 0.17.0, NVIDIA-Nemotron-3.5-Lightning-30B-A3B-MLX-4bit with its MTP head;
--mtp-drafts 3 --parallel 1 --context 4096 --prompt-cache-gib 2, greedy. There were four token-id/v1/completionsrequests:A[0:520].A[0:1100].A[0:512]plus 8 other tokens.A throwaway read-back (not in this diff) hashed the head's K and V at position 511:
dbe9a117…→6411494c…dbe9a117…Boxes it reaches: Nemotron on HIP with
--mtp-drafts, single rank and rank 0 of TP. Followers hold no head and keep their cache rules unchanged.New switch? None.
Environment: above. Base
d1ff890729; the GPU cells ran on4c79cfe346plus this change, and nothing between those two commits touches the Nemotron,hip_serveor radix code.Paths and platforms: the Nemotron HIP prompt cache and the MTP absorb. Ran on gfx1030. Not run on gfx1100, gfx1151, gfx1201 or TP > 1.
Exactness:
token_shamatches across main and branch, with and without B: A13e6ce2279a7d, A2749be1c472e9, Bbe6a63a683cf, A3c31385f7d0a9.Draft acceptance: A3 accepted 161 of 208 drafts on main with and without B, and on the branch with and without B. The wrong row changed nothing measurable in this run.
Decode speed: not measured with
tools/bench_openai.py. The decode path is unchanged; one absorb row less per resume.Prompt speed: a prompt that differs from a kept one exactly at the token after a kept state now resumes from an earlier state. In the run above, B went from 512 cached tokens to 0. Other resumes are unchanged.
Licence of new weights or drafter: n/a.
Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. A resume matches fresh (invariance) and tokens are unchanged;"draft": falseand concurrent runs were not run.