Skip to content

[Fix] Restore vLLM rollout topology - #2017

Merged
YanhuiDua merged 1 commit into
InternLM:mainfrom
YanhuiDua:fix-vllm-topology
Sep 8, 2026
Merged

YanhuiDua merged 1 commit into
InternLM:mainfrom
YanhuiDua:fix-vllm-topology

Conversation

@YanhuiDua

Copy link
Copy Markdown
Collaborator

No description provided.

@YanhuiDua
YanhuiDua force-pushed the fix-vllm-topology branch 2 times, most recently from 76c4758 to 08424ca Compare September 4, 2026 11:23
@YanhuiDua

Copy link
Copy Markdown
Collaborator Author

@claude review

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Claude:

Summary

本 PR 恢复了 vLLMWorker.build_rollout_topology,把 topology refactor 后遗留的 NotImplementedError 替换为按 engine 切分 rank/bundle、每个 engine 启动一个 vLLM API server 的实现。整体结构与 LMDeploy/SGLang 后端保持一致,但 engine 规模的取值口径与 vLLM 实际启动参数不匹配,且缺少对应单测。

ProduceBatchResult impact: not affected
RoutedExperts impact: not affected
Ray concurrency impact: not affected

Main Flowchart after this PR

flowchart TD
    A["RolloutController._initialize_worker_ports_and_build_rollout_topology"] --> B["vLLMWorker.build_rollout_topology<br/>(本次新增实现)"]
    B --> C{"num_gpus_per_engine<br/>= ep &gt; 1 ? ep : tp"}
    C --> D["按 num_gpus_per_engine 切分<br/>engine_ranks / engine_bundle_idxs"]
    D --> E["RolloutEngine + 单个 RolloutServerProcess<br/>weight_update_ranks = engine_ranks"]
    E --> F["RolloutTopology.server_launch_specs()"]
    F --> G["worker.init(launch_spec)"]
    G --> H["VLLM_RAY_BUNDLE_INDICES<br/>+ tp = tensor_parallel_size // dp<br/>enable_expert_parallel = False"]
    G --> I["VLLMIPCBackendAdapter<br/>rollout_tp = tensor_parallel_size"]

    style B fill:#cfe8ff,stroke:#1a73e8
    style C fill:#ffd6d6,stroke:#d93025
    style H fill:#ffe8cc,stroke:#e8710a
    style I fill:#ffe8cc,stroke:#e8710a
Loading

核心原理实现与单测

核心行为是「把 (rank, bundle_idx) 列表切分为逻辑 engine,并为每个 engine 生成一个 request entrypoint + weight-update endpoint 的 server process」。实现路径与 RolloutTopology 的校验契约(engine rank 不重叠、bundle 不复用、weight_update_ranks 完整覆盖 engine_ranks)兼容。

但该实现目前没有任何单测覆盖tests/rl/test_rollout_logic.py::TestRolloutTopologyAPI 通过 public classmethod 覆盖了 LMDeployWorker(TP16/EP16)与 SGLangWorker(跨节点 TP16),唯独缺少 vLLM 用例,tests/ 下也完全没有引用 vllm 模块。

抽象与信息隐藏评估

  • Warningxtuner/v1/rl/rollout/vllm.py:139-174:engine 切分与整除校验(含逐字相同的错误信息)已是第三份复制,与 lmdeploy.py:160-183sglang.py:129-172 重复,规则未集中在一处,后续修改需三处同步。

单测建议

  • Warningtests/rl/test_rollout_logic.py::TestRolloutTopologyAPI:本次恢复的核心行为缺少真实代码路径覆盖,建议按同类后端的写法补一个 vLLM 用例(engine 切分结果 + 非整除时的 ValueError)。

其他 Issues

  • Warningxtuner/v1/rl/rollout/vllm.py:147:engine 规模取 config.num_gpus_per_engine(优先 expert_parallel_size),而 vLLM 侧固定 enable_expert_parallel = False 且只按 tensor_parallel_size 启动 worker,expert_parallel_size > 1 时会造成 bundle 超额分配与 IPC weight update 的 rank 数不匹配。

Verdict

REQUEST_CHANGES

Comment thread xtuner/v1/rl/rollout/vllm.py Outdated
Comment thread xtuner/v1/rl/rollout/vllm.py
Comment thread xtuner/v1/rl/rollout/vllm.py
@YanhuiDua
YanhuiDua merged commit 12bc73d into InternLM:main Sep 8, 2026
8 checks passed
@YanhuiDua
YanhuiDua deleted the fix-vllm-topology branch September 8, 2026 07:54
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.

2 participants