Skip to content

Commit f565adb

Browse files
yaoyu-33cuichenx
andauthored
[training] fix: use startswith for Blackwell GPU name validation in DeepEP (#2731)
Signed-off-by: Yu Yao <yaoyu.094@gmail.com> Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com> Signed-off-by: Chen Cui <chcui@nvidia.com> Co-authored-by: Chen Cui <chcui@nvidia.com>
1 parent 94a90b2 commit f565adb

3 files changed

Lines changed: 38 additions & 17 deletions

File tree

‎src/megatron/bridge/training/flex_dispatcher_backend.py‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@ def apply_flex_dispatcher_backend(
4545

4646
device_properties = torch.cuda.get_device_properties(0)
4747
if moe_flex_dispatcher_backend == "deepep":
48-
if not (device_properties.major in [8, 9] or device_properties.name in ["NVIDIA B200", "NVIDIA B300"]):
48+
if not (
49+
device_properties.major in [8, 9] or device_properties.name.startswith(("NVIDIA B200", "NVIDIA B300"))
50+
):
4951
if get_rank_safe() == 0:
5052
logger.warning(
51-
"DeepEP is only applicable to Ampere, Hopper, and Blackwell (only B200 and B300) GPUs. Skipping DeepEP configuration."
53+
f"DeepEP is only applicable to Ampere, Hopper, and Blackwell (B200/B300) GPUs. "
54+
f"Current GPU: {device_properties.name}. Skipping DeepEP configuration."
5255
)
5356
return
5457
elif moe_flex_dispatcher_backend == "hybridep":
@@ -74,8 +77,13 @@ def validate_flex_dispatcher_backend(model_config: TransformerConfig) -> None:
7477
if model_config.moe_token_dispatcher_type == "flex":
7578
device_properties = torch.cuda.get_device_properties(0)
7679
if model_config.moe_flex_dispatcher_backend == "deepep":
77-
if not (device_properties.major in (8, 9) or device_properties.name in ["NVIDIA B200", "NVIDIA B300"]):
78-
raise ValueError("DeepEP is supported for Ampere, Hopper, and Blackwell (only B200 and B300) GPUs")
80+
if not (
81+
device_properties.major in (8, 9) or device_properties.name.startswith(("NVIDIA B200", "NVIDIA B300"))
82+
):
83+
raise ValueError(
84+
f"DeepEP is supported for Ampere, Hopper, and Blackwell (B200/B300) GPUs. "
85+
f"Current GPU: {device_properties.name}"
86+
)
7987

8088
if model_config.moe_flex_dispatcher_backend == "hybridep":
8189
if not device_properties.major in [8, 9, 10]:

‎tests/unit_tests/training/test_config.py‎

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,25 +1035,34 @@ def test_context_parallel_finetuning_validations(
10351035
restore_get_world_size_safe(og_ws, cfg_mod)
10361036

10371037
@pytest.mark.parametrize(
1038-
"gpu_major, moe_enable_deepep, expect_error",
1038+
"gpu_major, gpu_name, moe_enable_deepep, expect_error",
10391039
[
1040-
(8, True, False), # Ampere GPU with DeepEP enabled - should pass
1041-
(9, True, False), # Hopper GPU with DeepEP enabled - should pass
1042-
(7, True, True), # Volta GPU with DeepEP enabled - should raise ValueError
1043-
(6, True, True), # Pascal GPU with DeepEP enabled - should raise ValueError
1044-
(10, True, True), # Future unsupported GPU with DeepEP enabled - should raise ValueError
1045-
(7, False, False), # Volta GPU with DeepEP disabled - should pass
1046-
(6, False, False), # Pascal GPU with DeepEP disabled - should pass
1040+
(8, "NVIDIA A100", True, False), # Ampere GPU with DeepEP enabled - should pass
1041+
(9, "NVIDIA H100", True, False), # Hopper GPU with DeepEP enabled - should pass
1042+
(10, "NVIDIA B200", True, False), # Blackwell B200 GPU with DeepEP enabled - should pass
1043+
(10, "NVIDIA B200 SXM6 AC", True, False), # Blackwell B200 variant with DeepEP enabled - should pass
1044+
(10, "NVIDIA B300", True, False), # Blackwell B300 GPU with DeepEP enabled - should pass
1045+
(7, "NVIDIA V100", True, True), # Volta GPU with DeepEP enabled - should raise ValueError
1046+
(6, "NVIDIA P100", True, True), # Pascal GPU with DeepEP enabled - should raise ValueError
1047+
(
1048+
10,
1049+
"NVIDIA B100",
1050+
True,
1051+
True,
1052+
), # Unsupported Blackwell variant with DeepEP enabled - should raise ValueError
1053+
(7, "NVIDIA V100", False, False), # Volta GPU with DeepEP disabled - should pass
1054+
(6, "NVIDIA P100", False, False), # Pascal GPU with DeepEP disabled - should pass
10471055
],
10481056
)
10491057
@patch("torch.cuda.get_device_properties")
10501058
def test_deepep_validation(
1051-
self, mock_get_device_properties, monkeypatch, gpu_major, moe_enable_deepep, expect_error
1059+
self, mock_get_device_properties, monkeypatch, gpu_major, gpu_name, moe_enable_deepep, expect_error
10521060
):
10531061
"""Test DeepEP validation during config container validation."""
10541062
# Mock GPU device properties
10551063
mock_properties = MagicMock()
10561064
mock_properties.major = gpu_major
1065+
mock_properties.name = gpu_name
10571066
mock_get_device_properties.return_value = mock_properties
10581067

10591068
# Create a GPT model config with MoE settings
@@ -1069,7 +1078,7 @@ def test_deepep_validation(
10691078

10701079
try:
10711080
if expect_error:
1072-
with pytest.raises(ValueError, match="DeepEP is supported for Ampere"):
1081+
with pytest.raises(ValueError, match="DeepEP is supported for Ampere, Hopper, and Blackwell"):
10731082
container.validate()
10741083
else:
10751084
container.validate() # Should pass without error

‎tests/unit_tests/training/test_deepep.py‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def test_apply_flex_dispatcher_backend_warns_for_unsupported_gpu_volta(
133133
# Mock Volta GPU (compute capability 7.x)
134134
mock_properties = MagicMock()
135135
mock_properties.major = 7
136+
mock_properties.name = "NVIDIA V100"
136137
mock_get_device_properties.return_value = mock_properties
137138

138139
# Create a mock TransformerConfig with MoE enabled
@@ -145,7 +146,7 @@ def test_apply_flex_dispatcher_backend_warns_for_unsupported_gpu_volta(
145146
# Verify warning was logged
146147
mock_logger.warning.assert_called_once()
147148
assert (
148-
"DeepEP is only applicable to Ampere, Hopper, and Blackwell (only B200 and B300) GPUs"
149+
"DeepEP is only applicable to Ampere, Hopper, and Blackwell (B200/B300) GPUs"
149150
in mock_logger.warning.call_args[0][0]
150151
)
151152

@@ -162,6 +163,7 @@ def test_apply_flex_dispatcher_backend_warns_for_unsupported_gpu_pascal(
162163
# Mock Pascal GPU (compute capability 6.x)
163164
mock_properties = MagicMock()
164165
mock_properties.major = 6
166+
mock_properties.name = "NVIDIA P100"
165167
mock_get_device_properties.return_value = mock_properties
166168

167169
# Create a mock TransformerConfig with MoE enabled
@@ -174,7 +176,7 @@ def test_apply_flex_dispatcher_backend_warns_for_unsupported_gpu_pascal(
174176
# Verify warning was logged
175177
mock_logger.warning.assert_called_once()
176178
assert (
177-
"DeepEP is only applicable to Ampere, Hopper, and Blackwell (only B200 and B300) GPUs"
179+
"DeepEP is only applicable to Ampere, Hopper, and Blackwell (B200/B300) GPUs"
178180
in mock_logger.warning.call_args[0][0]
179181
)
180182

@@ -249,6 +251,7 @@ def test_validate_flex_dispatcher_backend_volta_gpu_raises_error(self, mock_get_
249251
# Mock Volta GPU (compute capability 7.x)
250252
mock_properties = MagicMock()
251253
mock_properties.major = 7
254+
mock_properties.name = "NVIDIA V100"
252255
mock_get_device_properties.return_value = mock_properties
253256

254257
# Create a mock TransformerConfig with DeepEP enabled
@@ -259,7 +262,7 @@ def test_validate_flex_dispatcher_backend_volta_gpu_raises_error(self, mock_get_
259262
# Should raise ValueError
260263
with pytest.raises(
261264
ValueError,
262-
match="DeepEP is supported for Ampere, Hopper, and Blackwell \\(only B200 and B300\\) GPUs",
265+
match="DeepEP is supported for Ampere, Hopper, and Blackwell \\(B200/B300\\) GPUs",
263266
):
264267
validate_flex_dispatcher_backend(config)
265268

@@ -272,6 +275,7 @@ def test_validate_flex_dispatcher_backend_future_gpu_raises_error(self, mock_get
272275
# Mock future GPU
273276
mock_properties = MagicMock()
274277
mock_properties.major = 200
278+
mock_properties.name = "NVIDIA Future GPU"
275279
mock_get_device_properties.return_value = mock_properties
276280

277281
# Create a mock TransformerConfig with DeepEP enabled

0 commit comments

Comments
 (0)