Repository navigation
spark-model: carry remaining DFlash2 batched-propose fixes to main - #64
Merged
Merged
Conversation
verify_dflash_batch_step consulted only mtp_propose_batch_min, so a generic DFlash head (propose_batch_max = 1 — the Lightning Bxgamma seam is the served-gamma=4 product contract) got called every step, errored on the contract gate, and paid an error round-trip to reach the serial fallback. Gate on batch_cap >= batch_min the same way verify_k4_batch_step already does, and widen the else arm to propose every pending sequence serially — it previously handled only pending.first(), which would have stranded the rest once the batch call was skipped. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> (cherry picked from commit 2e678d8)
The batched DFlash commit loop exposed a latent stream-ordering bug: preserve/pack/restore_dflash_save_front honored the scheduler's literal `0` stream arg, which lands on the CUDA legacy default stream, while the capture that writes the owner regions and the commit_ctx that reads the front both run on the model's NON_BLOCKING default stream. Stream 0 does not serialize with a non-blocking stream, so commit_ctx could read the front before the pack landed — handing each non-owner-0 sequence another sequence's (or stale) hidden stack, poisoning ctx_hidden_acc. Acceptance decayed with batch width and over time exactly as that race predicts; owner-slot-0 rows stayed healthy because region 0 IS the front. The path was unreachable before the envelope admitted k=gamma rows, so the helpers were never exercised live. Fix model-side per the file's convention (commit_ctx, save_hidden_for_mtp, stash_verify_hidden_rows all ignore the boundary arg and use self.gpu.default_stream()): the copies must be ordered with the capture writer and commit_ctx reader, which are always on the default stream. Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> (cherry picked from commit 34e427b)
propose_batch ran the Lightning Bxgamma seam (owners collection, DsparkBatchInput::validate, packed uploads, staged backbone) before every dispatch — and its gamma == LIGHTNING_SERVED_GAMMA (4) contract rejected generic gamma=8 heads outright, so the multi-lane tail was unreachable for non-Lightning models even with ATLAS_DFLASH_PROPOSE_LANES > 1. Generic DFlash never consumes the seam's staged result (the native rows are only authoritative under native_batch_authoritative / batch_parity), so skip the seam entirely for generic heads and dispatch straight to the per-lane enqueue/collect path. propose_batch_max now reports batch_capacity when lane_count() > 1, letting the scheduler's cap >= min gate admit batched calls; the single-lane serial arm is unchanged. propose_on_lanes is the extracted tail, verbatim. (cherry picked from commit 14b3cab)
Two multi-lane propose fixes exposed by the lanes=4 sweep: - forward_block(defer_readback=true) returns Vec::new(), so the draft cap in propose_drafts_on_lane ran on an empty vec and the deferred readback handed verify all γ rows uncapped — an 8-draft / 9-token verify window vs pools sized for K=8 (7 h / 8 conv intermediates). decode_verify_dflash refused every multi-lane seq. read_deferred_drafts now takes the scheduler-K cap; last_num_drafted is set from the collected drafts. - Piecewise graph capture on a lane stream (lane 0 IS the default stream) leaks capture mode when any op between begin/end fails — every subsequent unrelated-stream op then fails CAPTURE_ISOLATED and every sync on the capturing stream fails 900. Suppress propose graphs under defer_readback; multi-lane stays eager until per-lane capture ownership is proven safe. (cherry picked from commit 5944227)
can_batch_verify_dispatch self-gated on the MTP ladder shape (ks in 2..=4) and rejected DFlash outright (dflash_hidden_save.is_none()), so every DFlash chunk silently fell back to per-sequence verify — verify cost scaled linearly in batch width and the concurrency sweep stayed flat (~25 tok/s at C=1/4/8/16, TPOT 35->538ms). The selector fix could not help; the batched path was never entered. - verify_batch_ks_ok: shared row-shape predicate for the gate and the dispatch ensure! — ladder 2..=4 on the non-DFlash envelope, k <= dflash_hidden_save_rows (gamma) with n <= dflash_hidden_save_nseq on the DFlash envelope. VERIFY_ROW_CAP=96 still applies, so gamma=8 chunks cap at 12 seqs via mtp_dcut::chunk_ranges. - decode_verify_batched_dispatch now calls try_dflash_capture_batched_at per capture layer, keyed on each sequence's immutable dspark owner slot (never batch position) so the deferred batched propose reads the accepted row's hiddens. - CUDA-graph capture is vetoed on the DFlash lane: capture destinations are owner-slot regions, which are not a function of the (ssm_slot, k) graph key and survive slot reuse — a replayed graph could write a dead generation's regions. Eager batched forward still collapses the per-seq weight reads; owner-aware replay is follow-up. WY-table upload still only spans k in 2..=4, so k=8 GDN layers take the per-seq WY fallback inside decode_verify_multi; weight-bearing ops stay batched. Widening the table is a measured follow-up. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> (cherry picked from commit b59d6b7)
This was referenced Sep 25, 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
Carries the five DFlash2 commits that shipped on
c8b88c6(the integration lane) but never reached main — the last code delta between the lane and main in the DFlash path:2e678d887— spark-server respects the head's batched-propose envelope for DFlash34e427b3c— order DFlash front-region copies on the default stream14b3cabe7— enable multi-lane batched propose for generic DFlash (ATLAS_DFLASH_PROPOSE_LANES)594422770— cap deferred DFlash drafts + suppress lane-graph captureb59d6b7e4— admit DFlash gamma-shaped rows to batched verifyThese are what make
ATLAS_DFLASH_PROPOSE_LANES(already plumbed inproduct_policy.rs) actually do something on main, and restore the lane's batched-verify envelope after the #52/#60 subset merge.Test plan
cargo check -p spark-model -p spark-serverclean