Repository navigation
spark-model: DFlash2 step cuts — async batched propose + opt-in GDN deferred commit (#58) - #127
Merged
Merged
Conversation
…rains per sequence (#58) Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…#58) Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ws (#58) Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…TLAS_DFLASH_DRAFTER_CUBLAS) Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
plan_ctx_chunks is first-fit: a chunk that overflows the row cap goes serial and later chunks that still fit keep packing, so [10, 10, 4] at cap 16 is [Some(0), None, Some(10)] — the test expected the planner to stop at the first overflow. The structural pin counted its own needle literals via include_str!; it now counts only the production half. Both failed on reiner (job 610 unit step); 105/105 dflash_head tests pass. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…#58) 0ebedeb turned the kernel body into df2_selector_body for the new batched entry but never re-added the extern "C" per-sequence symbol, so the audited load-time lookup resolved to handle 0 and every async-stack serve refused to boot (reiner job 610, all B arms). Re-export it as a thin wrapper over the shared body in the gb10 and strix-hip sources, and pin both exported entry points in batched_selector_is_one_launch_with_fallback (fails on 0ebedeb, passes now). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…#58) [seq][gamma][width] parsed as intra-doc links and failed the rustdoc CI job; quote it as code. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…OMMIT)
wyN verify (K=5..16, serial and batched) writes K-1 full h_state
snapshots + the final H per (seq, v-head, layer) — ~64 KB each on
qwen3.8-27b — but every accept path consumes only intermediates[a-1].
Under the opt-in lever the new gated_delta_rule_wy{K}_defer entries
run the identical gated_delta_rule_wyn_impl arithmetic with all state
stores removed (h_state stays H0), and gated_delta_rule_commit replays
the accepted prefix 0..a-1 through the same impl body, storing only
H_{a-1} — bit-identical to intermediates[a-1]/final H.
Conv outputs/gates are staged into per-slot commit buffers at verify
time (the shared ctx.buffers scratch is reused by the next forward).
Accept paths (commit_accepted_prefix, rollback_ssm_states, batched
DFlash) launch the commit kernel whenever a layer's
gdn_commit_pending flag is set — full accept is no longer a no-op for
deferred layers, since h_state was never written. Conv intermediates
are unchanged; wy2/3/4/wy17 and the f16/resident variants are
untouched; the strix-hip wyN port predates the table form so the
lever stays inert there (handles resolve to 0).
Lever off is byte-identical to main.
Test: cargo test -p spark-model --release --features cuda
gdn_deferred_commit -- --ignored (K in {5,8,9,12,16}, every
a in 1..=K, outputs + committed state vs storing oracle)
Devin-Review-Token: gdn-deferred-commit
cd02041 could not reach a GPU: - ATLAS_WYN_INSTANTIATE still called gated_delta_rule_wyn_impl<K>(...) after the impl gained a MODE parameter and an accepted_count argument (nvcc error). The legacy wy{K} entries now call impl<K, 0> with an unused accepted_count; their extern signature is unchanged from main. - ATLAS_WYN_DEFER_INSTANTIATE was invoked for K=5..16 but never defined. It now emits gated_delta_rule_wy{K}_defer with the same 18-param signature (same gdn_decode_wyn launcher) calling impl<K, 1>. - then_some(self.gdn_wyn_defer_k[k - 5]) evaluated the index eagerly: an underflow panic for k <= 4 (the existing r4/r7 dispatch tests hit it) and an out-of-bounds index at k = 17. Both sites now branch first. - Under defer a full accept still runs commit_accepted_prefix, and the deferred branch restored conv state from conv_intermediate(k - 1), a slot the fused conv path never writes. Skip the conv restore on a full accept; the verify's final conv state is already canonical. gdn_wyn_launcher_arg_count_matches_kernel_param_count pins the wy{K}, wy{K}_defer and commit entries against their launchers (18/18/14); it fails on cd02041 because the _defer entry does not exist. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… in the captured forward (#58) Reiner job 621: with ATLAS_GDN_DEFERRED_COMMIT=1 greedy output diverged after ~20 tokens (json "population" 1250000 -> 2847000, code 256 -> 181 tokens) although the kernel oracle passes. The verify forward is graph- captured (verify_d logs "Captured CUDA graph for K=gamma verify"), and the layer set gdn_commit_pending and lazily allocated its staging buffers as host code inside that forward. On replay the graph still ran the MODE-1 _defer kernel (no state stores) while the flag stayed false, so the accept path restored h_state from intermediates MODE 1 never wrote. - mark_gdn_deferred_commit assigns the flag at every decode_verify* entry, on the capture pass and on every replay, from TransformerLayer::gdn_deferred_wyn (the wyN arm's own gates) plus the shared SsmLayerState::h_inter_pool_layout precondition. - Staging lives in lever-gated SsmStatePool pools, bound at slot bind and rebind like h_state; the forward only issues the capturable copies and fails fast if the staging is missing. - decode_verify_batched checks that it has one depth per sequence. gdn_commit_pending_is_set_at_dispatch_not_in_the_layer fails on 0f5ec00; cargo test -p spark-model --lib: 857 passed. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 of 8 tasks
Contributor
Author
|
Both halves on one binary: passes (reiner job 625zzz1, 4c13a0a). Setup: job-240 DFlash2 serve,
Checks:
Result: at 16 sequences the step drops from ~617 ms to ~427 ms (−31 %). C16 on C was 85.9 / 89.0 against 73.5 required; lever off (B) was 77.3 / 82.4. Status: ready for the GB10 train's gates. The deferred-commit lever stays opt-in until ST-995 runs with it on. |
Contributor
Author
|
Added to the GB10/common train #132 ( |
This was referenced Sep 28, 2026
AzeezIsh
added a commit
that referenced
this pull request
Sep 29, 2026
One conflict, in dflash_head.rs's module list: #104 adds `mod carry;` and #127 adds `mod batched_ctx;`. Keep both. The two paths compose. #127's batched propose records ctx chunks from the same `committed = ctx_committed.min(ctx_len)` watermark as the serial path, so #104's carried prefix is skipped by both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Sep 29, 2026
AzeezIsh
added a commit
that referenced
this pull request
Sep 29, 2026
#127 added 13 lookups: gated_delta_rule_wy5..16_defer and gated_delta_rule_commit. Their kernels exist only in kernels/gb10/common/gated_delta_rule_wyn.cu. strix-hip ships a gated_delta_rule_wyn module without them, so plain try_kernel resolved all 13 to handle 0, and the boot kernel gate refused qwen3.8-27b on gfx1151: "Error: 13 unresolved kernel lookup(s) for (qwen3.8-27b, gfx1151, nvfp4)" (winbox, 56b3d6a). Use try_kernel_gated(!cfg!(atlas_hip), ...), the same fix as #101's batch8 lookup. gdn_defer_active already requires both handles to be non-zero, so HIP keeps the eager commit. GB10 behaviour is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Sep 29, 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.
Summary
Cuts the DFlash2 batched-propose step (#58) without touching verify or outputs. At 16 sequences, propose was 249 ms of a 617 ms step on main (reiner job 596's profile: 48.5 % of CUDA API time in
cuStreamSynchronize).Commits:
cuStreamSynchronizeper sequence). They are stream-ordered async copies from pinned carve-outs, and the overflow path falls back to the old sync copy.ctx_kv_projectover Σn_i rows per step instead of one per sequence. The first-fit planner keeps the per-sequence GEMV arm wherever it would have run, so rows stay byte-identical.dflash2_candidate_selector_batchedlaunch (grid = n sequences) instead of n serial single-CTA launches (4.7 ms each), plus drafter LM-head GEMV waves for more than 32 rows.ATLAS_DFLASH_DRAFTER_CUBLAS=1(cuBLASLt for drafter BF16 GEMMs at m>=32). Default off, because cuBLAS algorithm choice can move draft numerics and therefore acceptance, though never outputs.extern "C" dflash2_candidate_selectorsymbol, so the kernel audit refused boot in job 610.Evidence (reiner job 611y, 2026-09-27)
Setup: DFlash2 γ=8, bs16, util 0.70, bf16 KV, thinking off,
spark benchmark run concurrency-sweepC 1/4/8/16, ISL 512, OSL 320. A = main 10d4ec7, B = this branch @ da95e05, interleaved A/B/A/B.Aggregate tok/s, C1 / C4 / C8 / C16:
Step times (server-side means over ~70 steps per arm) are identical across reps:
Caveat on the client aggregate: it is noisy at C8/C16 because mean acceptance moves 3.03–3.19 between runs of the same binary (A1 vs A2). Main's C16 has read 61.7–74.2 across six runs today, so the step-time drop is the primary evidence. The C16 aggregate on this branch was 75.7 and 75.8, above the 73.5 floor. Main was below it in 5 of 6 runs; that is being bisected separately in job 611zz.
Parity:
ATLAS_DFLASH_BATCH_PARITY=1: backbone parity 0/40960 mismatched, max_abs_diff 0.dflash_headunit tests pass on reiner.Test plan
cargo test -p spark-model --lib dflash_head::105/105 (reiner and macOS).Generated with Devin
Also in this PR: opt-in GDN deferred commit (folded in from #128)
ATLAS_GDN_DEFERRED_COMMIT=1targets the wyN GDN verify (K=5..16), the top kernel in the DFlash2 C=16 profile. The lever is off by default, and lever-off behaves byte-identically to main.gated_delta_rule_wy{K}_deferruns the same arithmetic but stores nothing: no per-token snapshots and no final H.gated_delta_rule_commitreplays the accepted prefix from H0 and stores only H_{a-1}.decode_verify*dispatch entry, outside graph capture. Staging lives in slot-bound pool buffers, so captured verify graphs replay correctly.Commits (patch-identical to #128's, per
git range-diff):_defermacro,impl<K>arity, an eagerthen_someindex, and a full-accept conv restore.Evidence (reiner job 625zzz, lever off vs on, interleaved ×2):
gdn_deferred_commit_byte_identicalpasses.Not yet measured: the two halves together on one binary. That's the next reiner A/B.