Skip to content

perf(ds4): extend sparse prefill scheduling to 10K - #684

Draft
dusterbloom wants to merge 12 commits into
Luce-Org:mainfrom
dusterbloom:perf/ds4-sparse-prefill-wide
Draft

perf(ds4): extend sparse prefill scheduling to 10K#684
dusterbloom wants to merge 12 commits into
Luce-Org:mainfrom
dusterbloom:perf/ds4-sparse-prefill-wide

Conversation

@dusterbloom

@dusterbloom dusterbloom commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • extend DS4 sparse-prefill scheduling from four to five independent
    2,048-token numerical bands, admitting one physical frontier up to 10,240
    tokens
  • derive long ratio-4 causal visibility in the HIP attention path instead of
    retaining and uploading its quadratic score mask
  • pass authoritative long-prefill top-k rows directly, keep selected
    raw/compressed KV transport in F16, and stream each selected latent row once
    across sixteen wave32 heads
  • preserve native top-6 routing, selected-row order, per-row reduction order,
    independent 2K attention bands, and chronological state commit
  • preserve mrciffa's authorship on the three extracted streaming-attention
    commits from perf(ds4): default mixed ROCmFP MMQ prefill on gfx1151 #683

Exact prefill, dense-flash prefill, decode, non-ratio-4 attention, and unsupported
backend shapes retain their existing paths. No runtime flag, memory guard,
cache, worktree, or private BWS policy was added.

Production workflow

Strix Halo gfx1151, 98.3 GB ROCmFPX MIX artifact, target-only sparse
prefill, native top-6 routing, fused autoregressive decode, Q4_0 K/V cache,
caches off, 9,133-token SWE-bench-shaped prompt, and up to 128 generated
tokens:

Build Physical prefill Warm prefill median Warm decode median Matched 128-token warm wall
Previous PR head 619413c 8,192 + 941 231.365 tok/s 19.005 tok/s 46.319 s
Final head d6471f1 one 9,133-token step 252.175 tok/s 19.220 tok/s 42.797 s
Change tail removed +8.99% +1.13% -7.60%

The final two warm prefill samples were 252.09 and 252.26 tok/s. The matched
128-output-token warm sample saved 3.522 seconds. Decode code is unchanged;
its small movement is reported, not claimed as a decode optimization. Sparse
replay produced 47 tokens in one warm sample and 128 in the other, so whole
wall is compared only between matched 128-token samples.

The earlier clean-head 7,680-token receipt remains 254.921 tok/s, nominally
0.335% above the cited 254.07 tok/s Vulkan result at the same token count. The
prompts, artifacts, and quality protocols are not proven identical, so this PR
does not claim a cross-runtime record from that comparison.

Memory and execution shape

The ratio-4 analytic path removes retained masks from 21 attention layers:

  • 6.562 GiB at 8,192 tokens
  • 8.157 GiB at 9,133 tokens

That memory headroom permits the five-band frontier without a runtime memory
guard. The four full-vocabulary quality processes reported zero swaps; the
end-to-end runs had no OOM, managed-memory cliff, or system-manager failure.

Failure found by the real workflow

The first maskless implementation passed units but segfaulted on the real
9,133-token request. A GDB hardware watchpoint found the generic ring-mask
writer overwriting the layer-2 graph header: after omitting the layer-major
score mask, control incorrectly fell through to old-row logic that assumes a
saved ring unavailable in layer-major prefill.

The root-cause correction restricts that branch to
causal_batch && !layer_major_batch. It adds no fallback, allocation, flag,
or defensive guard. The corrected source crosses the former crash point and
passes the real workflow.

Qualification

Release HIP gfx1151, build concurrency capped at four. The full pinned-Halo
test_deepseek4_unit passes, including the ratio-4 boundary formula and a
focused explicit-mask versus analytic-mask GPU oracle with bit-identical
streaming-attention output.

The unchanged Q2048/Q8192/Q8192/Q2048 ABBA harness used four frozen real-domain
token tapes, 128 teacher-forced full-vocabulary rows, and 32 greedy rows per
arm:

Domain Cross mean KLD Same-arm noise Cross top-1 Greedy prefix Result
Prose/reasoning 0.011536 0.008973 92.97% 2 KL-only miss
Code/kernel 0.001257 0.001329 98.44% 25 pass
Tool/agent 0.001293 0.001353 97.66% 32 pass
Multilingual/structured 0.003537 0.003923 97.66% 21 pass

Code, tool, and multilingual passed the preregistered limits. Prose passed its
top-1 and greedy rules but measured KLD 0.011536 against the frozen
max(0.006, 1.25 * noise) limit of 0.011216, a 0.000320 miss. This is
consistent with the inherited sparse replay noise, but the sample remains
reported as failed: no threshold was changed and it was not rerun until
passing. The focused kernel oracle is bit-identical.

Known limitation

Sparse prefill remains approximate and nondeterministic across identical
same-arm replays. State and logit hashes differ even within equal-width
controls. These results do not claim bitwise full-model determinism.

The 9,133-token timing fixture carries an agent-shaped coding transcript but
no actual tool schema and only a 128-token output budget. It directly exercises
the changed path; it is not a complete agent-task quality proof.

Scope

This PR contains public scheduling, selected-row dataflow, F16 transport,
generic HIP attention-kernel work, tests, and the narrow ring-mask root-cause
fix. It contains no private Behavioural Working Set mask, calibration, expert
reuse, slab, or placement policy. Temporary attribution telemetry was removed
before the final commit.

Review in cubic

@dusterbloom

Copy link
Copy Markdown
Collaborator Author

Clean public-head validation for da67e47f:

  • Built from a git archive export, excluding all private/staging working-tree edits.
  • HIP Release, gfx1151, -j4; test_deepseek4_unit passed on the Halo device.
  • Strix Halo performance/high policy, CPU boost on.
  • 7,680 prompt tokens, sparse Q8192, Q8 K / Q4 V, fused decode, prefix/prefill caches disabled.
  • Cold topology-build run: 33,256.8 ms.
  • Warm runs: 30,122.4 and 30,131.6 ms.
  • Warm midpoint: 254.921 tok/s.

This is +0.851 tok/s / +0.335% over the cited 254.07 tok/s Vulkan result at the same token count. All three clean one-token runs emitted The.

Caveat: matched token count and Strix Halo class, but not a proven identical prompt or model artifact. Sparse prefill itself remains approximate; this proves the performance gate, not full behavioral parity.

@dusterbloom dusterbloom changed the title perf(ds4): extend sparse prefill scheduling to 8K perf(ds4): extend sparse prefill scheduling to 10K Aug 31, 2026
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.

2 participants