Skip to content

dflash: warm-context drafting for the DFlash2 draft head (ATLAS_DFLASH_WARM_CTX, default legacy; ported from Enntity) - #255

Closed
AzeezIsh wants to merge 2 commits into
stack/qsa-aux-kv-budgetfrom
stack/dflash-warm-ctx
Closed

AzeezIsh wants to merge 2 commits into
stack/qsa-aux-kv-budgetfrom
stack/dflash-warm-ctx

Conversation

@AzeezIsh

@AzeezIsh AzeezIsh commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Replaces #244. GitHub closed #244 automatically during a restack: its branch briefly pointed at a commit its base already contained. It's the same branch (stack/dflash-warm-ctx), now corrected; the history and receipts are on #244.

Replaces #234. GitHub closed #234 automatically when a restack force-pushed its base branch, and once the head was force-pushed afterwards it couldn't be reopened. The branch is the same (stack/dflash-warm-ctx); #234 has the history and receipts.

Stack: … ← #232 ← #233 ← this.

Summary

  • Ports Enntity's DFlash warm-context series (AGPL-3.0, 5573f4d5, 43a5b9a6, cfa56639, d3953211) with credit. ATLAS_DFLASH_WARM_CTX=legacy|exact|seed|restore controls how the DFlash2 draft head's context window is captured and restored across prompt-cache turns (WarmCtxStore LRU slab, capture plan, seed/restore).
  • Default legacy = the old capture math, byte for byte. GLM DFlash2 only; the Qwen MTP path is untouched.

