fix pyink - #5150
Open
NuojCheng wants to merge 3 commits into
Open
Conversation
PR #5119 landed src/maxtext/models/qwen3.py, qwen3_5.py and their tests wrapped at 80 columns, so 'pre-commit run pyink --all-files' now fails on main and reddens the Code Quality check on every unrelated PR. This is pyink's output verbatim; no behaviour changes.
NuojCheng
requested review from
A9isha,
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
September 5, 2026 00:48
There was a problem hiding this comment.
Code Review
This pull request consists entirely of code formatting adjustments across several files, including model definitions (qwen3.py, qwen3_5.py) and test suites (train_tests.py, pyconfig_test.py, train_compile_test.py). Multi-line statements, function calls, and assertions have been consolidated into single lines to improve readability and consistency. No functional changes were introduced, and there are no review comments to address.
test_tpu_qwen3_explicit_sharding_matches_auto has failed on tpu7x-8 in every nightly since tpu7x joined the matrix, and passes on v6e-4. Only the dense 'qwen3' subtest is affected -- it is the one that sets ici_tensor_parallelism=-1, which resolves to the device count: 4 on v6e (2 of the 8 query heads per shard) but 8 on tpu7x (1 head per shard, the axis fully sharded). Step 1 matches bit-for-bit and the drift appears only from step 2, so it is the backward reductions reassociating under the pinned layout, not a sharding bug. The observed miss is 9.99e-6 relative against an rtol of 1e-6. 1e-4 matches what the sibling hybrid test already allows for the same effect.
…vice count
test_tpu_qwen3_hybrid_explicit_sharding_matches_auto crashes on tpu7x-8 with
ValueError: Sharding spec ('tensor',) implies that array axis 2 is partitioned
8 times, but does not evenly divide the dimension size 4.
Got shape: (96, 256, 4, 384)
ici_tensor_parallelism=-1 resolves to the device count, so the head axis is asked
to shard 8 ways while gdn_num_key_heads is 4. It passes on v6e-4 only because 4
divides 4. Pin the degree at 4 and let the leftover devices go to data
parallelism, which both shard modes see alike.
Reproduced and verified by AOT-compiling this config: it raises the same error at
v5p-16 (8 devices) with '-1' and compiles clean at both v5p-8 and v5p-16 with the
pinned degree.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Description
Fixes every failure on
mainthat is attributable to recently merged Qwenexplicit-sharding work. Three commits.
1. pyink formatting (Code Quality Check).
pre-commit run pyink --all-filesfails on
main. Five files landed wrapped at 80 columns instead of the repo's--pyink-indentation=2 --line-length=122:src/maxtext/models/qwen3.pysrc/maxtext/models/qwen3_5.pytests/integration/train_tests.pytests/unit/pyconfig_test.pytests/unit/train_compile_test.pyAll five came in with #5119 (f452e71). The Code Quality job runs pyink over all
files rather than only the diff, so this reddens the check on every unrelated PR.
The nightly at 13988fb (run 33932239729) is the first to include #5119 and it
reports exactly these five files. That commit is pyink's output verbatim.
2.
test_tpu_qwen3_explicit_sharding_matches_autotolerance. Fails ontpu7x-8, passes onv6e-4, bit-identical across nightlies:Only the dense
qwen3subtest is affected -- the one that setsici_tensor_parallelism=-1, which resolves to the device count. Withbase_num_query_heads=8that is 4-way TP on v6e (2 heads per shard) and 8-way ontpu7x (1 head per shard). Step 1 matches bit-for-bit and the drift appears only
from step 2, so the backward reductions reassociate under the pinned layout while
the forward pass is unchanged. Loosened to
rtol=1e-4, matching what the siblinghybrid test already allows for the same effect.
3.
test_tpu_qwen3_hybrid_explicit_sharding_matches_autodivisibility. Hardfailure on
tpu7x-8, new with #5119:Same root cause, different symptom:
ici_tensor_parallelism=-1asks the head axisto shard 8 ways while
gdn_num_key_heads=4. It passes on v6e-4 only because 4divides 4. Pinned the degree at 4 with the leftover devices going to data
parallelism, which both shard modes see alike.
Tests
pre-commit run pyink --all-filesandmdformat --all-filespass on this branch;pyink fails on
main. codespell, pylint, yamllint, actionlint and thedecoupled-requirements hook were already passing and still pass.
The qwen3-next fix was reproduced and verified locally by AOT-compiling that exact
config: with
ici_tensor_parallelism=-1it raises the identicalValueErroratv5p-16(8 devices), and with the pinned degree it compiles clean at bothv5p-8andv5p-16. The tpu7x CI job on this PR is the end-to-end check forboth test changes.
Not addressed here (not caused by this work)
For the record, the other failures on
mainat 13988fb were checked and areunrelated:
tokamax_test.py::test_smoke_train_tokamax_v1_fp8_full_ep1--NotImplementedError: subchannel_iters != 1 not supported yet in tgmm, a tokamax limitation.train_tests.py::test_moe_nanoo_fp8[_sparse_matmul]-- GCS412 PreconditionFailedwriting torunner-maxtext-logs, infrastructure.sft_multimodal_gemma3_demo.ipynb/native_lora_demo.ipynb--NOT_FOUND: "google/gemma-3-4b-it"tokenizer, failing nightly for weeks.checkpoint_resharding_test.py::test_checkpoint_resharding-- tensorstore zarr3chunk_shapemismatch. Not root-caused here, but no PR in this range touches checkpointing, orbax or tensorstore, and this shard has a history of orbax-flavoured breakage (e.g.'Checkpointer' object has no attribute 'restore'in run 33776554492, well before this work).Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.