Skip to content

fix(args): skip Megatron validate_args for external SGLang server#1674

Open
surega21 wants to merge 1 commit into
radixark:mainfrom
GymPod:skip-megatron-validate-external-model-server
Open

fix(args): skip Megatron validate_args for external SGLang server#1674
surega21 wants to merge 1 commit into
radixark:mainfrom
GymPod:skip-megatron-validate-external-model-server

Conversation

@surega21

Copy link
Copy Markdown

Summary

  • Add is_external_model_server(args) predicate that returns True when --sglang-router-ip is set and --rollout-num-gpus == 0.
  • Gate megatron_validate_args (and the associated varlen / pipeline-parallel rewrites) on not is_external_model_server(args).

Why

When rollout runs against an external SGLang model server, no local rollout GPUs are allocated. megatron_validate_args reads CUDA device properties during parse_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_args and sglang_validate_args still run for external-server evals.

Assumptions

  • External-server mode is identified by the combination of sglang_router_ip is not None and rollout_num_gpus == 0. Setting only one of the two keeps the existing validation path.
  • The skipped block (Megatron validation, variable_seq_lengths = True, allgather → alltoall rewrite, and the pipeline_model_parallel_size == 1 decoder 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 None or rollout_num_gpus > 0) hit the unchanged code path.

Validation

  • python3 train.py --sglang-router-ip <remote> --rollout-num-gpus 0 ... no longer trips megatron_validate_args at parse_args time.
  • Regular Megatron training runs unaffected (predicate returns False).
  • pre-commit run --files miles/utils/arguments.py clean.

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>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread miles/utils/arguments.py
@surega21
surega21 marked this pull request as ready for review July 14, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant