[BUG] Flaky CPU unit tests: port 29500 EADDRINUSE from hardcoded MASTER_PORT colliding with xdist port ranges

オープン
#9,103 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@ArchanaChetan07 がすでに取り組んでいます。

2026年11月19日 から。

  • #9123 @ArchanaChetan07 による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
67/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, pytorch

調査の方向性

Start with tests/unit/runtime/zero/test_zero_grad_clip.py and tests/unit/utils/test_groups.py, then compare the re-initialization with the file-store example in test_world_destroy_releases_sequence_parallel_groups. Check the port setup in tests/unit/checkpoint/test_affine_transfer_executor_external_group.py too. Run the affected tests with pytest -n 4; done means these tests avoid port collisions under xdist and pass together.

索引モデルが issue の本文から書いたものです。

説明

Describe the bug

cpu-torch-latest failed once on #8966 with an unrelated test:

FAILED unit/utils/test_groups.py::TestGroupCacheTeardown::test_default_destroy_releases_cached_groups[True]
torch.distributed.DistNetworkError: The server socket has failed to listen on any local network address. port: 29500, useIpv6: false, code: -98, name: EADDRINUSE, message: address already in use

Run: https://github.com/deepspeedai/DeepSpeed/actions/runs/44087089094/job/134062944114 (1 failed, 3795 passed). The [False] case passed a few seconds later in the same job.

Cause

Two tests used TCP port 29500 at the same time, on different xdist workers:

  1. tests/unit/runtime/zero/test_zero_grad_clip.py hardcodes os.environ['MASTER_PORT'] = '29500' and initializes through env://. Worker gw1 started it at 13:14:08 and held the port until 13:14:56.
  2. On worker gw0, get_master_port() returned 29500 for test_default_destroy_releases_cached_groups[True] at 13:14:04, because gw0's range starts at 29500 and the port was free. get_master_port() only binds the port briefly to check that it is free; the first init of this test uses a file store, so nothing kept the port reserved. After destroying the process group, the test re-initializes with dist.init_distributed(dist_backend="gloo"), without init_method, so it falls back to env:// and opens a TCPStore on MASTER_PORT=29500. By then gw1 held the port.

The failure needs both tests to overlap in time and gw0 to get the bottom of its range, so it is rare. Across the failed cpu-torch-latest, mps and modal jobs of the past month whose logs are still available (110 CPU jobs), this is the only EADDRINUSE.

Other tests with the same risk

  • tests/unit/checkpoint/test_affine_transfer_executor_external_group.py builds its TCPStore on 29000 + os.getpid() % 1000, which overlaps gw0's range (29500–30499).
  • tests/accelerator/test_ds_init.py hardcodes MASTER_PORT=8088. It is outside the unit suite, so it is lower risk.
  • Several DistributedTests with init_distributed = False initialize through env:// on the harness port, for example in test_hybrid_engine_rollout.py and comm/test_dist.py. They are safe unless a hardcoded port collides with them, because get_master_port() only checks the port and does not hold it until use.

Suggested fix

  • test_zero_grad_clip.py: use get_master_port() instead of '29500'.
  • test_groups.py: re-initialize with a file:// store, as test_world_destroy_releases_sequence_parallel_groups in the same class already does.
  • test_affine_transfer_executor_external_group.py: take the port from get_master_port(), or use a FileStore.

Optionally, keep hardcoded ports out of the xdist ranges, or add a lint check for literal MASTER_PORT values under tests/unit.

Environment: GitHub-hosted CPU runner, pytest -n 4.

This analysis was prepared with AI assistance (GitHub Copilot CLI) from the CI log and the test sources.

主要言語
Python
スター
43.3k
フォーク
5.1k
平均マージ
5日 10時間
マージ済み PR(30日)
85

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

deepspeedai/DeepSpeed のほかの issue

deepspeedai/DeepSpeed の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。