Skip to content

perf(qwen38): batch draft projections across lanes for concurrency - #651

Merged
davide221 merged 5 commits into
Luce-Org:mainfrom
Graffioh:codex/draft-projection-batching
Aug 27, 2026
Merged

davide221 merged 5 commits into
Luce-Org:mainfrom
Graffioh:codex/draft-projection-batching

Conversation

@Graffioh

@Graffioh Graffioh commented Aug 23, 2026 •

Copy link
Copy Markdown
Collaborator

Stack

This PR is restacked on the current #642 head at f45f874e, followed by two #651 commits:

Summary

  • Batch shared draft dense projections across active lanes.
  • Keep convolution, cache updates, RoPE, masks, positions, attention, and draft KV state lane-local.
  • Use one builder for C1 through C6, without a runtime switch or duplicate execution path.
  • Include the backend in the cached graph replay key.
  • Inherit feat(qwen38): batch DFlash2 decode for Qwen3.8-27B concurrency #642's metadata-preserving DFlash2 sliding-window handling. The tested Qwen3.8 draft reports SWA layers: 5/5 (window=2048).

The previous path ran each lane's dense draft backbone in a separate graph. The packed path combines projection columns and removes repeated MMQ launches without sharing lane state.

Projection A/B

This matched A/B isolates the unchanged #651 projection patch against its #642 parent. Warm medians exclude the first speculative round; each run generated a fixed 64-token output.

GPU C Draft compute, ms Complete round, ms
R9700 1 5.864 -> 5.864 (-0.0%) 62.161 -> 62.107 (-0.1%)
R9700 2 11.622 -> 8.498 (-26.9%) 74.153 -> 70.951 (-4.3%)
R9700 3 17.424 -> 11.392 (-34.6%) 96.811 -> 90.871 (-6.1%)
Strix Halo 1 12.129 -> 12.120 (-0.1%) 137.892 -> 138.107 (+0.2%)
Strix Halo 2 24.039 -> 15.341 (-36.2%) 166.877 -> 158.065 (-5.3%)
Strix Halo 3 36.378 -> 19.665 (-45.9%) 224.446 -> 209.150 (-6.8%)

C1 is neutral. C2 and C3 reduce complete-round latency by 4.3% to 6.8%. The R9700 C3 rocprof trace reduced MMQ launches from 336 to 196 (-41.7%) and MMQ device time from 11.938 ms to 6.103 ms (-48.9%).

Lucebox versus llama.cpp: generic-prompt concurrency baseline

This initial matrix was measured before the restack, on Lucebox #651 at 67c15f3e and llama.cpp PR #27342 at f7aadef0. It is retained here as a historical, artifact-pinned baseline; the follow-up matrix below uses the blog-aligned UD-IQ4_XS target and the checked-in HumanEval-style prompts.

The workload was synthetic engineering prose, not ordinary multi-turn chat: disjoint prompts of 250, 350, 450, or 550 words asked for a structured engineering analysis. Each cell used a fresh server, a same-concurrency 8-token warm-up, five measured repetitions, temperature 0, and exactly 256 generated tokens per request with EOS ignored. C1 through C4 used five server slots, 4,096-token per-request context, paged full attention, Q4_0 K/V cache, full GPU offload, no context shift, and disabled prefix/prompt/context-checkpoint caches. The GPUs ran sequentially. Aggregate throughput is total generated tokens divided by case wall time; ranges are the minimum and maximum of the five repetitions.

Radeon AI PRO R9700 (gfx1201)

C Lucebox tok/s, median (range) llama.cpp tok/s, median (range) Lucebox / llama.cpp llama.cpp acceptance
1 58.35 (58.27–58.51) 42.65 (42.59–43.02) 1.368× 34.16%
2 84.37 (84.33–84.46) 67.66 (66.91–68.38) 1.247× 30.45%
3 101.83 (101.76–102.19) 81.00 (79.11–81.07) 1.257× 34.32%
4 117.85 (117.48–117.94) 85.96 (82.51–86.86) 1.371× 31.04%

Ryzen AI Max+ 395 / Strix Halo (gfx1151)

C Lucebox tok/s, median (range) llama.cpp tok/s, median (range) Lucebox / llama.cpp llama.cpp acceptance
1 23.51 (19.92–23.55) 19.74 (17.73–20.06) 1.191× 30.18%
2 39.03 (31.53–39.14) 12.30 (10.71–13.77) 3.173× 0.65%
3 32.14 (28.51–32.38) 10.41 (8.91–12.13) 3.086× 0.69%
4 38.10 (32.95–38.60) 12.25 (10.68–12.35) 3.110× 0.09%

All 80 measured cases completed: 200/200 requests, with audit checks passing for output length, distinct prompt slices, GPU identity, model/draft identity, full offload, cache disablement, and required runtime markers. C5 was excluded from publication and C6 was not scheduled.

