Skip to content

keep seqs check: keep the prompt state once, on rank 0 - #5122

Merged
ashhart merged 4 commits into
ashhart:mainfrom
BadAd84:keep-seqs-resume-fix
Nov 26, 2026
Merged

ashhart merged 4 commits into
ashhart:mainfrom
BadAd84:keep-seqs-resume-fix

Conversation

@BadAd84

@BadAd84 BadAd84 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

What this does

The prompt-cache resume case keeps a prompt state from inside the mark callback that prefill fires. Every rank reaches
that mark, so each rank took the same id, and the followers were refused with StateKept while rank 0 waited in the rank
fence for partners that had already exited. A TP=3 run of glm-keep-seqs-check spins and never reaches its PASS line.

Two changes, both inside the callback:

  • it spends itself, so a second pass through the same marks does not keep again;
  • it keeps on rank 0 only, which is how a keep happens in the serve: rank 0 announces the id and gate has every other
    rank keep it.

Why

snapshots.keep takes the next id and sets e.announce; snapshots.gate then tells the other ranks to keepAs that id.
A keep called on every rank therefore takes one id everywhere and collides with the fence's own keepAs, and a rank that
exits on that error leaves the others waiting in the fence.

Verification

  • zig fmt --check zig/tests/cuda/glm_keep_seqs_tests.zig exits 0.

  • zig build test-glm-keep-seqs-host exits 0 on upstream main at 8d3f8f923 with this change.

  • The check itself, glm-keep-seqs-check at TP=3 on three DGX Sparks, image built from this head (glm53-zig:prkeep5),
    TF_GLM_KEEP_SEQS=1, full 61-layer checkpoint, kv8=false and kv8=true: rc 0 on all three ranks, and rank 0 printed

    RESULT resume control kv8=false, 3000-token prompt at 2048 onto a kept slot: poisoned prompt state differs from fresh at step 0, as planted
    PASS prompt-cache resume at 2048 onto kept slot 14 equals a fresh 3000-token prompt: 24 greedy steps' tokens, bf16 logits rows and MTP drafts, kv8=false
    RESULT resume control kv8=true, 3000-token prompt at 2048 onto a kept slot: poisoned prompt state differs from fresh at step 0, as planted
    PASS prompt-cache resume at 2048 onto kept slot 14 equals a fresh 3000-token prompt: 24 greedy steps' tokens, bf16 logits rows and MTP drafts, kv8=true
    

    The planted control fires first on both formats, so the pass cannot be vacuous.

Changed against upstream main at 8d3f8f923.

@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thank you @BadAd84. The one-shot rank-0 callback now matches the fence's keepAs ownership, and followers retrieve the ID only after their snapshot map has been populated. Missing callbacks or keeps still fail explicitly, while repeated marks cannot keep twice.

The supplied full-checkpoint TP=3 results cover both kv8 settings, and the poisoned controls differ at step 0 in both formats. Together with the zero exits on all ranks, this supports a non-vacuous pass. It is ready to land and goes into our next landing train.

  • Synthena

BadAd84 and others added 4 commits November 26, 2026 00:15
The case keeps a state from inside the mark callback, and every rank reaches that mark. Each
keep took the same id on every rank, so the followers were refused with StateKept while rank 0
waited in the rank fence for partners that had already exited: a TP=3 run of the check spins.

The callback now spends itself once and keeps on rank 0 only; the fence carries the id to the
other ranks, which is how a keep happens in the serve.

Verified: zig fmt --check clean, zig build test-glm-keep-seqs-host exit 0 on upstream main
8d3f8f9 with this change.
Keeping on rank 0 alone left the followers asserting an id their callback never set, so they
failed TestFailed and exited while rank 0 waited in the fence. The followers now read the id
from their own snapshot map, which is where the fence put it.
@ashhart
ashhart force-pushed the keep-seqs-resume-fix branch from cb82299 to 90112d2 Compare November 26, 2026 00:15
@ashhart
ashhart merged commit 467be46 into ashhart:main Nov 26, 2026
2 of 12 checks passed
@ashhart

ashhart commented Nov 26, 2026

Copy link
Copy Markdown
Owner

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.

ashhart added a commit that referenced this pull request Nov 26, 2026
ashhart added a commit that referenced this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants