[NNX] Delete Linen 3/5: collapse dispatch in inference (maxengine, kvcache, vLLM, LoRA) - #4359
Draft
ecnal-cienet wants to merge 5 commits into
Draft
[NNX] Delete Linen 3/5: collapse dispatch in inference (maxengine, kvcache, vLLM, LoRA)#4359ecnal-cienet wants to merge 5 commits into
ecnal-cienet wants to merge 5 commits into
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
ecnal-cienet
force-pushed
the
feat/nnx-del-linen-3-inference
branch
2 times, most recently
from
July 7, 2026 21:00
cb9c0d0 to
fbe1484
Compare
ecnal-cienet
force-pushed
the
feat/nnx-del-linen-3-inference
branch
7 times, most recently
from
July 21, 2026 18:55
b514961 to
6a2b270
Compare
ecnal-cienet
force-pushed
the
feat/nnx-del-linen-3-inference
branch
6 times, most recently
from
July 29, 2026 14:48
2a26f98 to
e1a43f7
Compare
ecnal-cienet
force-pushed
the
feat/nnx-del-linen-3-inference
branch
3 times, most recently
from
August 19, 2026 16:46
24c27a8 to
dab8d49
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.
… muon utils - sharding.maybe_update_params_sharding_with_opt delegates to the _nnx variant; build_zero1_input_state_mesh_shardings drops its Linen early return. - muon_utils.get_muon_weight_dimension_numbers drops the isinstance(nnx.Module) test and the Linen get_abstract_param path; get_model_mdn loses its pure_nnx parameter and always builds the abstract NNX model. - run_sharding_dump loses its --pure_nnx flag. Tests follow: the Linen branch test in muon_utils_test goes away, optimizers_test drops the pure_nnx argument and the dual-shape comparison, sharding_nnx_test drops the flag from its fake config.
… and model creation - quantizations.maybe_quantize_model always runs the qwix forward pass with the dummy tokens/positions/segment ids (and the MTP decoder targets when mtp_num_layers > 0), then pops the transient nnx.Intermediate variables the traced forward sows. - model_creation_utils.from_pretrained always builds the sharded model through maxtext_utils_nnx.create_nnx_sharded_model. Tests follow: quantizations_test and nnx_quant_guard_test drop their flag arguments and Linen expectations, correctness_tests_nnx_dispatch_test keeps only the NNX case, and forward_pass_logit_checker always loads via from_pretrained.
…kvcache, vLLM, LoRA)
ecnal-cienet
force-pushed
the
feat/nnx-del-linen-3-inference
branch
from
August 20, 2026 21:38
dab8d49 to
5890a05
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.
NNX Migration Route Map
pure_nnxflag,init_state_fn,TrainStateNNX, NNX utils. Linen workflow unchanged. (PR NNX migration prep (1/N): pure_nnx flag and init_state_fn scaffolding #3427)get_abstract_state_nnx,get_named_sharding_nnx,set_named_sharding_nnx,get_partition_spec_nnx,get_mesh_from_config. (PR NNX migration prep (2/N): NNX utils and sharding utilities #3470)TrainStateNNX, model creation, gradient accumulation, checkpointing, and training loop dispatch. (PR NNX migration prep (3/N): TrainState, model creation, and end-to-end training loop #3500)9.5. ✅ NNX + AQT in MaxEngine + serve-mode reload + gpt3 prefill fix. (PR [NNX] NNX migration prep (9.5/N): NNX + AQT in MaxEngine + serve-mode reload + gpt3 prefill fix #3844)
custom_vjpfor NNX.True; regenerate sharding goldens; flip back integration-testpure_nnx=Falseannotations. (PR [NNX] NNX migration (11/N): set pure_nnx / enable_nnx / pure_nnx_decoder defaults to True #3526)12.1. ✅ Collapse Linen dispatch in utils / quantization / checkpointing / sharding. (PR [NNX] Delete Linen 1/5: collapse dispatch in utils, quantization, checkpointing, sharding #4357)
12.2. ✅ Collapse Linen dispatch in trainers (pre-train, DiLoCo, GRPO); regenerate the NNX DPO golden. (PR [NNX] Delete Linen 2/5: collapse dispatch in trainers (pre-train, DiLoCo, GRPO) #4358)
12.3. 🔄 [This PR] Collapse Linen dispatch in inference / serving —
maxengine.py,kvcache.py,vllm_decode.py,lora_utils.py+ tests. Also drops theenable_nnx/pure_nnx_decoderentriesvllm_decode.pyforwarded into the nested vLLMmaxtext_config. Stacks on 12.2.12.4. ❌ Delete the Linen decoder/attention/embedding layers +
*_as_linenmodel wrappers.12.5. ❌ Remove the
pure_nnx/enable_nnx/pure_nnx_decoderconfig flags.Description
Third of the stacked "Delete Linen" series (see 1/5). Collapses the Linen dispatch in the inference and serving path:
maxengine.py,kvcache.py,vllm_decode.py, andlora_utils.py, with their tests updated. This also drops theenable_nnx/pure_nnx_decoderentries thatvllm_decode.pyforwarded into the nested vLLMmaxtext_config, since that nested MaxText now defaults to NNX.Serving already ran the NNX path by default, so this is dead-branch removal with no behavior change. Base branch is
feat/nnx-del-linen-2-trainers. ~8 files, +189 / −648.Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.