fix(args): skip Megatron validate_args for external SGLang server#1674
Open
surega21 wants to merge 1 commit into
Open
fix(args): skip Megatron validate_args for external SGLang server#1674surega21 wants to merge 1 commit into
surega21 wants to merge 1 commit into
Conversation
When --sglang-router-ip is set and --rollout-num-gpus is 0, rollout runs against a long-lived remote SGLang server and no local rollout GPUs are allocated. Megatron's validate_args reads CUDA device properties, so it crashes on CPU-only pods that have no NVIDIA driver. Gate megatron_validate_args and the varlen/pipeline-parallel rewrites on a new is_external_model_server(args) helper so external-server eval runs skip the block. Regular training and colocated-eval runs are unaffected. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces the is_external_model_server helper function to determine if the rollout runs against an external SGLang model server, allowing Megatron argument validation to be skipped on CPU-only pods. The review feedback suggests using getattr to safely access rollout_num_gpus to prevent potential AttributeErrors when args is a mock or custom namespace.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
surega21
marked this pull request as ready for review
July 14, 2026 22:50
surega21
requested review from
Shi-Dong,
Zhichenzzz,
fzyzcjy,
guapisolo,
jybsuper,
maocheng23 and
yueming-yuan
as code owners
July 14, 2026 22:50
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.
Summary
is_external_model_server(args)predicate that returnsTruewhen--sglang-router-ipis set and--rollout-num-gpus == 0.megatron_validate_args(and the associated varlen / pipeline-parallel rewrites) onnot is_external_model_server(args).Why
When rollout runs against an external SGLang model server, no local rollout GPUs are allocated.
megatron_validate_argsreads CUDA device properties duringparse_args, which crashes on CPU-only pods that have no NVIDIA driver — this fails eval jobs before any rollout starts.Skipping the Megatron block for external-server mode is safe because local Megatron isn't initialized in that path.
miles_validate_argsandsglang_validate_argsstill run for external-server evals.Assumptions
sglang_router_ip is not Noneandrollout_num_gpus == 0. Setting only one of the two keeps the existing validation path.variable_seq_lengths = True,allgather → alltoallrewrite, and thepipeline_model_parallel_size == 1decoder assertion) only applies when local Megatron is initialized, which does not happen for external-server rollouts.Risks
Low. Regular training and colocated-eval runs (both
sglang_router_ip is Noneorrollout_num_gpus > 0) hit the unchanged code path.Validation
python3 train.py --sglang-router-ip <remote> --rollout-num-gpus 0 ...no longer tripsmegatron_validate_argsatparse_argstime.False).pre-commit run --files miles/utils/arguments.pyclean.