Repository navigation
feat(training): add Primus CLI overrides, 405B pipeline layer split, and in-container HF token reads - #693
Conversation
…t flags Add train_params.primus_cli_overrides as a string or key/value map, and auto-append decoder first/last pipeline layer flags for Primus 405B from train_params.pipeline_parallelism when 126 layers do not divide evenly. An 8-node run with pipeline parallelism 4 gets 31/31. User-provided decoder split flags take precedence, and the test fails when no integer split exists.
…imus Megatron and Primus no longer embed the HF_TOKEN value in training, tokenizer-download, or job-launch commands. Each node reads paths.hf_token_file inside the container. If that file is missing, empty, or not mounted, Megatron fails the stage and later stages are skipped. Primus exports an empty HF_TOKEN and continues.
Security scan found no critical or high findings on lines changed by this pull requestView the security scan run for complete reports. “New” means the finding is located in a changed file on an added or modified line; it is not a base-versus-head findings delta. |
solaiys
left a comment
There was a problem hiding this comment.
No blocking issues. Combined 0.3.0 backport of the in-container HF token read (#676/#684) and Primus CLI overrides / 405B layer-split (#687).
-
Megatron
_hf_token_export_lineshlex.quotes the path and reads it on the node (tr -d '[:space:]' < file); a missing/empty fileexit 1s._require_hf_token_fileprobestest -sviaorch.exec(..., detailed=True)before tokenizer download and launch. On this branch that returns{host: {output, exit_code}}. Primus still exports emptyHF_TOKENand continues, as documented. Launch logs go throughredact_secrets.hf_tokenis dropped from the job ctors and the suite fixture. -
primus_cli_overrides(string or dict) is appended toprimus-cli direct. 405B auto-split usespipeline_stages=self.pipeline_parallelism, so PP=4 is 31/31 even on 8 nodes. User-provided decoder flags win; no integer splitfail_tests and raises. How-to, reference, and CHANGELOG match both behaviors.
Summary
Megatron and Primus no longer write the Hugging Face token value into tokenizer-download or job-launch commands. Each node reads
paths.hf_token_fileinside the container. If that file is missing, empty, or not mounted, Megatron fails the stage and later stages are skipped. Primus exports an emptyHF_TOKENand continues.Primus also accepts
train_params.primus_cli_overridesas a string or a JSON object. For Primus 405B, decoder first/last pipeline layer flags are derived fromtrain_params.pipeline_parallelism. An 8-node run with pipeline parallelism 4 gets 31/31. User-provided decoder split flags take precedence, and the test fails when no integer split exists.Motivation
The launch command and the per-node wrapper script were embedding
HF_TOKEN=<value>, so orchestrator logs and scripts on disk contained the token. This follows the same in-container read used for vLLM, SGLang, and JAX MaxText.Primus 405B has 126 decoder layers. Those layers are split across pipeline stages (
pipeline_model_parallel_size), not across nodes. When data parallelism makes the node count larger thanpipeline_parallelism, a node-count split is wrong. With pipeline parallelism 4 the first and last stages need 31 layers each.Technical Details
megatron_lib.pyandprimus_lib.pyreadpaths.hf_token_fileon the node at run time. The token value is not interpolated into the command. Job-launch logs pass throughredact_secrets.HF_TOKENand continues.cvs run. Thehf_tokenfixture and thehf_tokenargument are removed from the single-node and distributed stage functions.train_params.primus_cli_overridesis appended to the Primus command. A JSON object is rendered as--key valuepairs. The nine Megatron templates ship"primus_cli_overrides": {}.--decoder_first_pipeline_num_layersand--decoder_last_pipeline_num_layersare added only when 126 is not evenly divisible bypipeline_parallelism. Flags already set inprimus_cli_overridesare left unchanged.[0.3.0]changelog describe both behaviors.