Test plan (vs parent #233)

Tracking: #220.

Generated with Devin

…restore

Port of Enntity/atlas 5573f4d + 43a5b9a + cfa5663 + d395321
(AGPL-3.0-only). GLM DFlash2 only; the Qwen/MTP path is untouched.

ATLAS_DFLASH_WARM_CTX=legacy|exact|seed|restore (default legacy,
byte-for-byte the old capture math):
- exact: every prefill pass anchors at the prompt end (slot i = position
  window_start + i) — fixes the two chunk-boundary placement defects.
- seed: a warm restore starts the window at ctx_floor instead of filling
  zero rows under the skip point.
- restore: rows under the skip point come back from a content-addressed
  device slab (one slab of ATLAS_DFLASH_WARM_CTX_SLOTS windows on rank 0,
  SHA-256 keyed, LRU).

Hooks: DflashProposerState warm_ctx/ctx_floor/ctx_run/ctx_store fields,
impl_b3_dflash capture_plan, dflash_warm_begin after the prefix lookup,
dflash_warm_save at the prompt leaf, WarmCtxStore reserved before KV
sizing in build_model, store_slots_from_env checked on every rank when
the restore arm is on.

scripts/dflash_warm_ctx_check.py drives a served model for the pair
check (warm == cold window oracle). GPU tests compiled, #[ignore].
@AzeezIsh

AzeezIsh commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Included in GB10 integration train #305 on main 8c2b672: ported onto main, because its stack base landed via #282 (see #305 for the resolution notes). The sparky gate (job 68b) builds #305's exact head and runs tests, three model controls, agentic-50, BFCL ST-995 and error counts. The results will be posted on #305 and here. This PR will be closed in favour of #305 once it lands.

@AzeezIsh

AzeezIsh commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Not landing yet: #255's own GPU test fails when ported onto main.
In train #305, 5c15afb91 was cherry-picked onto main 8c2b672. #282 already landed the stack/qsa-aux-kv-budget base.

  • cargo test --release -p spark-model --lib warm_ctx: 15 passed, 2 ignored.
  • With --include-ignored, the two GPU tests give:
    • warm_ctx_gpu_tests::the_store_round_trips_glm_windows_on_the_device: ok;
    • warm_ctx_gpu_tests::a_warm_turn_window_matches_its_cold_prefill_on_the_device: FAILED (sparky GB10; log ~/code/perf/train1101/, job 68e).
  • Hypothesis, not verified: the warm-turn path relies on the stack's CTX_CARRY layer. On main, DraftProposer::adopt_dflash_ctx / acquire_ctx_acc exist only as no-op trait defaults, and the cherry-pick also had to bring along write-only ctx_prefill_origin/base / ctx_acc_rows fields. A local port/dflash2-ctx-carry-main branch exists but has no PR.
  • Default serving is unaffected (ATLAS_DFLASH_WARM_CTX defaults to legacy). Train controls, BFCL and agentic were identical to main.
  • Next step for this PR: land the CTX_CARRY port first, then re-run these GPU tests. There's no DFlash2 checkpoint on sparky to run an end-to-end check.

@AzeezIsh

AzeezIsh commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up on the dependency hypothesis. It's now supported by history.

Suggested path:

  1. Restore the CTX_CARRY impls on main as their own PR. Diff b9a7eda^ vs b9a7eda for layers/dflash_head*.
  2. Re-run warm_ctx_gpu_tests with --include-ignored on GB10 with this PR on top.
  3. Land this PR if both GPU tests pass.

sparky has no DFlash2 checkpoint, so the GPU tests are the only coverage available there.

AzeezIsh added a commit that referenced this pull request Nov 2, 2026
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@AzeezIsh

AzeezIsh commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Closing: this PR's content is on main. Its head 09a823056 is an ancestor of main. It landed through d56fa8e, "Merge upstream stack/glm-video (#242 <- #253 <- #254 <- #255 <- #256) onto main", then de50673 / #309. GitHub kept the PR open only because its base is the stack branch stack/qsa-aux-kv-budget, not main.

My earlier comment about the CTX_CARRY dependency still applies, now to main: warm_ctx_gpu_tests is on main, and the concrete adopt_dflash_ctx / acquire_ctx_acc impls are not. A sparky GB10 run of the warm-context tests (--include-ignored) on a clean main f506e92 build is queued (job 77b). I'll post its result here, and open a restore PR if the GPU tests fail.

@AzeezIsh AzeezIsh closed this Nov 2, 2026
@AzeezIsh

AzeezIsh commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

GPU test result on main (sparky GB10, clean main f506e92 build, --include-ignored):

  • Run together (job 79e): a_warm_turn_window_matches_its_cold_prefill_on_the_device passes. the_store_round_trips_glm_windows_on_the_device fails with CUDA backend: cuCtxGetCurrent failed: status 0, ctx 0x0.
  • Each run alone (job 80c, full test path with --exact): both pass, 1/1 each.

So the warm-context code on main works on the device. The failure is a test-isolation issue: the GLM store test assumes a CUDA context is current on its thread, which holds only when it runs first. Nothing here needs the CTX_CARRY impls I flagged earlier, so I'm withdrawing that hypothesis for these tests. The fix belongs in the test, which should bind or create its own context.

vcruz305 pushed a commit to vcruz305/atlas that referenced this pull request Nov 11, 2026
…-Inf#256)

Port of Atlas-Inf#256 (Enntity/atlas f3f3876 via 5497364, plus 8a8a959 from
Atlas-Inf#295) onto main's Atlas-Inf#286 video path. Atlas-Inf#256's stack base already landed
through Atlas-Inf#282, and the DFlash warm-ctx port from the same stack (Atlas-Inf#255) is
not included. Every video file here is byte-identical to the version
gated in train Atlas-Inf#305.

- ensure_decoder is the single source for the ffmpeg enabled/available
  check, in video_decode_ffmpeg/probe.rs (pub(super)); decode_with_plan
  and frames.rs call it.
- The moov/faststart decode tests use the enabled() policy; on a host
  with ffmpeg they fail on main under FfmpegPolicy::default().
- The GLM reference path pads a single sampled frame into a temporal
  pair. Qwen's generic path is unchanged.
- The generic-path GLM single-frame refusal test is dropped, superseded
  by the reference pad test (the generic GLM branches are now unreachable
  behind the is_glm5_next early return; follow-up).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.

1 participant