fix(nnx): scope PartitionSpec default strictly to LoRA parameters in sharding analysis - #4689
Merged
Merged
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
July 31, 2026 10:28
copybara-service
Bot
force-pushed
the
test_957035527
branch
3 times, most recently
from
July 31, 2026 10:53
2657a93 to
0f219b9
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
copybara-service
Bot
force-pushed
the
test_957035527
branch
4 times, most recently
from
July 31, 2026 14:21
5229448 to
3e677e0
Compare
copybara-service
Bot
force-pushed
the
test_957035527
branch
7 times, most recently
from
July 31, 2026 17:21
f583668 to
2fa5fc3
Compare
copybara-service
Bot
force-pushed
the
test_957035527
branch
4 times, most recently
from
August 3, 2026 10:48
07d738d to
9843e44
Compare
copybara-service
Bot
force-pushed
the
test_957035527
branch
5 times, most recently
from
August 3, 2026 15:21
51d8810 to
dba84fb
Compare
shralex
approved these changes
Aug 3, 2026
copybara-service
Bot
force-pushed
the
test_957035527
branch
7 times, most recently
from
August 4, 2026 08:26
8b3ab75 to
6c9a2c1
Compare
…sharding analysis This CL is a follow-up fix for PR #4501 (`src/maxtext/utils/sharding.py`): - Scopes `PartitionSpec P()` defaulting strictly to LoRA parameters (`isinstance(p_leaf, nnx.LoRAParam)` or `'lora'` in parameter name), allowing NNX LoRA models to execute safely without missing-spec errors. - Standard NNX parameters (`nnx.Param`) and standard Linen parameters remain `None` so unit tests (`test_mixed_sharding_fails`) throw an `AssertionError` on unannotated arrays as expected (`tolerance=0.5` untouched). - Keeps element counts (`p_leaf.size`) for unsharded parameter totals to preserve mixed-precision sharding validation. # Tests - Verified `tests/unit/maxtext_utils_test.py::TestAssertParamsSufficientlySharded` (7/7 passed with tolerance=0.5 untouched). - Verified `tests/integration/lora_e2e_nnx_test.py` (sharding validation passed across all 10 tests). # Checklist - [x] I have performed a self-review of my code. For an optional AI review, add the `gemini-review` label. - [x] I have necessary comments in my code, particularly in hard-to-understand areas. - [x] I have run end-to-end tests and provided workload details above. - [x] I have made or will make corresponding changes to the doc if needed. PiperOrigin-RevId: 958869746
copybara-service
Bot
force-pushed
the
test_957035527
branch
from
August 4, 2026 08:29
6c9a2c1 to
29a0ad6
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.
fix(nnx): scope PartitionSpec default strictly to LoRA parameters in sharding analysis
This CL is a follow-up fix for PR #4501 (
src/maxtext/utils/sharding.py):PartitionSpec P()defaulting strictly to LoRA parameters (isinstance(p_leaf, nnx.LoRAParam)or'lora'in parameter name), allowing NNX LoRA models to execute safely without missing-spec errors.nnx.Param) and standard Linen parameters remainNoneso unit tests (test_mixed_sharding_fails) throw anAssertionErroron unannotated arrays as expected (tolerance=0.5untouched).p_leaf.size) for unsharded parameter totals to preserve mixed-precision sharding validation.Tests
tests/unit/maxtext_utils_test.py::TestAssertParamsSufficientlySharded(7/7 passed with tolerance=0.5 untouched).tests/integration/lora_e2e_nnx_test.py(sharding validation passed across all 10 tests).Checklist
gemini-reviewlabel.