Repository navigation
Conversation
- Free scanned sources, sliced wi_0/wi_1 halves, and pre-fused wi only after the last conversion group reading them finishes (for inhomogeneous local_layers cycle slots). - Forward-compatibly pass free_sources=True when MaxTextToMaxTextConverter supports it directly, and document the private hook fallback TODO. - Drop jax.clear_caches() after update_params(). - Move LoadAndConvertScannedCheckpointTest above the single __main__ guard and add shared-source local_index 0/1, native free_sources, and clear_caches test coverage.
ae1793e to
9511f74
Compare
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enables MaxText vLLM rollout nodes to load model weights from checkpoints when weight synchronization is disabled (mode: none). By supporting both unscanned and scanned checkpoint paths, the rollout node can now initialize with random weights and subsequently load the actual model parameters before serving. This change includes necessary infrastructure for detecting checkpoint layouts, managing storage settings, and integrating with the updated MaxText scanned checkpoint loader, while also updating the MaxText pin to support these features. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds support for loading scanned MaxText checkpoints at startup in inprocess_vllm rollout nodes when weight synchronization is disabled. It includes configuration updates, validation logic, layout resolution from Orbax metadata, and loading integration, along with comprehensive unit and golden tests. Feedback is provided to ensure the Orbax metadata parsing fails loud and fast with a clear ValueError if the format is invalid. A suggestion to use a defensive .get() fallback was removed as it violates the repository's style guide against speculative fallbacks.
tianshub
left a comment
There was a problem hiding this comment.
Thanks for the detailed description. I read the production changes (config, resolver, rollout.py) and did not find a logic bug, and the CPU checks are green. I have not read the test files or the golden JSON, and did not run anything locally.
I would hold off merging as is, for two reasons, plus a layering suggestion; details inline:
- The feature has not run on a real TPU yet (as the description says), and the part mocks cannot cover is exactly the risky part: peak HBM when a checkpoint is loaded over an already-initialized engine.
- The MaxText pin bump is 154 commits and affects every MaxText path, and
tunix_tpu_unit_testswas skipped on this PR, so the new pin has not been through the TPU smoke tests. - About 100 lines of
rollout.pyencode MaxText checkpoint-format knowledge that would be better owned by the MaxText loader.
One broader question: there is also the standalone eval entry point (eval_deepswe.py), which builds its own InprocessVllmSampler. With this PR the stock rollout node becomes a second evaluation path. Is the plan to keep both? If so, it would be good to make sure checkpoint loading does not end up maintained in two places.
Restore `requirements/maxtext_requirements.txt` and the deepswe_dist Dockerfile's `DEFAULT_MAXTEXT_COMMIT` to main's aee266d40071. Per review, the bump to 1bfed67f7f0f goes in separately (branch `sanbao/bump-maxtext-pin`) so TPU CI runs on it alone; this PR depends on that landing first.
- `_load_scanned_checkpoint` now requires `layout`; production always passes it, so the fallback that re-read `_scanned_checkpoint_layout` is removed. - `_create_inprocess_vllm_sampler` raises a ValueError naming the config keys before `sampler.initialize()` when the merged vLLM `additional_config` has no `maxtext_config` mapping, instead of a bare KeyError after the engine is built. Validated configs always have one (`scanned_checkpoint_path` requires a MaxText rollout, whose base `additional_config` carries `maxtext_config`, and `engine_kwargs` overrides must be mappings), so this guards the invariant.
Per review (r4689803839), the rollout node no longer encodes MaxText checkpoint-format knowledge. It calls `scanned_checkpoint_loader.resolve_scanned_checkpoint(path)` (file I/O only) before building the engine, so a bad path still fails before JAX or vLLM start, and `load_scanned_checkpoint(path, sampler, maxtext_config)` after `sampler.initialize()`. MaxText now finds the Orbax parameter directory, the OCDBT/Zarr3 storage flags, whether MoE gate/up are pre-fused, the TP for their re-layout, and `fp8_moe` itself. - Remove `_scanned_checkpoint_layout`, `_CHECKPOINT_PARAM_SUBDIRS` and `_load_scanned_checkpoint` (TP derivation, `fp8_moe` pop, storage merge). - Keep config validation, the pre-`initialize()` `maxtext_config` snapshot and its missing-config ValueError. - Drop the layout tests (now covered by MaxText's real-format tests) and the TP subtests; regenerate the `maxtext_scanned_eval` golden. Requires a MaxText pin that includes AI-Hypercomputer/maxtext#NNNN.
Add `cluster_config.pathways.rollout.persistence` (default false), mirroring `pathways.trainer.persistence`: `k8s.sh` sets `ENABLE_PATHWAYS_PERSISTENCE=1` on a `jobset.pathways.yaml` rollout when it is true. Orbax then reads a plain Zarr v2 `scanned_checkpoint_path` directly onto the TPU workers instead of staging the whole restore through the rollout container's memory, which OOM-killed a 120G container on a 397B checkpoint. It is opt-in because the persistence handler does not read OCDBT/Zarr3 checkpoints, and `roles.rollout.env` still rejects the variable.
- Drop the unreachable missing-`maxtext_config` check in `_create_inprocess_vllm_sampler` and snapshot `copy.deepcopy(additional["maxtext_config"])` directly. - Return string checkpoint paths as-is in `_optional_checkpoint_path` instead of stripping whitespace. - Pin the `copy.deepcopy` snapshot on a no-override subtest in `rollout_test.py`, fold `create_mesh` ordering into `calls`, drop the redundant fail-fast and missing-`maxtext_config` tests, and shrink the `maxtext.integration.vllm` `sys.modules` stubs in `rollout_test.py` and `constructor_goldens_test.py`. - Split and deduplicate `resolve_config_test.py` checkpoint accept/reject cases, and drop the `ENABLE_PATHWAYS_PERSISTENCE=0` assertion in `launch_test.py`.
Summary
With
weight_sync_config.mode: none(evaluation), a MaxText vLLM rollout had no way to get real weights: the resolver required Raiden weight sync. It can now load a checkpoint:vllm_config.engine_kwargs.additional_config.maxtext_config.load_parameters_path. vLLM'sMaxTextForCausalLMalready loads it, so only the resolver check changes.rollout_model_config.scanned_checkpoint_path. For aninprocess_vllmrollout, the node builds the engine on random weights (sampler.initialize()), then loads the checkpoint over them withmaxtext.integration.vllm.scanned_checkpoint_loader.load_scanned_checkpoint(AI-Hypercomputer/maxtext#6584). This happens beforeserve_worker, so the worker registers only once it serves the real weights.scanned_checkpoint_loader.resolve_scanned_checkpointchecks the path before engine initialization (file I/O only), so a bad path fails fast.items,defaultormodel_params), OCDBT/Zarr3 storage, pre-fused MoEwivswi_0/wi_1, and flat-cycledecoder.layers.layer_<i>vs nestedlocal_layers/global_layerblocks.additional_configis snapshotted beforesampler.initialize()soMaxTextForCausalLM's in-place rollout-padding mutations do not leak into themaxtext_configpassed to the loader.cluster_config.pathways.rollout.persistence(defaultfalse) makesk8s.shsetENABLE_PATHWAYS_PERSISTENCE=1on ajobset.pathways.yamlrollout, mirroringcluster_config.pathways.trainer.persistence. With it, Orbax'sCloudPathwaysArrayHandlerreads a plain Zarr v2 scanned checkpoint directly onto the TPU workers; without it, the whole restore is staged through the controller's host memory (on the 397B checkpoint this OOM-killed a 120G rollout container). It is opt-in because the persistence handler does not read OCDBT/Zarr3.resolve_configstill rejects the variable inroles.rollout.env; the error now points at both settings.load_scanned_checkpoint/resolve_scanned_checkpoint).The resolver changes (
resolve_config.py):weight_sync_config.mode: noneand one of the two checkpoint sources set (load_parameters_pathis also rejected when paired withmode: raiden). With neither, it is still rejected, and the error message now names both sources.scanned_checkpoint_pathis rejected, with one error that lists every problem, if:weight_sync_config.modeis notnone(e.g.raiden, which would replace the loaded weights),weight_sync_config.in_flight_weight_updatesistrue(partial_rolloutskips KV cache reallocation after loading), the rollout is notmodel_source: maxtextonrollout_engine: inprocess_vllm,vllm_config.init_with_random_weightsis explicitlyfalse, ormaxtext_config.load_parameters_pathis also set.scanned_checkpoint_pathset, a nullinit_with_random_weightsresolves totrue.engine_kwargsguard still rejectsscan_layers(and the other node-owned keys) inmaxtext_config. It is unchanged.Origin
This puts the worker-side checkpoint loading from #2504 (
deepswe_dist/eval_worker.pyonatwigg/mlperf, plus #2703) on the stock rollout node, minus the MLPerf-specific parts. The ported pieces are_METADATAstorage/pre-fused-MoE detection, composite-directory resolution, and loading the scanned checkpoint in memory; all three now live in MaxText'smaxtext.integration.vllm.scanned_checkpoint_loader(AI-Hypercomputer/maxtext#6497, layout detection in AI-Hypercomputer/maxtext#6584). Two behaviours change from #2504:getattrfallbacks.Data/expert parallelism and DP attention from #2579 already work through
rollout_model_config.meshandvllm_config.engine_kwargs.Merge notes
rollout.py,rollout_test.py,resolve_config.py,base_dist_config.yamland the rollout constructor goldens. Whichever PR lands second needs a small merge. The goldens should be regenerated rather than hand-merged.TPU verification
Run on TPU7x (96 GiB HBM per device) with a real
Qwen3.5-397B-A17BBF16 scanned checkpoint (396.35B params / 740.39 GiB, Zarr v2, pre-fused MoEwi, flat-cycledecoder.layers.layer_0..3). Stockrollout.main,weight_sync_config.mode=none+scanned_checkpoint_path,inprocess_vllm, EP=16, TP=1, with AI-Hypercomputer/maxtext#6584 andENABLE_PATHWAYS_PERSISTENCE=1. Per-device HBM was sampled fromjax.live_arrays()through observation-only wrappers, with no loader or model changes.Max live HBM per device (GiB):
2x2x4(16 chips / 32 devices), DP=2 + DP attention,hbm_utilization=0.842x2x2(8 chips / 16 devices), DP=1,0.842x2x2, DP=1,0.54sampler.initialize()(random weights + KV cache)delete_cache()from_pretrained)reinitialize_cache()/ after eval0.84the run-wide peak equals the configured cap.2x2x4. That is a lower bound: the stockrawchat parser does not stop at EOS, and 25 samples hit the 1024-token cap.Limitations
rollout_engine: inprocess_vllm. Thevllm(AsyncEngineArgs) engine runs vLLM out of process, so the node cannot reach its weights.Test plan
JAX_PLATFORMS=cpu python -m pytest tests/dist_rl/launch/resolve_config_test.py:cluster_config.pathways.rollout.persistencedefaults tofalse, is exported asK8S_ROLLOUT_ENABLE_PATHWAYS_PERSISTENCE, and must be a bool; unscanned and scanned sources are accepted with modenone;load_parameters_pathwithraidenand each invalidscanned_checkpoint_pathcombination (includingin_flight_weight_updates=Trueand whitespace-only paths) are rejected; the no-source rejection is unchanged.launch_test.py: ajobset.pathways.yamlrollout getsENABLE_PATHWAYS_PERSISTENCE=1only withcluster_config.pathways.rollout.persistence=true; other rollout templates ignore it.rollout_test.py:resolve_scanned_checkpointruns before the engine is built, so a bad path fails fast.initialize()runs beforeload_scanned_checkpoint, which gets the path, the sampler and the mergedmaxtext_config; in-placemaxtext_configmutations duringinitialize()do not leak into it.maxtext_configfails beforeinitialize().constructor_goldens_test.py: a newrollout/maxtext_scanned_eval.jsongolden (regenerated againstmain); the existing goldens are unchanged.python scripts/check_cl_complexity.py --strict --rev origin/main