Skip to content

GLM CUDA: keep completed shared-cache prefixes on prefill cancellation - #4694

Merged
ashhart merged 2 commits into
ashhart:mainfrom
MaverickKB:codex/glm-cuda-keep-cancelled-prefix
Nov 24, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
MaverickKB:codex/glm-cuda-keep-cancelled-prefix

Conversation

@MaverickKB

Copy link
Copy Markdown
Contributor

What this changes

When a client cancels a GLM CUDA request between prefill chunks, the lane can return before saving the last completed chunk. In shared-cache mode the family owns the checkpoint callback, so the stream's generic reuse hook can legitimately be empty. A retry then reads the same prefix again.

Resolve the callback through the lane's existing cache selection and keep the interruption callback available even when there are no scheduled checkpoints left. The existing completed-row guard still applies. The regression sends cancellation through the public backend callback, retries with a fresh stream, and checks both the restored position and the saved model state.

Checks on this head

Case Main with the new tests This change
Cancel at row 2,048 before a checkpoint at 6,144 No checkpoint saved Retry restored row 2,048 and both state words
Cancel at row 2,048 with no remaining checkpoints No checkpoint saved Retry restored row 2,048 and both state words
  • Zig 0.17.0, native arm64 host. On main, zig build -j1 test-glm-image-cache-host --summary all passed three existing tests and failed both new tests. Changing only the dispatch condition on v1.3.4 fixed the first case but still failed the second.
  • On the branch, zig build -j2 test-glm-image-cache-host test-glm-prompts-host --summary all passed all 13 tests. The fixture uses the real shared radix store, lane and interruption callback, with host doubles for CUDA copies and rank communication.
  • zig fmt --check on the three changed files and git diff --check passed. python3 tools/zig/lean_check.py reported 165 findings on both base and head, with byte-identical reports.
  • Hosted checks start when the PR opens.

Serving evidence and limits

On two GB10 GPUs running a GLM-5.3-Flash EXL3 release-based deployment, retrying a 21,273-token request after cancellation restored zero tokens before the fix and 10,240 completed tokens with the fix. Both retries returned the expected answer. This is corroborating deployment evidence. The controlled base-versus-head comparison is the host test above.

The change reaches the GLM CUDA lane. It adds no switch, allocation policy, decode branch or kernel. The full GPU qualification suite, other chips and token-level drafted/plain and concurrent/solo equivalence were not run on this exact main-based head. The PR makes no claim about uninterrupted decode speed.

  • One behavior and an independent base.
  • Both new regression cases fail on main and pass here without a GPU.
  • Public diff and commit metadata checked.

@ashhart
ashhart force-pushed the codex/glm-cuda-keep-cancelled-prefix branch from de23d07 to 4c4a78b Compare November 24, 2026 03:22
@ashhart
ashhart merged commit 3993128 into ashhart:main Nov 24, 2026
1 check failed
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you @MaverickKB. 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.

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