Skip to content

spark-model+server: DFlash2 batched verify/propose for generic heads (γ-shaped rows, stream ordering, multi-lane) - #52

Merged
AzeezIsh merged 3 commits into
integration/nvidia-lane-2026-09-20from
fix/dflash2-batched-verify-gamma
Sep 23, 2026
Merged

AzeezIsh merged 3 commits into
integration/nvidia-lane-2026-09-20from
fix/dflash2-batched-verify-gamma

Conversation

@AzeezIsh

Copy link
Copy Markdown
Contributor

Summary

DFlash2 batched-concurrency support for generic (non-Lightning) heads — the four-commit stack:

  • 5da27757a spark-model: admit DFlash gamma-shaped rows to batched verify — extends can_batch_verify beyond the MTP 2..=4 ladder to k = γ+1 rows (bounded by dflash_hidden_save geometry, R ≤ 96 chunk cap), wires owner-slot-indexed try_dflash_capture_batched_at into the batched forward, and vetoes CUDA-graph capture on this lane (owner-region destinations aren't covered by the (ssm_slot, k) graph key).
  • 1d9f87b62 spark-server: respect the head's batched-propose envelope for DFlash — the scheduler now consults propose_batch_max before calling propose_batch (generic DFlash declares max=1 → clean serial fallback over ALL pending seqs instead of a γ-contract error + pending.first() only).
  • 5f01b98fb spark-model: order DFlash front-region copies on the default stream — root cause of the acceptance collapse: preserve/pack/restore_dflash_save_* used the caller's literal stream 0 (legacy stream) while capture and commit_ctx run on the model's CU_STREAM_NON_BLOCKING default stream — commit_ctx raced the pack and accumulated stale/foreign hidden stacks into ctx_hidden_acc. Now uses self.gpu.default_stream() like every sibling helper.
  • 94f09a2fb spark-model: enable multi-lane batched propose for generic DFlash — generic heads skip the Lightning B×γ seam (whose γ==4 contract rejected γ=8 anyway, and whose output they'd discard) and dispatch to the existing per-lane overlapped propose (ATLAS_DFLASH_PROPOSE_LANES); propose_batch_max reports batch_capacity when lane_count() > 1.

GB10 validation (nvidia/Qwen3.8-27B-NVFP4 + incoai/Qwen3.8-27B-DFlash2, γ=8, Option B, bs16, util 0.70)

Concurrency sweep, aggregate tok/s:

C1 C4 C8 C16
198 — 3b4f7c2e0 (batched verify unreachable) 25.1 25.0 23.7 24.1
206 — 5f01b98fb (envelope + stream fix) 25.3 33.4 42.9 44.4
208 — 576441191 (merge head) 25.2 33.6 40.2 42.1

mean_na flat ~2.6-3.2 across batch widths post-fix (was 0.35 collapsed at n=12 before the stream fix). Multi-lane propose (94f09a2fb, lanes=4) validation running as jobs 210-212 on reiner — expected to collapse the ~647ms serial propose at n=12.

Known follow-ups

  • gdn_decode_wy8 kernel needed for the batched WY fast path at k=8 (today: correct per-seq fallback).
  • Owner-in-key CUDA-graph replay for batched verify (currently vetoed → eager forward).
  • The dflash2_selector_parity test's bf16 grid has too few distinct values at n=4096 (pre-existing on the lane, identical at 3b4f7c2e0).

Generated with Devin

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.
Wraps serve-amd.sh with the certified gamma=8 Option-B profile baked in
(util 0.80, seq 8192, prefill 2048, kv bf16, lm_head nvfp4, batch=1,
thinking off) so the handoff is a single command. All knobs stay
env-overridable.
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.
@AzeezIsh
AzeezIsh merged commit dcf917d into integration/nvidia-lane-2026-09-20 Sep 23, 2026
21 of 22 checks passed
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Fixed — scripts/strix-windows/win_serve_dflash2.ps1 is now on this branch (56bb5b210). It was previously only on integration/nvidia-lane-2026-09-20; cherry-picked here so the PR carries both launchers:

powershell -ExecutionPolicy Bypass -File scripts\strix-windows\first_run.ps1 -Phase build
powershell -ExecutionPolicy Bypass -File scripts\strix-windows\win_serve_dflash2.ps1

The script is the standalone DFlash2 γ=8 Option-B serve (batch=1, util 0.80, seq 8192, kv/lm_head bf16) — binary discovery off ATLAS_REPO/ATLAS_BIN, readiness wait, boot-evidence audit, one greedy smoke request.

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

For anyone landing here from elderorb's test report: win_serve_dflash2.ps1 does exist — the merged PR's file view is frozen at the merge-time head de068ddf, so the two commits pushed after merge aren't visible in the PR UI.

Where to get it:

Verified live on winbox: first_run.ps1 -Phase build → this script → server up, 0 unresolved kernels, γ=4 decode 28.5 tok/s server-attested (mean_na 2.68).

On the reported OOM: the hand-port's shape differs from the tested profile — the script pins --max-seq-len 8192 (not 64K), --ssm-cache-slots 20, --gpu-memory-utilization 0.80, batch 1, and already passes --no-fast-load. At 64K the KV budget alone exceeds what was free; status 2 during model construction with 47 GB free is consistent with that. The recipe is built to fit — please retest with the shipped script and report back.

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