Skip to content

tp-check gemma run: --layer-stride to measure Gemma's decode stride - #1827

Merged
jonathan308 merged 2 commits into
devfrom
perf/tp-gemma-stride-option
Nov 5, 2026
Merged

jonathan308 merged 2 commits into
devfrom
perf/tp-gemma-stride-option

Conversation

@jonathan308

@jonathan308 jonathan308 commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

What

A bench option for measuring Gemma's decode stride on a pair; it doesn't change the product.

Gemma tensor parallel submits each decode step to the GPU after every layer (Gemma4TensorParallelModel.decodeLayerStride = 1, documented as "not yet measured for Gemma"). For Qwen, moving from 1 to 8 took a pair's step from 21.4 to ~20.2 ms (1 request) and from 35.4 to 29.9 ms (4 at once) (#1820). This PR lets the M5 Ultra pair measure Gemma's curve before the product default moves:

  • Gemma4TensorParallelModel.withLayerStride(_:_:): a bench's own stride for its body (the existing internal @TaskLocal).
  • darkbloom-cluster-tp-check gemma run --layer-stride N (paged path; full, shard or tp):
    • bound into the ranks' workload digest;
    • prints decode stride=N step_ms_p50=… step_ms_min=….

Tests

  • Gemma4TensorParallelRuntimeTests.layerSubmissionKeepsEveryBit (GPU) compares the whole step (stride 0) with strides 1, 2, 5 and 8. Before, it compared 0 with 1 and 2. Tokens, top logits and the final row must be bitwise. Queued for the next GPU slot.
  • aBenchsLayerStrideHoldsForItsBodyOnly (new; CPU, run locally: passes).
  • The tool builds with Xcode 27.2 (build-native-worker.sh), and check-weak-imports.sh passes. A staged copy is in tp-perf/binx-gemma-stride/ on Mac A, sha ef184bcff38e.

Docs: docs/architecture/inference.md (Gemma oracles). No changelog fragment: there's no user-visible change.

Slot command on the pair, one run per stride:

gemma run --mode tp --backend jaccl --reduction sealed-bench --path paged --layer-stride {1,4,8,15} --model-dir <gemma-4-26b-qat> --request <req> --report <new>


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:56–19:58Z, Mac A load 3.4–6.9)

  • layerSubmissionKeepsEveryBit (strides 1/2/5/8) and aBenchsLayerStrideHoldsForItsBodyOnly PASS.
  • Gemma stride curve (tp mode, sealed, 61-token English prompt, 128 greedy tokens, interleaved): step p50 stride 1: 8.63/8.58 ms; 4: 9.02; 8: 9.22/9.16; 15: 9.55. Same tokens at every stride, ranks agree. Gemma's product stride 1 is the fastest: the default stays. The option remains useful for re-measuring.

Gemma tensor parallel submits each decode step after every layer
(decodeLayerStride = 1, "not yet measured for Gemma"). Qwen's pair measured
21.4 -> 20.2 ms per step at stride 8 (#1820). This adds the bench option
that measures Gemma's stride on a pair before the product default moves:
Gemma4TensorParallelModel.withLayerStride and gemma run --layer-stride N
(paged path; full, shard or tp), bound into the ranks' workload digest,
with a step p50 line. layerSubmissionKeepsEveryBit now also covers
strides 5 and 8; a CPU test pins the wrapper's scope.

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:30pm UTC
d-inference-console-ui-dev Error Error Nov 5, 2026 8:30pm UTC
d-inference-landing Ready Ready Preview Nov 5, 2026 8:30pm UTC
darkbloom-status Ready Ready Preview Nov 5, 2026 8:30pm UTC
eigen-homepages-darkbloom Ready Ready Preview Nov 5, 2026 8:30pm UTC

Request Review

Review of #1827 (nit 6): simulated runs both ranks on the local pair's
own threads, which never see the TaskLocal stride, so the product stride
ran while the log said stride=N. Gemma4TensorParallelModel
.benchLayerStrideApplies(mode:) names the modes a stride reaches (full,
shard, tp); the tool refuses any other, and the CPU test pins it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jonathan308
jonathan308 merged commit 559b697 into dev Nov 5, 2026
20 of 22 checks passed
jonathan308 added a commit that referenced this pull request Nov 5, 2026
Brings in the Gemma TP build-ahead steps (#1822, #1824) and the bench layer
stride (#1827). Conflict in tp-check's `gemma run` resolved by keeping both:
`--mtp-depth`/`--assistant-dir` beside `--layer-stride`, both bound into the
ranks' workload digest. Speculative rounds keep their own loop (runRounds),
which reads each round's agreement before it builds the next round; the plain
loop's build-ahead is unchanged.

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 — 085e7e15 Deployed Nov 5, 2026 by vercel[bot]
Preview – d-inference-landing — 085e7e15 Deployed Nov 5, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — 085e7e15 Deployed Nov 5, 2026 by vercel[bot]
Preview – d-inference — 085e7e15 Deployed Nov 5, 2026 by vercel[bot]
Preview – darkbloom-status — 085e7e15 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