Model merger success path lacks a terminal Hugging Face output check
Model merger success path lacks a terminal Hugging Face output check
System Info
- Repository:
verl-project/verl - Current main checked:
bc72e38e - Model-merger baseline tested:
7fbc00a9 - Python: 3.11.6
- PyTorch: 2.12.0+cu130
- Transformers: 5.8.1
- Accelerate: 1.13.0
- Ray: 2.55.1
- Platform: Linux
The two commits between the tested baseline and current main do not change verl/model_merger or its tests.
Current behavior
BaseModelMerger.save_hf_model_and_tokenizer() calls model.save_pretrained(), saves processor/tokenizer files, and returns without checking the final target directory. The Megatron path similarly writes distributed shards and metadata without a terminal output check.
A standard Transformers model normally writes its weights. This issue is about making the model merger's final artifact contract explicit, including for pluggable/custom model implementations and future serialization-path changes.
A focused regression substitutes a model whose save_pretrained() returns normally after writing config.json but no weights. On unpatched main, the merger does not raise:
Failed: DID NOT RAISE <class 'RuntimeError'>
The target can therefore contain config.json and tokenizer files but no model.safetensors, pytorch_model.bin, or complete sharded-weight layout. Code that treats a normal merger return as proof of a complete Hugging Face artifact has no final postcondition to rely on.
Expected behavior
Before reporting success or uploading the result, the merger should fail clearly unless the target contains:
- a non-empty, parseable
config.json; and - either a non-empty standard single weight file, or a standard weight index whose referenced shards all exist and are non-empty.
The same filesystem-level check should apply:
- after the common FSDP/single-process save path; and
- on Megatron rank 0 after all distributed shards and metadata have been written.
This check should not load model tensors or change parameter merging, key conversion, dtype, sharding, LoRA behavior, CLI arguments, or public function signatures.
Proposed fix
#7193 adds a shared terminal validator and focused CPU coverage for accepted single-file/sharded layouts and rejected incomplete layouts. Validation completed with:
- 12 focused CPU tests;
- the full pre-commit suite;
- a tiny FSDP checkpoint merged through the
verl.model_mergerCLI; and - a Transformers load and forward pass on the merged output.
Related work
- #7068 changes serialization compatibility to prevent exported-key corruption; it does not validate the completed artifact.
- #4770 normalizes PEFT keys and exports LoRA metadata; it does not validate full-model output completeness.
I opened #7193 after validating the missing terminal output check against current main (bc72e38e).
The focused regression models a normal-returning custom save_pretrained() implementation that writes configuration/tokenizer files but no weights. The unpatched merger accepts that output; the patched path fails with an actionable error. Validation also passed 12 focused CPU tests, the full pre-commit suite, and a tiny FSDP CLI merge followed by a Transformers load and forward pass.