Reject KV head counts that cannot be sharded across the tensor-parallel mesh. - #4811
Open
copybara-service[bot] wants to merge 1 commit into
Open
Reject KV head counts that cannot be sharded across the tensor-parallel mesh.#4811copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
copybara-service
Bot
requested review from
A9isha,
NuojCheng,
RissyRan,
SurbhiJainUSC,
abhinavclemson,
aireenmei,
bvandermoon,
darisoy,
dipannita08,
gagika,
gobbleturk,
hengtaoguo,
huytransformer,
igorts-git,
jiangjy1982,
khatwanimohit,
parambole,
richjames0,
shralex,
shuningjin,
vipannalla and
xibinliu
as code owners
August 10, 2026 22:11
…el mesh. Attention heads are atomic under tensor parallelism, so the per-layer KV head count has to be divisible by the combined size of the mesh axes that `logical_axis_rules` maps the `kv_heads` logical axis onto (by default tensor x tensor_sequence x autoregressive). Previously an over-sharded mesh -- for example gemma4-26b, whose global attention layers use `global_num_kv_heads: 2`, with `ici_tensor_parallelism=4` -- failed much later with an opaque XLA divisibility error, or silently left the key/value projection unsharded. `Attention.init_kv_w` now raises a `ValueError` naming the head count, the shard count, the mesh axes responsible, and how to fix it. PiperOrigin-RevId: 961244739
copybara-service
Bot
force-pushed
the
test_961244739
branch
from
August 11, 2026 18:44
a6966b7 to
7f704c4
Compare
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.
Reject KV head counts that cannot be sharded across the tensor-parallel mesh.
Attention heads are atomic under tensor parallelism, so the per-layer KV head
count has to be divisible by the combined size of the mesh axes that
logical_axis_rulesmaps thekv_headslogical axis onto (by default tensor xtensor_sequence x autoregressive).
Previously an over-sharded mesh -- for example gemma4-26b, whose global
attention layers use
global_num_kv_heads: 2, withici_tensor_parallelism=4-- failed much later with an opaque XLA divisibility error, or silently left the
key/value projection unsharded.
Attention.init_kv_wnow raises aValueErrornaming the head count, the shard count, the mesh axes responsible, and how to
fix it.