Artifact identity:

  • Pure-IQ4_XS target SHA-256: 4e44edf892af6d57506fcd9eeaf5d0628f8737cfdce89652cb9d9bff82808eae
  • Lucebox Q8_0 draft SHA-256: bb727abc583498aa4deea8b3cd0c34c2d96553954cbff25b5f7bdd469f0f1306
  • llama.cpp Q8_0 draft SHA-256: c18e800daedc59ca68fd13b6a856d795746af6d399a9279ac6a277d1d422f87e

Lucebox versus llama.cpp: HumanEval-style code prompts

This follow-up matches the workload used in the Qwen3.8 R9700 blog more closely. It uses the ten checked-in HumanEval-style prompts from server/scripts/bench_he.py, with disjoint prompt slices at each level: prompt 0 for C1, prompts 1–2 for C2, prompts 3–5 for C3, and prompts 6–9 for C4. Each cell used a fresh server, a same-concurrency 8-token warm-up, temperature 0, EOS honored after Lucebox's configured 8-token minimum, a 256-token cap, and two measured repetitions.

Both runtimes used five server slots, 4,096 tokens of per-request context, full GPU offload, no context shift, Q8_0 K/V cache, and disabled prompt/context-checkpoint caches. Lucebox used fixed DFlash2 width 8 and the packed draft backbone; llama.cpp used draft-dflash with n_max=7. The GPUs ran sequentially. Aggregate throughput is total output tokens divided by cell wall time; ranges are the two observed repetitions. The reported ratio is the median of paired per-repetition ratios. With two repetitions, the tabulated median is the midpoint of two observations and should be read as a limited estimate rather than a robust distribution.

The Lucebox server retained DFLASH_MIN_TOKENS=8; llama.cpp had no equivalent minimum-output floor. This can change a completion that would otherwise stop before eight tokens, so it is a protocol asymmetry. Every stable Lucebox completion ended at 19 tokens or more, but the retained logs do not contain a floor-trigger counter that proves whether the constraint activated.

The exact Lucebox build is #651 at 8ba84d3d, whose parent is the current #642 head f45f874e. The comparator is llama.cpp PR #27342 at f7aadef0.

Radeon AI PRO R9700 (gfx1201)

C Lucebox tok/s, median (range) llama.cpp tok/s, median (range) Lucebox / llama.cpp llama.cpp acceptance
1 110.02 (109.83–110.21) 80.23 (78.84–81.62) 1.372× 93.17%
2 153.67 (153.16–154.17) 107.62 (101.45–113.79) 1.432× 82.29%
3 200.33 (199.36–201.29) 165.92 (165.82–166.01) 1.207× 88.48%
4 188.85 (188.63–189.08) 142.16 (136.11–148.22) 1.331× 89.49%

All 20 paired prompt executions had the same completion-token count and stop reason across the two runtimes, and all eight runtime/concurrency groups were repeat-stable. Output text hashes were runtime-specific rather than byte-identical.

Ryzen AI Max+ 395 / Strix Halo (gfx1151)

C Lucebox tok/s, median (range) llama.cpp tok/s, median (range) Comparable speedup llama.cpp acceptance Stop/count parity
1 40.63 (40.40–40.87) 36.30 (33.85–38.74) 1.124× 93.17% 2/2
2 58.69 (55.47–61.92) 24.10 (13.33–34.87) n/a 13.18% 2/4
3 63.52 (59.24–67.81) 13.14 (12.70–13.58) n/a 1.93% 4/6
4 63.20 (58.51–67.90) 19.04 (18.18–19.91) n/a 20.39% 0/8

Only C1 is a valid paired speed comparison on Strix Halo. At C2 through C4, llama.cpp became repeat-unstable and stopped identical prompts at different output lengths—for example, one C2 prompt produced 7 tokens in repetition 1 and 137 in repetition 2, versus Lucebox's stable 97 tokens. Lucebox remained repeat-stable at every concurrency. The C2–C4 raw goodput values are retained as diagnostic evidence, but ratios are intentionally omitted because the runtimes did not perform equal output work.

Across both GPUs, all 32 cases and 80 requests completed. On R9700, each runtime produced 3,014 measured completion tokens with 20/20 stop/count parity. On Strix Halo, Lucebox produced 3,014 tokens while llama.cpp produced 2,123, with 8/20 stop/count parity. C5 and C6 were not run.

Artifact identity:

  • Blog-aligned target: unsloth/Qwen3.8-27B-GGUF/Qwen3.8-27B-UD-IQ4_XS.gguf
  • Target SHA-256: 40fac4050e940397dbf13087afd50f4734a11805bf9d65ef8ddd7483470e6199
  • Lucebox Q8_0 draft SHA-256: bb727abc583498aa4deea8b3cd0c34c2d96553954cbff25b5f7bdd469f0f1306
  • llama.cpp Q8_0 draft SHA-256: c18e800daedc59ca68fd13b6a856d795746af6d399a9279ac6a277d1d422f87e

