Repository navigation
refactor(dtensor): delete the DTensor v1 native checkpoint implementation - #4273
Conversation
|
/ok to test 468fd41 |
|
/ok to test 6984ed8 |
yuki-97
left a comment
There was a problem hiding this comment.
Self-review via /review-pr-team: 3 agents (rl-expert/automodel, bug-finder + test-agent, devil's advocate).
Verdict — no findings above the confidence bar. LGTM, no action needed.
Verified clean
- No dangling references to
nemo_rl.utils.native_checkpointorsave_tokenizer_on_rank0anywhere (docs are autodoc2-generated, so no hand-kept API list). nemo_rl/models/automodel/convert.pyhas no direct or transitivenemo_automodelimport (both parent__init__.pyfiles are license-only), so it still runs under--extra mcore.- Dropping the
endswith("/model")branch is safe: every caller'sweights_pathcomes fromget_resume_pathsoros.path.join(..., "policy"|"value", "weights"). It also removes a save/load asymmetry, since Automodel'sCheckpointer.save_modelalways writes<weights_path>/model. test_converter_roundtrip.pyconverts an Automodel DTensor checkpoint and compares against the original HF model atrtol=atol=1e-5, and runs in both L1 and Lfast (run_test fastinL1_Functional_Tests_Other_1.sh), which is stronger than the deleted unit test.TestSaveTokenizerOnRank0keeps its assertions. The newautomodelmarker still runs it inL0_Unit_Tests_Automodel.sh, and the dropped routing test is covered bytest_save_with_tokenizer_skipped_on_non_zero_rank.
Generated by Claude Code
6984ed8 to
a5c367b
Compare
|
/ok to test a5c367b |
terrykong
left a comment
There was a problem hiding this comment.
Reviewed with /review-pr-team (rl-expert, expert-automodel, test-agent, comment-reviewer, bug-finder, design-reviewer, devil-advocate).
Clean deletion. The moves are in the right places: convert.py under models/automodel/ keeps the converter free of nemo_automodel, so it still runs under --extra mcore, and the rank-0 tokenizer guard now sits next to its only caller. We found no remaining reference to native_checkpoint, and no code, config or doc in the repo passes a path ending in /model, so dropping the endswith("/model") branch is safe. fast_L1_Functional_Tests_Other_1, which runs the converter roundtrip, passed at this head; the L0 jobs were still pending when we looked.
Two inline comments, both on convert.py: the unclear error a v0.7 v1-checkpoint user now hits (with a test), and the docstring for the new model/ path rule.
A small suggestion that does not need to block this PR: add a line to convert.py's module docstring saying it must not import nemo_automodel, so the next editor knows why the file is separate. Today only the --extra mcore functional test catches that.
Not run: pre-commit (this reviewer's host cannot build the linux-only lock); CI lint passed at this head.
Generated by Claude Code
Signed-off-by: Yuki Huang <[email protected]>
…into its own module Signed-off-by: Yuki Huang <[email protected]>
…pointManager Signed-off-by: Yuki Huang <[email protected]>
…tion Signed-off-by: Yuki Huang <[email protected]>
…oading Signed-off-by: Yuki Huang <[email protected]>
Signed-off-by: Yuki Huang <[email protected]>
a5c367b to
498d828
Compare
… shards Signed-off-by: Yuki Huang <[email protected]>
…overrides Signed-off-by: Yuki Huang <[email protected]>
|
/ok to test bb0b8cf |
What does this PR do ?
Deletes
nemo_rl/utils/native_checkpoint.py. It was the DTensor v1 worker's own DCP save/load layer; v1 was removed in #4198, soModelState,OptimizerState,save_checkpointandload_checkpointhave had zero production callers since. Automodel goes throughAutomodelCheckpointManager->nemo_automodel'sCheckpointer, Megatron throughmegatron.bridge.training.checkpointing.What changed
The two functions in that file that were still alive move to where they belong:
convert_dcp_to_hf-> newnemo_rl/models/automodel/convert.py. Deliberately notmodels/automodel/checkpoint.py: that module importsnemo_automodelat the top level, and the offline converter must keep running in any venv --tests/functional/test_converters.shinvokes it underuv run --extra mcore, and the documenteduv run examples/converters/convert_dcp_to_hf.pywould otherwise require theautomodelextra, which[tool.uv] conflictsmakes mutually exclusive withmcore/vllm/trtllm/sglang.save_tokenizer_on_rank0->AutomodelCheckpointManager._save_tokenizer_on_rank0(staticmethod). Its only caller was that class'ssave_checkpoint, and the guard exists precisely because we passtokenizer=Nonetosave_model()and so bypass nemo_automodel's own rank-0 guard.Also drops the v1 checkpoint layout from
convert_dcp_to_hfand theweights_path.endswith("/model")tolerance inAutomodelCheckpointManager.load_checkpoint. Automodel's layout is fixed at<ckpt_dir>/model; no caller in the repo passes a path ending in/model, and theendswithbranch could never have matched a real v1 path anyway (v1 wrote the shards flat in<ckpt_dir>).Tests
TestSaveTokenizerOnRank0moves totests/unit/models/automodel/test_automodel_checkpoint.py, next toTestAutomodelCheckpointManager.test_convert_dcp_to_hfis deleted rather than moved:convert_dcp_to_hfis already covered bytests/functional/test_converter_roundtrip.py, which runs in both L1 and Lfast (L1_Functional_Tests_Other_1.shinvokestest_converters.shwith thefasttag, so it is not skipped whenFAST=1). That test converts a DTensor DCP checkpoint and compares the result against the original HF model withassert_state_dicts_equalatrtol=atol=1e-5-- strictly stronger than the deleted unit test, which only asserted the converted weights differed from the original. The unit test was itself deselected in FAST mode for being slow (~62-114s), so its--deselectentry inexcluded_unit_tests.shgoes too.pyrefly.toml:nemo_rl/utils/native_checkpoint.pydrops out ofproject-includes,nemo_rl/models/automodel/convert.pygoes in.🤖 Generated with Claude Code