SGLang multi-node: auto-negotiated dist_init port can collide with pre-allocated engine ports

未关闭
#7 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
python

调研方向

从 angelspec/inference/factory.py 中的 _prepare_sgl_engines 开始,同时阅读 Step 2 和 Step 2.5,然后跟踪 SglEngine.init,以确认 port 和 dist_init_addr 的分配方式。确保在 multi-node SGLang 路径中,自动协商的 dist-init 端口不会与预先分配的 engine 端口重叠,尤其是在默认值从 10000 开始时。

由索引模型根据 Issue 内容生成。

描述

In _prepare_sgl_engines (angelspec/inference/factory.py), Step 2 picks a free port for dist_init_addr starting from the default start_port=10000:

https://github.com/Tencent/AngelSpec/blob/main/angelspec/inference/factory.py#L288-L295

ip, port = ray.get(
    [head_engine.get_node_ip.remote(), head_engine.find_free_port.remote()],
    timeout=120,
)

find_free_port only probes ports; it never reserves them. Step 2.5 then restarts its sequential allocation at the literal next_start = 10000 without accounting for the port just handed out:

https://github.com/Tencent/AngelSpec/blob/main/angelspec/inference/factory.py#L297-L309

next_start = 10000
for i in range(num_engines):
    port = ray.get(engines[i].find_free_port.remote(start_port=next_start, consecutive=2), ...)
    pre_allocated_ports[i] = port
    next_start = port + 2

On a fresh node, Step 2 returns 10000 and Step 2.5 immediately hands engine 0 (which is the replica-0 head on the same node) ports 10000/10001. SglEngine.init then sets port=10000, nccl_port=10001, and dist_init_addr="<same-ip>:10000" — the head node is told to bind its server port and its dist-init TCPStore on the same port. The Step 2.5 comment says "allocate sequentially so engines on the same node never collide", but the Step 2 allocation is invisible to that sequencer.

The vLLM path avoids this by reusing the head's pre-allocated port as the dist-init port rather than drawing a second untracked port. Possible fixes: allocate the dist-init port from the same sequential allocator (e.g. run Step 2 after Step 2.5 using next_start, or advance next_start past the negotiated dist-init port). Only affects sglang_nnodes > 1 with auto-negotiated addr.

主要语言
Python
星标
460
派生
40
平均合并
1 小时 4 分钟
30 天内合并 PR
4

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Tencent/AngelSpec 的其他 Issue

查看 Tencent/AngelSpec 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。