diff --git a/studio/backend/utils/hardware/hardware.py b/studio/backend/utils/hardware/hardware.py index f75c7a9d12..d0fe3822b5 100644 --- a/studio/backend/utils/hardware/hardware.py +++ b/studio/backend/utils/hardware/hardware.py @@ -958,6 +958,7 @@ def _determine_attention_impl_for_gpu_estimate(config) -> str: ("is_available", lambda: False), ("get_rank", lambda: 0), ("get_world_size", lambda: 1), + ("is_torchelastic_launched", lambda: False), ): if not hasattr(_td, _attr): setattr(_td, _attr, _stub) diff --git a/tests/studio/install/test_rocm_support.py b/tests/studio/install/test_rocm_support.py index a917820255..5824fbd784 100644 --- a/tests/studio/install/test_rocm_support.py +++ b/tests/studio/install/test_rocm_support.py @@ -846,6 +846,28 @@ class TestHardwareRocmFlag: assert '"cuda"' in func_body assert '"rocm"' in func_body + def test_distributed_stubs_cover_is_torchelastic_launched(self): + """_determine_attention_impl_for_gpu_estimate must stub is_torchelastic_launched. + + resolve_attention_implementation calls is_torchelastic_launched() on + Windows ROCm where torch.distributed ships without that helper, causing + a warning: 'module torch.distributed has no attribute is_torchelastic_launched'. + """ + hw_path = ( + PACKAGE_ROOT / "studio" / "backend" / "utils" / "hardware" / "hardware.py" + ) + source = hw_path.read_text(encoding = "utf-8") + assert "is_torchelastic_launched" in source + + def test_distributed_stubs_cover_core_helpers(self): + """_determine_attention_impl_for_gpu_estimate must stub the four core distributed helpers.""" + hw_path = ( + PACKAGE_ROOT / "studio" / "backend" / "utils" / "hardware" / "hardware.py" + ) + source = hw_path.read_text(encoding = "utf-8") + for attr in ("is_initialized", "is_available", "get_rank", "get_world_size"): + assert attr in source, f"distributed stub for '{attr}' missing from hardware.py" + # ============================================================================= # TEST: tokenizer_utils.py -- error message