Skip to content

feat: add --sglang-config YAML for engine group configuration #1614

Merged
zhuzilin merged 14 commits intomainfrom
zhuzilin/sglang-config-v2
Feb 26, 2026
Merged

feat: add --sglang-config YAML for engine group configuration #1614
zhuzilin merged 14 commits intomainfrom
zhuzilin/sglang-config-v2

Conversation

@zhuzilin
Copy link
Contributor

No description provided.

Add --sglang-config argument that accepts a YAML file to configure
engine groups with explicit roles and GPU counts, including support
for placeholder groups that reserve GPU slots without creating
engines (useful for NUMA alignment or GPU gaps between model parts).

Configuration priority:
1. --sglang-config YAML with explicit engine_groups
2. --prefill-num-servers (legacy PD disaggregation)
3. Default single "regular" group

New dataclasses:
- EngineGroupConfig: per-group role + num_gpus + overrides
- SglangConfig: list of groups with factory methods + from_yaml

Key changes:
- start_rollout_server() uses config-driven loop with cumulative
  GPU offset for rank calculation, all groups start concurrently
- RolloutServer.active_engine_groups filters out placeholders
- Health monitors, engine aggregation, offload/onload skip placeholders
- _start_router() accepts has_pd_disaggregation kwarg
- Per-engine-group sglang ServerArgs overrides via YAML "overrides" dict
  threaded through EngineGroup -> SGLangEngine -> _compute_server_args
- Mutual exclusion: --sglang-config vs --rollout-external and
  --sglang-config vs --prefill-num-servers

Example YAML:
  engine_groups:
    - role: prefill
      num_gpus: 4
      overrides:
        mem_fraction_static: 0.9
    - role: decode
      num_gpus: 10
      overrides:
        mem_fraction_static: 0.7
@zhuzilin zhuzilin force-pushed the zhuzilin/sglang-config-v2 branch from bac171c to 2d18f92 Compare February 25, 2026 03:31
@zhuzilin zhuzilin force-pushed the zhuzilin/sglang-config-v2 branch from 16e2c44 to 51e18dc Compare February 25, 2026 05:20
…s_per_engine

Support serving multiple models via --sglang-config YAML, each with its
own router and engine groups. Engine groups within a model may have
different num_gpus_per_engine (e.g. PD disaggregation with prefill TP=2
and decode TP=4).

Key changes:
- rollout.py: New ModelConfig/SglangConfig with models list. EngineGroup
  now carries per-group num_gpus_per_engine, gpu_offset, router_ip/port.
  RolloutManager.servers is now a dict[str, RolloutServer]. Each model
  gets its own router via _start_router(force_new=True).
- sglang_engine.py: SGLangEngine accepts per-engine num_gpus_per_engine
  and per-engine router_ip/port, forwarded to _compute_server_args.
- Weight updates (Megatron and FSDP): engine_gpu_counts flows through
  actor -> weight_updater -> connect_rollout_engines_from_distributed,
  supporting heterogeneous NCCL world_size and rank offsets.
- Backward compatible: legacy engine_groups-only YAML still works as a
  single default model. Single-model callers use the .server property.
- Megatron UpdateWeightFromTensor: move Gloo group creation from __init__
  to connect_rollout_engines where engine_gpu_counts is available; compute
  colocate_engine_nums via cumulative GPU budget; use cumulative offsets
  for engine mapping instead of uniform stride.
- FSDP UpdateWeightFromTensor: same cumulative offset fix for IPC groups.
- Remove stale 'assume gpu id same' comments.
@zhuzilin zhuzilin merged commit da7080f into main Feb 26, 2026
23 of 29 checks passed
@zhuzilin zhuzilin deleted the zhuzilin/sglang-config-v2 branch February 26, 2026 00:47
@CSWYF3634076
Copy link

Hello, is this PR for PD disaggregation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants