From a3d9bac77966941b9ab5ab56b66e9077fafadeb7 Mon Sep 17 00:00:00 2001 From: LeoBorcherding Date: Mon, 11 May 2026 03:32:40 -0500 Subject: [PATCH] =?UTF-8?q?fix(rocm/win):=20auto-stub=20missing=20torch.di?= =?UTF-8?q?stributed=20attrs=20(Store,=20ProcessGroup,=20=E2=80=A6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- studio/backend/core/training/worker.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/studio/backend/core/training/worker.py b/studio/backend/core/training/worker.py index 4593873383..785125e9d7 100644 --- a/studio/backend/core/training/worker.py +++ b/studio/backend/core/training/worker.py @@ -1129,10 +1129,30 @@ def run_training_process( for _name, _stub in _td_stubs.items(): if not hasattr(_td, _name): setattr(_td, _name, _stub) + # ROCm Windows wheels omit C-extension-backed distributed classes + # (Store, ProcessGroup, …). Auto-stub any missing attribute so + # torch._dynamo's fake_pg class definitions don't crash at import time. + if not hasattr(_td, "__getattr__"): + def _td_getattr(_attr): + if _attr.startswith("__"): + raise AttributeError(_attr) + _cls = type(_attr, (), {"__init__": lambda self, *a, **kw: None}) + setattr(_td, _attr, _cls) + return _cls + _td.__getattr__ = _td_getattr except Exception: _td_mock = _types.ModuleType("torch.distributed") for _name, _stub in _td_stubs.items(): setattr(_td_mock, _name, _stub) + + def _td_mock_getattr(_attr): + if _attr.startswith("__"): + raise AttributeError(_attr) + _cls = type(_attr, (), {"__init__": lambda self, *a, **kw: None}) + setattr(_td_mock, _attr, _cls) + return _cls + + _td_mock.__getattr__ = _td_mock_getattr sys.modules["torch.distributed"] = _td_mock if "torch._C._distributed_c10d" not in sys.modules: _c10d_fb = _types.ModuleType("torch._C._distributed_c10d")