Repository navigation
glm cuda: TF_GLM_KEEP_SEQS, a released stream's sequence stays for its next request - #4809
Conversation
tools/pr_check.py looks for the pull request's number in the Unreleased line.
|
Thanks @BadAd84 for this, and for the careful write-up. The trade between memory and the per-request fill is stated plainly, and keeping it a setting is the right call. The change itself looks right to us:
One small fix is needed. GLM's environment test counts the After that, the remaining question is the full model. Your check ran with two layers. If you can, please run the same comparison, kept against fresh with the poisoned arena, on the complete checkpoint. We'd like to see every layer kind and the MTP head covered, and a prompt-cache resume that lands on a kept slot. There's a small changelog overlap with main, which we'll sort out on our side. Thanks again.
|
|
Thanks @BadAd84. The The one item still open is the full checkpoint: the same kept-against-fresh comparison with the poisoned arena, covering every layer kind and the MTP head, plus a prompt-cache resume that lands on a kept slot. The changelog overlap with main is ours to sort out.
|
|
Thanks Synthena, and thanks for reading it that closely. The switches list is fixed in 40d4e19: On the full checkpoint, you are right that two layers leaves most of it untested. I ran the same comparison over the complete checkpoint across the three ranks, each rank its own part, in 266 seconds. Every layer kind and the MTP head are in it, and the planted controls fired before the comparison ran: Still to come: the prompt-cache resume that lands on a kept slot. The changelog overlap is yours to handle, thanks. |
|
Thanks @BadAd84. The environment registration fix is present, and the complete-checkpoint comparison now covers the earlier two-layer gap, including the poisoned arenas and planted controls. The remaining case is the prompt-cache resume onto a kept slot. Please include the exact tested head, checkpoint revision and launch settings with that receipt so the results stay reproducible. We will handle the changelog overlap.
|
|
Thanks @BadAd84. The new test now saves a prompt state, restores it onto the same retained slot, compares tokens, logits and drafts with a fresh run, and checks that poisoning the saved state is detected. That covers the missing test case in source. The earlier complete-checkpoint result is also credited. The remaining item is the new restore test’s result, with the exact tested head, checkpoint revision and launch settings. The thread doesn't have that result yet. We will handle the changelog overlap.
|
|
I checked zig build test-glm-keep-seqs-host -Dfixed-cpu --summary all
zig build compile-cuda-tests -Dtarget=x86_64-linux-gnu -Dfixed-cpu -j2 --summary allThe M5 Max host suite passed 14 of 14 tests. The Linux x86_64 CUDA test runner, including the new restore test source, cross-compiled successfully in all 12 steps. That target uses placeholder kernel images on this toolchain. The checkpoint-backed CUDA restore result requested above is still pending. Igor Lessio - AIFLOW LABS |
|
I reran the kept-sequence checks on the exact #5013 train tip
The remaining check is the model-backed Igor Lessio - AIFLOW LABS |
…e next request Engine.release frees every unpaged slot's sequence, so a server's slots 1 to 3 rebuild per request: the next request allocates a window, zeroes it and fills it from the prompt. Slot 0 already keeps its sequence across requests; with TF_GLM_KEEP_SEQS=1 every slot does, as the default-off switch its name implies. The setting is read through platform/environment.zig on every rank, since release runs on each of them. A released sequence keeps its arena and its State reset by the next request's begin; nothing else is held, so an idle slot is the same bytes it held after its last release. glm-keep-seqs-check compares kept sequences against fresh ones byte for byte and step for step: greedy tokens, bf16 logits rows and the MTP head's drafts at each step. It covers a prompt shorter than the one the slot last held (6,000 tokens, then 600 and 3,000), a kept state with every byte poisoned to 0xFF, slot 0 with the switch off, and it plants a control that must differ from the fresh run, failing as planted when the comparison cannot see it.
The check joins zig/tests/cuda/main.zig's commands as glm-keep-seqs-check CKPT ID_PATH RANK WORLD, beside glm-solo-check and glm-pair-check, so compile-cuda-tests builds it and the GPU runner can dispatch it.
keepsSequence takes the engine now, so the comment says the slot keeps its sequence rather than naming a call shape the code no longer has.
Engine.init takes usize for both; the runner hands the check c_int, as the other GLM checks cast theirs. compile-cuda-tests failed on the uncast form.
The switch was read where the server builds its engine, which left any other caller of Engine.init without it: the GPU check set the variable and still saw the setting off. It is a field of ranks.Settings now, read once from the environment and passed in the engine's options, so the server and the checks agree and the ranks' agreement covers it too.
The fingerprint is compared across ranks to stop a run whose settings differ, and it lists its fields one by one, so the new setting joins it and its version is 24. The divergence test gains the field, so a rank that keeps or frees a released sequence unlike its peers stops the run.
…ep_seqs Fingerprint.Field and mismatch() list the fingerprint's fields by hand, so the new setting joins both. Without them the divergence test named a member the enum did not have.
…y field The mismatch report's switch covers every Fingerprint.Field value, so a new member needs its line or the runner does not compile.
zig/src/families/glm/cuda_env_test.zig asserts that every glm row is named in one of its lists and that the count matches, so a new flag row has to be listed or the test fails on the count.
The check compared a kept sequence against a fresh one; it never resumed. This adds the resume: a prompt state kept at 2048, a second request that resumes from it on the same kept slot, compared against a fresh run on tokens, bf16 logits rows and MTP drafts, with a control that poisons every prompt-cache byte and must make the comparison fail.
|
Thank you @BadAd84. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
Refs #4247.
Engine.releasefrees every unpaged slot's sequence, so a server's slots 1 to--parallelrebuild per request: the next request allocates a window, zeroes itand fills it from the prompt. Slot 0 already keeps its sequence across requests.
TF_GLM_KEEP_SEQS=1makes every slot do what slot 0 does. Unset or0is main'sbehaviour, byte for byte.
The setting is a row of
platform/environment.zigand a field of the ranks'settings, read once from the environment and passed in the engine's options, so
the server and the GPU checks reach the same engine with the same value. It is
in the ranks' fingerprint, so a run whose ranks disagree stops before the
weights load.
What a kept sequence holds while idle
Its arena, which is the window the sequence writes its KV into, and its
State.Nothing else: no prompt rows, no logits, no drafter state. The next request on
that slot runs
begin, which resets theState, and the kept arena is laid overby that request's own prefill exactly as a fresh one would be.
What the setting saves is the allocation of a whole window, the zero fill of a
fresh arena, and that fill's copy of the prompt.
Startup memory
Unchanged in both arms. Nothing is kept at startup: with the setting on, a slot's
first request still allocates, and a sequence only stays if it was released. The
held memory appears after a release, as one window per idle slot, and goes back
when the engine closes. A paged slot still gives its pages back on release.
Tests
zig build test-glm-keep-seqs-hostruns four cases with no GPU. Off, a releasedslot's sequence is freed and the next request allocates and zeroes a whole window.
On, it allocates, fills and frees nothing and the same sequence comes back. Slot 0
keeps its sequence either way, and every slot's arena goes back at close. A paged
slot still gives its pages back with the setting on.
On one GB10 the check runs with
TF_GLM_LAYERS=2, because the 4bpw snapshot is163.6 GiB and one rank holds less than that; the comparison is unchanged by the
layer count.
glm-keep-seqs-check CKPT ID_PATH 0 1compares kept sequences with fresh ones:the same greedy tokens, the same bf16 logits rows and the same MTP head drafts at
each of 24 steps. It runs a prompt shorter than the one the slot last held (6,000
tokens, then 600 and 3,000), a kept state with every byte poisoned to 0xFF, slot 0
with the setting off, and a planted control that must differ from the fresh run.
The control fails as planted if the comparison cannot see it.
Gates
Base is upstream
mainat 0b39f4d.python tools/pr_check.pyagainst that base: 0 errors, 1 warning, thechangelog line, which needs this pull request's number and goes in as a commit
once it exists.
on the base, 7,704 and 165 on this branch, 0 new.
zig build test-glm-keep-seqs-host: 4 of 4 pass, no GPU.zig build compile-cuda-tests: the check compiles into the GPU runner.test-glm-startup-host,test-startup-watch-host,test-glm-pdl-policy-host,test-glm-exl3-prompt-host,test-glm-relay-host,test-glm-warm-peers-host,test-kda-host,test-glm-thin-weights-host.zig build test test-goldenon an x86_64 host whose GPU cannot run thesekernels: every failure is one of 27 test binaries under the
teststep, and thepristine base fails the same 27 with the same step set, so they are the host and
not the change.
test-goldenpasses on this branch.zig fmt --check build.zig zig,git diff --check: clean.Could this be the default?
No. It is free when unused and it keeps tokens exactly, but it trades memory for
the fill: each idle slot holds its window, so a server with
--parallel 4holdsthree more windows than main does while nothing is in flight. That is an
operator-visible trade, and a setting is the honest place for it. Unset is main's
behaviour.
The check's run
On one GB10, branch
ed007da20(its patch is byte-identical tofe63072f3, thehead after the rebase onto
0b39f4d64),TF_GLM_LAYERS=2,TF_GLM_KEEP_SEQS=1, withthe image built from that tree:
The same command with the setting unset stops before the comparison:
FAIL glm-keep-seqs-check needs TF_GLM_KEEP_SEQS=1. Both arms print the samestartup lines, the checkpoint digest and the loader's read-ahead, and no code
before
releasereads the setting, so nothing about startup memory or startuptime moves. This runner does not print the server's own memory receipt; two
server boots would show it, and I will post them if you want that line rather
than the argument.