Skip to content

Commit 493dafa

Browse files
authored
Skip fp16-config tests on accelerators without fp16 support (#8398)
## Problem `TestMultipleModels::test_zero_optimizer`, `TestSimpleMoE`, `TestMoE`, `TestPRMoE`, and `TestMOETensorParallel` hardcode `"fp16": {"enabled": True}` in their DeepSpeed configs. The engine's sanity check then raises: ``` ValueError: Type fp16 is not supported on your device. ``` on any accelerator whose `is_fp16_supported()` is false. On CPU that maps to the AVX512-FP16 capability of the host, and GitHub's `ubuntu-24.04` runners are hardware-heterogeneous: **the same test passes on one runner and fails on the next** (observed directly in #8381 — 146 failures appeared on one runner generation and none on another, with identical code). ## Change Skip these tests via a capability query: ```python @pytest.mark.skipif(not get_accelerator().is_fp16_supported(), reason="fp16 is not supported on this accelerator") ``` - capability only, no accelerator-name matching; - mirrors the existing bf16 skip precedent in `tests/unit/v1/zero/test_zero_user_backward.py`; - deliberately a **skip** rather than silently running bf16 — these tests exist to cover the fp16 paths. ## Validation Validated as part of the multi-rank CPU CI experiment in #8381: the 146 hardware-lottery failures became deterministic skips, zero regressions on previously-passing tests. Signed-off-by: Guokai Ma <guokai.ma@intel.com>
1 parent e74c707 commit 493dafa

3 files changed

Lines changed: 6 additions & 0 deletions

File tree

tests/unit/runtime/test_multiple_models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import deepspeed
88
import deepspeed.comm as dist
99
import torch
10+
from deepspeed import get_accelerator
1011
from unit.common import DistributedTest
1112
from unit.simple_model import SimpleModel, random_dataloader
1213

@@ -76,6 +77,7 @@ class TestMultipleModels(DistributedTest):
7677
@pytest.mark.parametrize('fp32_grad_accum', [False, True])
7778
@pytest.mark.parametrize('contiguous_gradients', [False, True])
7879
@pytest.mark.parametrize('overlap_comm', [False, True])
80+
@pytest.mark.skipif(not get_accelerator().is_fp16_supported(), reason="fp16 is not supported on this accelerator")
7981
def test_zero_optimizer(self, num_models, shared_loss, zero_stage, fp32_grad_accum, contiguous_gradients,
8082
overlap_comm):
8183
config_dict = {

tests/unit/v1/moe/test_moe.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
class TestSimpleMoE(DistributedTest):
2525
world_size = 2
2626

27+
@pytest.mark.skipif(not get_accelerator().is_fp16_supported(), reason="fp16 is not supported on this accelerator")
2728
def test(self, zero_stage):
2829
if not required_torch_version(min_version=1.8):
2930
pytest.skip("DeepSpeed MoE tests need torch 1.8 or higher to run correctly")
@@ -66,6 +67,7 @@ def test(self, zero_stage):
6667
class TestMoE(DistributedTest):
6768
world_size = 4
6869

70+
@pytest.mark.skipif(not get_accelerator().is_fp16_supported(), reason="fp16 is not supported on this accelerator")
6971
def test(self, ep_size, zero_stage, use_residual):
7072
if not required_torch_version(min_version=1.8):
7173
pytest.skip("DeepSpeed MoE tests need torch 1.8 or higher to run correctly")
@@ -164,6 +166,7 @@ def strict_narrow(dim, start, length):
164166
class TestPRMoE(DistributedTest):
165167
world_size = 4
166168

169+
@pytest.mark.skipif(not get_accelerator().is_fp16_supported(), reason="fp16 is not supported on this accelerator")
167170
def test(self, ep_size, use_residual):
168171
if not required_torch_version(min_version=1.8):
169172
pytest.skip("DeepSpeed MoE tests need torch 1.8 or higher to run correctly")

tests/unit/v1/moe/test_moe_tp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def get_model_parallel_group(self):
5757
class TestMOETensorParallel(DistributedTest):
5858
world_size = 4
5959

60+
@pytest.mark.skipif(not get_accelerator().is_fp16_supported(), reason="fp16 is not supported on this accelerator")
6061
def test(self, ep_size, tp_size, enable_expert_tp, use_residual):
6162
# TODO: replace this with a true parallel mlp in the future
6263
# and run convergence tests

0 commit comments

Comments
 (0)