Verification

The generic and HumanEval-style concurrency matrices are reported here on #651. #654 adds sampled concurrent speculation and needs a separate restack onto this updated #651 head.

@Graffioh Graffioh changed the title perf(qwen35): batch draft projections across lanes perf(qwen35): batch draft projections across lanes for concurrency Aug 23, 2026
@Graffioh
Graffioh force-pushed the codex/draft-projection-batching branch from c136c86 to 98896bf Compare August 24, 2026 06:36
@Graffioh
Graffioh force-pushed the codex/draft-projection-batching branch 2 times, most recently from 9608985 to fae03e7 Compare August 24, 2026 09:17
@Graffioh
Graffioh force-pushed the codex/draft-projection-batching branch 4 times, most recently from 21b3aef to e272492 Compare August 24, 2026 13:33
@Graffioh
Graffioh marked this pull request as ready for review August 24, 2026 17:37

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 64 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="server/test/test_batched_gdn.cpp">

<violation number="1" location="server/test/test_batched_gdn.cpp:73">
P2: In test_cpu_gdn_support_matrix the active op is built with n_tokens=2 yet active_slots has only 1 element. GGML construction asserts the active-slot ids tensor matches n_tokens*n_seqs (as run_gdn does with n_seqs for n_tokens==1, and as the sibling tree/tree_persist helpers assert), so on the --cpu path this GGML_ASSERT aborts the test instead of printing the support-matrix result. Size active_slots to n_tokens.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread server/src/common/dflash_draft_kv.h Resolved
Comment thread server/src/common/dflash2_batch.cpp Resolved
Comment thread server/src/common/dflash2_head.cpp Resolved
Comment thread server/test/test_paged_kv_pool.cpp Resolved
Comment thread server/test/test_draft_topk_cuda.cpp Resolved
Comment thread server/test/test_gdn_replay_log.cpp Resolved
@Graffioh
Graffioh force-pushed the codex/draft-projection-batching branch 2 times, most recently from 8ba84d3 to f74d1c9 Compare August 25, 2026 11:30
@Graffioh
Graffioh changed the base branch from qwen38-dspark to main August 25, 2026 11:30

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 5 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="server/test/test_draft_swa_multilane.cpp">

<violation number="1" location="server/test/test_draft_swa_multilane.cpp:139">
P3: When `draft_kv_init_batched` returns false for a real failure (e.g. `mem_buf` cache allocation fails), this combined condition prints "batched init allocated a single-lane graph", which misdirects debugging. Split the init-failure case from the graph-allocation checks and give each its own message.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

@Graffioh

Copy link
Copy Markdown
Collaborator Author

Fixed the inherited NVIDIA CI failure in 6ab5d01b. The workflow still requested the pre-rename target test_gdn_transition_journal, while f74d1c9 renamed the CMake target to test_gdn_replay_log. Both the RTX 3090 and DGX failures on the previous #651 head stopped at that missing target. #659 has been refreshed by merging this new #651 head while preserving all measured follow-up commits.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name=".github/workflows/ci.yml">

<violation number="1" location=".github/workflows/ci.yml:216">
P2: The build target rename here is incomplete: the "Run concurrent-serving kernel tests" step in this same job still filters ctest with `gdn_transition_journal_preflight$`, but server/CMakeLists.txt now registers the tests as `gdn_replay_log`, `gdn_replay_log_gallocr`, and `gdn_replay_log_preflight`. The stale filter matches no registered test, so the new gdn replay-log coverage is silently dropped from the NVIDIA gpu-tests run (the other alternatives still match, so `--no-tests=error` does not catch it). Update the `-R` regex to the renamed test name so the preflight test actually executes.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread .github/workflows/ci.yml Resolved
@Graffioh
Graffioh force-pushed the codex/draft-projection-batching branch 2 times, most recently from 6b21192 to 7aa0245 Compare August 26, 2026 15:40
@Graffioh Graffioh changed the title perf(qwen35): batch draft projections across lanes for concurrency perf(qwen38): batch draft projections across lanes for concurrency Aug 26, 2026
Add fixed-width DFlash2 concurrent decoding for Qwen3.8 and batch the shared dense draft projections across active lanes.

Keep convolution, cache updates, RoPE, masks, and attention lane-local. Preserve transactional state promotion and fixed-chain validation through C6.
@davide221
davide221 force-pushed the codex/draft-projection-batching branch from 7aa0245 to e6465dc Compare August 27, 2026 13:51
@davide221
davide221 merged commit 15884e5 into Luce-Org:main Aug 27, 2026
9 checks passed
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