[NNX] Delete Linen (12.1a): state setup and train loop - #4683
[NNX] Delete Linen (12.1a): state setup and train loop#4683ecnal-cienet wants to merge 1 commit into
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
4c81467 to
aa08c26
Compare
aa08c26 to
9272adf
Compare
e4f9afd to
d095c8f
Compare
bvandermoon
left a comment
There was a problem hiding this comment.
Do we need to get rid of the flags to enable/disable the NNX/Linen versions with this PR? The flags break once the Linen paths start getting removed
Hi @bvandermoon, You're right that the flags break as the Linen paths come out. But removing them in this PR means deleting every So I split it into 7 stacked PRs by subsystem:
The flags are removed in 12.5. That is the only PR that touches the config surface ( For the gap in between: I checked what So it fails, not silently trains something wrong. |
d095c8f to
70a1185
Compare
…ate setup and train loop The pure_nnx defaults are true, so the Linen branches in the pre-train state and train-loop path are dead. Collapse them: - train_utils.setup_train_loop: always build the abstract NNX model and a TrainStateNNX init_state_fn; drop the Linen model/TrainState branch and the Linen arms of the DiLoCo sharding and debug_sharding blocks. - maxtext_utils: get_functional_train_with_signature and get_functional_eval_with_signature drop the trailing rng in_sharding; load_compiled drops the example rng; get_abstract_state delegates to get_abstract_state_nnx. setup_initial_state is deliberately left alone. Its Linen branch is entangled with the checkpoint restore overlay, and the orbax v1 migration is touching that code; it is collapsed in a later change. Tests follow the same narrowing: the Linen-only cases in maxtext_utils_test, state_dtypes_test and the sharding_compare_test Linen-golden driver go away. test_deepseek4 is skipped rather than pinned to Linen, since nnx_decoders.py has no deepseek4 decoder_block branch yet.
70a1185 to
94526bc
Compare
Description
First of the pre-train Delete-Linen PRs. It removes the Linen branch of every
pure_nnxconditional in pre-train state setup and the training loop. With the NNX defaults those branches never run, so this is pure dead-branch removal — the three flags (pure_nnx/enable_nnx/pure_nnx_decoder) still exist (they come out in a later PR), so nothing about the config surface changes here.Source changes:
maxtext_utils.pyget_functional_train_with_signature/get_functional_eval_with_signature: drop the Linen(state, batch, rng)in-shardings; the NNX step takes no rng, so it is always(state, batch).load_compiled: drop the Linenexample_rngextra input.get_abstract_state: collapse to always callget_abstract_state_nnx, deleting the Linen abstract-state path (jax.eval_shape+nn.get_partition_spec+logical_to_mesh_sharding+ the optimizer/param host-offload handling).train_utils.pysetup_train_loop: always build the NNX abstract model and theTrainStateNNXinit function, and drop the Linenfrom_configmodel, theinit_initial_statepartial, and the Linenelsebranches for param extraction, the DiLoCo step mesh,debug_shardinglogical annotations, and the final train-state/model merge.Test changes (drop the now-dead Linen cases):
setup_train_loop_nnx_test.py: only the NNX path remains, so thetest_pure_nnx_*cases lose theirpure_nnxqualifier.maxtext_utils_test.py: remove the Linen model construction andtest_linen_in_shardings_includes_rng/pure_nnx=Falsemock configs.sharding_compare_test.py: remove the Linen-goldentest_sharding_dump_for_modelcomparison (those goldens were Linen-only).state_dtypes_test.py/train_compile_test.py: drop thepure_nnx=False/linen_scannedvariants, keeping the NNX cases.correctness_tests_nnx_dispatch_test.py: droptest_sft_logits_linen_pathand collapse_sft_config()to NNX-only — the Linen SFT path is deleted here, so that CPU case can no longer run.~8 files, +115 / −628.
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.