Repository navigation
Nemotron CUDA: kept prompt states hold each attention layer's first rows only - #722
plotarmordev wants to merge 3 commits into
Conversation
…messages end A prompt pass cuts a chunk at each keep, since a row's bits do not depend on where its chunk is cut, so the prompt cache keeps states at the history's end instead of the 2,048-row grid point below it. tf-cuda-test prompt-cuts checks a pass cut on and off the grid, and passes resumed from each cut, against one uncut pass.
…the chunk there The Mamba scan runs to the keep, its state and the conv rows a cut would leave are copied aside, and the scan runs on with the same bits; the keep's saved state takes those planes in place of the live ones. A chunk with several keeps still ends at the first. A conversation's later turn now prefills in one pass.
…ws only A state kept after at tokens copies each layer's first at KV rows instead of the whole window's, and the cache counts it at that size; the rows past it, which no pass reads before writing them, stay as they are on restore. prompt-cuts fills those rows before each restore.
|
Closing this as superseded by 1.0.8. #723 builds on this branch. It will be brought onto 1.0.8's prompt states and re-measured there before it asks for review again. |
ashhart#721 and ashhart#722 were superseded by 1.0.8 (ashhart#670: states keep and resume at any row, kept states hold the prompt's rows); this merge takes 1.0.8's prompt states and keeps only this PR's change on top.
The contributor's commit landed above on 1.0.8's prompt states. The head also holds ashhart#721's and ashhart#722's commits, whose changes 1.0.8 had already made in its own form and whose tests landed above; this keeps the head in the history with no change to the tree.
|
Thank you, @plotarmordev. Yes, 1.0.8 already keeps only a prompt's own key and value rows, so this one is covered. Its test landed in 1.0.9: |
The contributor's commit landed above on 1.0.8's prompt states. The head also holds ashhart#721's and ashhart#722's commits, whose changes 1.0.8 had already made in its own form and whose tests landed above; this keeps the head in the history with no change to the tree.
ashhart#721 and ashhart#722 were superseded by 1.0.8 (ashhart#670: states keep and resume at any row, kept states hold the prompt's rows); this merge takes 1.0.8's prompt states and keeps only this PR's change on top.
What this changes
On top of #721 (its two commits come first here; this pull request adds the last one). A Nemotron CUDA prompt state kept after
attokens holds each attention layer's firstatKV rows instead of the whole window's, and the prompt cache counts it at that size, so the cache holds more states and each keep copies less.cuda_state.zig:Buffers.keptBytes(at),snapshotFrom(ops, at, from)andrestoreAt(ops, saved, at)copy each attention layer's firstatrows of the K and V planes and every other plane whole;snapshot/restore(the profiling tools') keep the whole window.cuda_reuse.zig:bytes(at)reports that size; save and restore use it. The KV rows pastatare left as they are on restore: no pass reads a row past its position before writing it.tf-cuda-test prompt-cutsfills those rows with a value (bf16 10.0) before each restore and hashes the prompt's rows of the KV planes, so a pass whose result depended on one would fail it.Receipt
Environment: as Nemotron CUDA: keep prompt states where messages end, staged inside a chunk without an extra pass #721 (two DGX Sparks, GB10, driver 580.173.02, Nemotron 3.5 Lightning MLX-4bit @
d9d758fb, one7c523eb).Exactness:
prompt-cutspasses with the rows past each keep filled. Twelve conversations served turn by turn (each turn of every conversation, then the next turn), four turns, 4.7k to 8.5k-token prompts,--context 65536 --parallel 4 --prompt-cache-gib 4: all 48 replies equal the cache-off server's on both Sparks, two sessions each.Prompt speed and cache, the same workload:
At
--context 16384and the default 16 GiB nothing was evicted in the earlier workloads either way, so the gain shows when kept states compete for the budget, as with many conversations or a long window.Decode speed: unchanged.
Tests run:
zig build test39/39 steps, 451/451 tests;zig build test-cuda-host24/24 steps; the server tests 127/127 and 104/104 (zig/tests/server/zig_test.sh); the frozen server goldens 309 of 319 equal, 0 unexpected differences, as onmain;zig fmt --checkclean on the changed files;lean_check.py534 problems, as onmain. GPU:tf-cuda-test prompt-cutswith the filled rows (above).Not run, and why: Metal (unchanged). The NVFP4 checkpoint, RTX cards (no hardware here).
Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.prompt-cuts.)