{
  "id": "pytorch/nccl-timeout-during-allreduce",
  "signature": "RuntimeError: [torch.distributed] AllReduce timed out in rank 0 (timeout: 600)",
  "signature_zh": "运行时错误：[torch.distributed] 排名 0 上的 AllReduce 超时（超时时间：600）",
  "regex": "AllReduce timed out in rank \\d+ \\(timeout: \\d+\\)",
  "domain": "pytorch",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "NCCL allreduce operation timed out due to network congestion, a slow or crashed worker, or mismatched NCCL versions across nodes.",
  "root_cause_type": "generic",
  "root_cause_zh": "NCCL allreduce 操作由于网络拥塞、工作节点缓慢或崩溃、或节点间 NCCL 版本不匹配而超时。",
  "versions": [
    {
      "version": "pytorch>=2.1.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nccl>=2.18.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "If the underlying issue (e.g., network congestion or slow node) persists, the operation will still fail after the longer timeout.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The network issue is likely persistent; a restart only resets the state temporarily.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "While logging helps diagnosis, it does not resolve the timeout itself.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Check network connectivity between all nodes using `nccl-tests` or `ping`. Ensure all nodes can communicate on the required ports (e.g., 29500). Then set `NCCL_SOCKET_IFNAME=eth0` to specify the correct network interface.",
      "success_rate": 0.85,
      "how": "Check network connectivity between all nodes using `nccl-tests` or `ping`. Ensure all nodes can communicate on the required ports (e.g., 29500). Then set `NCCL_SOCKET_IFNAME=eth0` to specify the correct network interface.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Reduce the batch size or model size to lower communication volume, or use gradient accumulation to decrease allreduce frequency.",
      "success_rate": 0.75,
      "how": "Reduce the batch size or model size to lower communication volume, or use gradient accumulation to decrease allreduce frequency.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Switch to Gloo backend for allreduce if NCCL is problematic: `torch.distributed.init_process_group(backend='gloo', ...)`. Note: Gloo may be slower but more stable on certain networks.",
      "success_rate": 0.8,
      "how": "Switch to Gloo backend for allreduce if NCCL is problematic: `torch.distributed.init_process_group(backend='gloo', ...)`. Note: Gloo may be slower but more stable on certain networks.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "使用 `nccl-tests` 或 `ping` 检查所有节点之间的网络连接。确保所有节点可以在所需端口（例如 29500）上通信。然后设置 `NCCL_SOCKET_IFNAME=eth0` 以指定正确的网络接口。",
    "减小批量大小或模型大小以降低通信量，或使用梯度累积减少 allreduce 频率。",
    "如果 NCCL 有问题，切换到 Gloo 后端进行 allreduce：`torch.distributed.init_process_group(backend='gloo', ...)`。注意：Gloo 可能较慢但在某些网络上更稳定。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://pytorch.org/docs/stable/distributed.html#troubleshooting",
  "official_doc_section": null,
  "error_code": "2",
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}