Skip to content

Qwen TP decode: submit every 8 layers, not every layer (−15 % solo, −13 % at 4) - #1820

Merged
jonathan308 merged 3 commits into
devfrom
perf/tp-decode-idle-gaps
Nov 5, 2026
Merged

jonathan308 merged 3 commits into
devfrom
perf/tp-decode-idle-gaps

Conversation

@jonathan308

@jonathan308 jonathan308 commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

What

Qwen tensor-parallel decode submits its forward to the GPU every 8 decoder layers instead of after every layer (QwenTensorParallelLaunch.decodeLayerStride, was QwenTensorParallelBatchSession.decodeLayerStride = 1). Evaluation order only: every primitive, input and rounded value is unchanged, so tokens, logits and committed state keep their bits. It is not a launch option, and the two ranks don't need to agree on it.

darkbloom-cluster-tp-check qwen-decode also takes --backend jaccl (a real pair) and --layer-strides 1,8,16 (compare strides in one run; the default is the product's stride).

Why: measured, not per chip

Setup: two M5 Ultra 256 GB over JACCL, Qwen 3.8 27B, sealed-bench sums, qwen-decode through the real batch driver and native executor. Synthetic 64-token prompt, 128–256 output tokens. DevNet production window 2, 2026-11-05 15:47–15:53Z. Mac A's load came from other agents' builds.

Width Mac A load Stride 1 (before) 8 16 32
1 ~2.5 21.4 ms 19.6–20.7 20.2–20.9 21.2
1 (interleaved 1,8,16 ×3) 6–10 25.1 20.4 19.9 —
4 ~5 35.4 29.9 29.5 —

The curve is flat from 8 to 16 and worse again at 32, where the GPU waits for the host's first batch of layers. I chose 8 rather than tuning per chip:

  • it sits inside that flat band on the only hardware measured;
  • it splits the 9B's 32 and the 27B's 64 layers evenly;
  • it's the smaller of the equal-cost values, so on slower hosts the GPU starts sooner.

Pair-2 (M3 Ultra + M5 Max) was not measured; that lane is owned elsewhere. The stride can be re-measured with --layer-strides on any pair.

Tokens identical

Hardware: every stride (0, 1, 2, 4, 8, 12, 16, 24, 32) retired the same token digest on both ranks in every run:

  • width 1, 128 tokens: 07e4ad1b7b1f3176;
  • width 1, 256 tokens: e9a2476641c3ba6d;
  • width 4: 5a19c6dc97432be2.

The tool's cross-rank check printed "both ranks retired the same tokens in every run: true".

Suites: the existing GPU-gated parity tests already compare a whole-step evaluation (layerStride 0) with decodeLayerStride byte for byte, so they now cover 8:

  • QwenTensorParallelMoEDecodeBenchTests submission-parity;
  • QwenTensorParallelWindowSubmissionTests;
  • QwenTensorParallelComputeBenchTests.

These GPU suites ran on the M5 Ultra pair (2026-11-05 19:53Z, 63612983d9): 22/22 passed (results below). Not measured: the MoE submission-parity bench (no qwen3_5_moe checkpoint on the pair) and pair-2 speed.

Tests

libs/darkbloom-cluster/Tests/TensorParallelPlanChecks/run.sh (model-free, CI's focused lane) adds checkDecodeSubmission:

  • the product stride gives 4–8 submissions for 64 layers (the measured band);

  • it divides 32 and 64;

  • the submission count is right at stride 1, at 0, with a partial last batch, and with no layers.

  • Before (stride 1): FAIL: 27B decode submissions at stride 1: 64, measured band 4-8, FAILED: 1.

  • After: decode submission: stride 8, 8 submissions for 64 layers, PASS.

The tool builds with Xcode 27.2 (build-native-worker.sh, no warnings in the changed files).

Scope

  • Qwen (dense and MoE) batch decode only. Speculative verify windows are still evaluated whole by default.
  • Gemma's own decodeLayerStride = 1 is unchanged (not measured).
  • Docs: docs/architecture/inference.md. Changelog: changelog.d/tensor-parallel-decode-submits-every-eight-layers.md.

Against the bar (pair ≥ 2× one Mac, plain vs plain): the re-measured step goes from 23.2 to 19.7 ms (−15 %, width 1) and from 32.1 to 27.8 ms (−13 %, width 4) on the tool's synthetic prompt. One M5 Ultra plain does 55.9 tok/s through DevNet (.95, realistic chat prompt), and 2× needs 112. This is the first of the idle-gap fixes. Next: GLM's pipelined one-token loop, the per-step host cost in exactFrozenQuantizedInputProjections, and the MoE exchange.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Hardware results (M5 Ultra pair, 2026-11-05 19:53–20:01Z, Mac A load 2.9–5.8)

  • GPU parity suites PASS 22/22 at 63612983d9 (QWEN_TP_MTP_GPU=1 QWEN_TP_BATCH_GPU=1 swift test --filter 'QwenTensorParallelWindowSubmissionTests|QwenTensorParallelBatchSessionTests').
  • Stride re-check (tp-check over JACCL, sealed, synthetic prompt, interleaved 1,8,16 ×2 runs ×2): width 1 23.2 → 19.7 ms (−15 %) at 8 (16: 19.5); width 4 32.1 → 27.8 ms (−13 %) at 8 (16: 27.8). Same tokens on both ranks in every run.
  • MoE submission-parity bench skipped: no qwen3_5_moe checkpoint on the pair.

A tensor-parallel decode step was submitted to the GPU after every decoder
layer (decodeLayerStride = 1): 64 commits and GPU wake-ups a 27B token. On
two M5 Ultra 256 GB over JACCL (sealed sums, synthetic 64-token prompt) a
width-one step took 21.4 ms at stride 1 and 20.2-20.3 ms at 8-16 (25.1 vs
19.9-20.4 ms with the host loaded), width four 35.4 vs 29.5-29.9 ms; 32 is
slower again (21.2 ms). Every stride retired the same tokens on both ranks.

The stride moves to QwenTensorParallelLaunch.decodeLayerStride (8, inside
the measured flat band, divides 32 and 64 layers) with decodeSubmissions,
checked by the model-free TensorParallelPlanChecks. qwen-decode takes
--backend jaccl and --layer-strides (default: the product's stride).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
d-inference Error Error Nov 5, 2026 8:46pm UTC
d-inference-console-ui-dev Error Error Nov 5, 2026 8:46pm UTC
d-inference-landing Ready Ready Preview Nov 5, 2026 8:46pm UTC
darkbloom-status Ready Ready Preview Nov 5, 2026 8:46pm UTC
eigen-homepages-darkbloom Ready Ready Preview Nov 5, 2026 8:46pm UTC

Request Review

jonathan308 and others added 2 commits November 5, 2026 12:41
QwenTensorParallelDecodeBench.pair ran the same run(...) call twice, with
and without a layer-stride scope. One scope that keeps the current stride
when the caller gives none does the same. The verify-window doc no longer
says "layer by layer": windows submitted by layer (diagnostic) now use the
decode stride, 8.

Behaviour unchanged. Plan checks PASS; Qwen TP CPU suites 25/25.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #1820: the quieter slot (2026-11-05 19:58Z) measured -15 % for
one request and -13 % for four, replacing the first window's 6 %/16 %/20 %.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jonathan308 jonathan308 changed the title Qwen TP decode: submit every 8 layers, not every layer (−6 % solo, −16 % at 4) Qwen TP decode: submit every 8 layers, not every layer (−15 % solo, −13 % at 4) Nov 5, 2026
@jonathan308
jonathan308 merged commit a0a5150 into dev Nov 5, 2026
20 of 22 checks passed
jonathan308 added a commit that referenced this pull request Nov 5, 2026
QwenStageTokenSampler.takePendingStepLogprobs came in from #1824 too: one
copy kept, its doc naming both users (Gemma's one-token loop, Qwen's
build-ahead). #1820's stride, #1822/#1824's CBv2OwnedRequestState.submit and
#1830 are kept as on dev.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 5, 2026
qwen-decode keeps #1820's --backend jaccl and --layer-strides beside
--build-ahead; the bench takes both layerStride and buildsAhead (the logic
measured on the pair at 21:24-21:30Z).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch had an error being deployed

2 failed and 3 active deployments
Preview – eigen-homepages-darkbloom — 8a35684e Deployed Nov 5, 2026 by vercel[bot]
Preview – d-inference-landing — 8a35684e Deployed Nov 5, 2026 by vercel[bot]
Preview – darkbloom-status — 8a35684e Deployed Nov 5, 2026 by vercel[bot]
Preview – d-inference — 8a35684e Deployed Nov 5, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — 8a35684e Deployed Nov 5, 2026 by vercel[bot]
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