Repository navigation
Gemma 4 TP: prompt chunks in row parts, each part's sums issued as built (off by default; GPU-exact for two ranks only) - #388
Merged
Conversation
Gemma4TensorParallelPromptParts.parts (task-local, 1 by default): a tensor-parallel rank runs a registered prompt chunk's work after attention in consecutive row parts. The attention output projection's partial is taken unsummed (Gemma4TensorParallelContext.deferred); every part's attention sum is issued, then every part's feed-forward collective (Gemma4Experts.tensorParallelPromptSum, asyncEval as built), then every part's rounding and norms, so one part's sum crosses the link while the next computes. The attention core still runs the whole chunk; every later op keeps each row's one-row bytes under the registered prompt policy, so every value is the whole chunk's. Only chunks whose experts take the shared one-row dispatch (BF16, expert prefill) split. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The changelog keeps both entries (the parts entry now states the measured best: 4 parts, +13 %). Two new lines over 100 columns are wrapped (a local Part typealias). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308
changed the base branch from
perf/gemma4-tp-prefill-shared-experts
to
main
November 6, 2026 07:40
…ctive, one down-projection guard - Gemma4TensorParallelContext.withoutCollective(_:) runs a layer's attention without its output projection's collective and returns the dtype that sum rounds to. DeferredSum and its task-local are now private to the context, so the decoder layer no longer binds the task-local or checks the dtype itself. The name follows TensorParallelSwitchLinear.withoutCollective, which does the same for the experts' down projection. - Gemma4Experts.tensorParallelDown holds the down-projection cast and its failure message once, for tensorParallelCall and tensorParallelPromptSum. - minimumRows says why a part keeps more than one row: it stays a registered prompt frame, so its projections and experts take the whole chunk's one-row paths. The same ops are built in the same order and the same arrays are issued: no value, default or schedule changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Documentation only. The SDK doc comments, the changelog entry and fork.yaml no longer say "never a value" / "values are unchanged": the parts are bit-identical on the GPU for two ranks while every op after attention is per-row; not on the CPU backend (RMSNorm's fallback); not exact with more than two ranks (the collective's per-element sum order depends on its size); nothing enforces it, so it stays off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308
added a commit
that referenced
this pull request
Nov 6, 2026
The changelog keeps main's entries, then this branch's; fork.yaml merged without conflict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does (stacked on #387)
Gemma4TensorParallelPromptParts.parts(task-local, 1 by default): a Gemma 4 tensor-parallel rank can run a registered prompt chunk's work after attention in consecutive row parts.Gemma4TensorParallelContext.deferred).Gemma4Experts.tensorParallelPromptSum,asyncEvalas built), then every part's rounding and norms. The GPU computes one part while the link carries the previous part's sum.Evidence
d-inference test
promptPartsKeepEveryBitAndSplitEachChunksCollectives(parts: 2, 4)(two in-process ranks, paged host):The pair speedup is not yet measured; the GPU commands are queued for the next M5 Ultra window. Estimate: 1,066 → ~1,300 (2 parts) / ~1,450 (4 parts) tok/s at 9.7K.
Measured (M5 Ultra pair, JACCL, 2026-11-06 03:21–03:25Z) — off by default
tp-check gemma run --mode tp --prompt-parts N, real QAT 4-bit weights and text, warm, sealed:tokenIDsSHA256).--mode shard), and ~1.0 s of the 3.7 s exchange is hidden. The next layer's attention needs every row, so the last part's sum stays exposed.Update (07:40Z)
Merged
main(79a1ecc4, #387) into this branch: signed merge, no rebase. The changelog keeps both entries, and two lines over 100 columns are wrapped.AI usage
Written with Claude (Co-Authored-By trailer).
Exactness: conditions (independent review,
review-388-1843.md; 10:56Z)The earlier wording ("never a value", "every value unchanged") overstated it. Precisely:
promptChunkParts = 1). Onlytp-check --prompt-partssets it.The doc comments, the changelog entry and
fork.yamlnow say this (cd33b911). Refactor pass:3e74a460.