Repository navigation
Preserve completed CUDA prefill across cancellation and retry - #1228
Closed
Sapphire-Rapids wants to merge 3 commits into
Closed
Sapphire-Rapids wants to merge 3 commits into
Sapphire-Rapids wants to merge 3 commits into
Conversation
Keep completed resumable prefixes before cancellation releases model state, including cancellation between host-managed chunks. Reuse the existing snapshot implementations and cache budget. Refs ashhart#1225.
Owner
|
Landed on main as 7b16445 and 9fa9248, with a maintainer child (87272aa) that keeps main's early Qwen cancel check and saves the prefix before returning Cancelled, thank you @Sapphire-Rapids. We dropped the compressed receipt files from the tree. On a GB10 with Qwen3.8-27B, a request cancelled 2 s into a 32k prompt kept 1,792 tokens, and its retry's reply equalled an uncancelled run's on a fresh server. The base build kept nothing, and prefill and tokens were otherwise unchanged against main (8k and 32k within 0.2%). It will be in the next release. - Synthema, Ash's AI Assistant. |
ashhart
added a commit
that referenced
this pull request
Oct 24, 2026
Keep #1078's between-chunk cancellation point and save its completed prefix before returning Cancelled, with one check on an uncancelled path. Preserve main's recorder score forwarding when adding the optional cancellation hook. Add whole and stepped fake-lane controls proving unchanged uncancelled work. Carry Sapphire-Rapids' two code records with their authors, dates and messages. Retain only host-free opening README prose from the third record, attributed as historical contributor observations. Omit its raw receipt artifacts and artifact-dependent instructions; integrated GPU qualification remains owed. Fixes #1225. Refs #1228.
ashhart
added a commit
that referenced
this pull request
Oct 24, 2026
This was referenced Oct 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Cancelled native CUDA prefill currently discards completed work. This change saves the latest complete, resumable prefix through the existing prompt cache before releasing model state, so an identical retry can continue and repeated cancellations can accumulate progress. Fixes #1225.
The shared helper preserves cache identity, budget and snapshot ownership. An optional callback covers cancellation between host-managed prefill steps and is forwarded by the CUDA device wrapper and recorder. Flash Next, Kolibri, Qwen3.5 dense/MoE, Nemotron and GLM reuse their existing snapshots; GLM publishes the cancellation snapshot to all ranks before rebinding. Kernels, arithmetic, precision and cache budgets are unchanged.
Receipt
Reproduction commands, exact generated requests/token arrays, original result JSON, source hashes and host logs.
3f2ceb85; validated source6ad99c5f, with all 16 changed source-file hashes retained. Zig 0.17.0, one NVIDIA GB10/SM121, Ubuntu 24.04.5/aarch64, driver 580.173.02, CUDA 13.3.1.008. Checkpointmlx-community/Qwen3.5-2B-MLX-4bitat93760be4f1f69842a46bc13dbdc0f19e291392a3, affine 4-bit/group 64, BF16 checkpoint dtype. Native Zig/CUDA inference; installed PyTorch version is recorded, and MLX is not used. Build logs reportsafe nativedespite the requested-Doptimize=ReleaseFastflag.draft: falseretry and two concurrent default retries. These later retries are warm. Positive drafter activity was not recorded.bench_openai.pypanel was not run.SUMMARYis claimed.Integration notes
This remains a draft pending the missing gates and coordination with overlapping work. It applies cleanly to current
main(3f2ceb85). Complete file lists for oversized open PRs were fetched separately to supplement ATC's file-list limit; merge-tree comparisons were checked against both unmodified main and this candidate.4808c94b) also adds Qwen's between-chunk cancellation check. When combining, retain its early check together with this PR's snapshot save before returningCancelled.34560aa8) splits Qwen prefill into host-managed steps. Integration must save the prefix while itsFillstate is still alive and providecancel_prefillfor between-step cancellation. A textual merge alone is insufficient; rerun the cancellation receipt on the combined code.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. Output comparisons pass on the tested checkpoint; positive drafter activity and other affected checkpoints remain unqualified.SUMMARY: not applicable; no GPU kernels change.