Skip to content

Commit 61213e9

Browse files
cj-zhangJoseph Zhang
andauthored
fix: add g7e, p6-b200 and trn2 to volume size unsupported instance families (#6505)
* fix: add g7e, p6-b200 and trn2 to volume size unsupported instance families --- X-AI-Prompt: Add g7e, p6-b200, and trn2 to volume size unsupported instances X-AI-Tool: Claude * style: apply black formatting to sagemaker-core and sagemaker-serve unit tests --- X-AI-Prompt: Run formatters and fix issues X-AI-Tool: Claude --------- Co-authored-by: Joseph Zhang <cjz@amazon.com>
1 parent d75056d commit 61213e9

5 files changed

Lines changed: 27 additions & 17 deletions

File tree

‎sagemaker-core/src/sagemaker/core/common_utils.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,10 +1645,10 @@ def volume_size_supported(instance_type: str) -> bool:
16451645
raise ValueError(f"Failed to parse instance type '{instance_type}'")
16461646

16471647
# Any instance type with a "d" in the instance family (i.e. c5d, p4d, etc)
1648-
# + g5 or g6 or p5 does not support attaching an EBS volume.
1648+
# + g5, g6, g7e, p5, p6-b200, trn1 or trn2 does not support attaching an EBS volume.
16491649
family = parts[0]
16501650

1651-
unsupported_families = ["g5", "g6", "p5", "trn1"]
1651+
unsupported_families = ["g5", "g6", "g7e", "p5", "p6-b200", "trn1", "trn2"]
16521652

16531653
return "d" not in family and not any(
16541654
family.startswith(prefix) for prefix in unsupported_families

‎sagemaker-core/tests/unit/local/test_entities.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,9 @@ def test_wait_custom_timeout(self, mock_sleep, mock_get_host, mock_perform_reque
762762
@patch("sagemaker.core.local.entities._perform_request")
763763
@patch("sagemaker.core.local.entities.get_docker_host")
764764
@patch("time.sleep")
765-
def test_wait_uses_default_timeout_constant(self, mock_sleep, mock_get_host, mock_perform_request):
765+
def test_wait_uses_default_timeout_constant(
766+
self, mock_sleep, mock_get_host, mock_perform_request
767+
):
766768
"""Test that _wait_for_serving_container defaults to HEALTH_CHECK_TIMEOUT_LIMIT"""
767769
mock_get_host.return_value = "localhost"
768770
# Succeed on first attempt so we can verify it was called

‎sagemaker-core/tests/unit/test_common_utils.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,16 @@ def test_volume_size_supported_g5(self):
11001100

11011101
assert volume_size_supported("ml.g5.xlarge") is False
11021102

1103+
@pytest.mark.parametrize(
1104+
"instance_type",
1105+
["ml.g7e.2xlarge", "ml.p6-b200.48xlarge", "ml.trn2.48xlarge"],
1106+
)
1107+
def test_volume_size_supported_unsupported_families(self, instance_type):
1108+
"""Test g7e, p6-b200 and trn2 instances."""
1109+
from sagemaker.core.common_utils import volume_size_supported
1110+
1111+
assert volume_size_supported(instance_type) is False
1112+
11031113
def test_volume_size_supported_local(self):
11041114
"""Test local mode."""
11051115
from sagemaker.core.common_utils import volume_size_supported

‎sagemaker-serve/tests/unit/conftest.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
the suite three times (py310/py311/py312) and these failures almost always hit
2727
only one of the three.
2828
"""
29+
2930
from __future__ import annotations
3031

3132
from contextlib import ExitStack

‎sagemaker-serve/tests/unit/test_jumpstart_default_instance_type.py‎

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ def _load_fixture_spec_dict():
3535
# Exclude ml.m5.large (the buggy code's hardcoded fallback) from the
3636
# supported list so membership assertions discriminate red from green.
3737
spec["supported_inference_instance_types"] = [_FIXTURE_DEFAULT_INSTANCE_TYPE] + [
38-
t
39-
for t in spec.get("supported_inference_instance_types", [])
40-
if t != "ml.m5.large"
38+
t for t in spec.get("supported_inference_instance_types", []) if t != "ml.m5.large"
4139
]
4240
return spec
4341

@@ -50,7 +48,6 @@ def _get_fixture_spec(*args, **kwargs):
5048
return JumpStartModelSpecs(_load_fixture_spec_dict())
5149

5250

53-
5451
def _mock_session():
5552
"""Mock sagemaker session following the package's shared-setup convention."""
5653
mock_session = Mock()
@@ -122,14 +119,14 @@ def spy(self):
122119
with patch.object(ModelBuilder, "_get_default_instance_type", spy):
123120
_build_jumpstart_builder()
124121

125-
self.assertTrue(seen.get("has_region"), "self.region missing during instance-type detection")
122+
self.assertTrue(
123+
seen.get("has_region"), "self.region missing during instance-type detection"
124+
)
126125
self.assertEqual(seen.get("region"), "us-west-2")
127126

128127
def test_user_provided_instance_type_wins_and_skips_lookup(self):
129128
"""Explicit instance_type must be honored without consulting the spec."""
130-
builder, get_deploy_kwargs_mock = _build_jumpstart_builder(
131-
instance_type="ml.p5.48xlarge"
132-
)
129+
builder, get_deploy_kwargs_mock = _build_jumpstart_builder(instance_type="ml.p5.48xlarge")
133130

134131
self.assertEqual(builder.instance_type, "ml.p5.48xlarge")
135132
self.assertTrue(builder._user_provided_instance_type)
@@ -157,9 +154,9 @@ def test_deploy_passes_spec_default_to_internal_deploy(self):
157154
builder, _ = _build_jumpstart_builder()
158155
builder.built_model = Mock()
159156

160-
with patch.object(ModelBuilder, "_is_model_customization", return_value=False), patch.object(
161-
ModelBuilder, "_deploy", return_value=Mock()
162-
) as mock_deploy:
157+
with patch.object(
158+
ModelBuilder, "_is_model_customization", return_value=False
159+
), patch.object(ModelBuilder, "_deploy", return_value=Mock()) as mock_deploy:
163160
builder.deploy(endpoint_name="test-endpoint")
164161

165162
mock_deploy.assert_called_once()
@@ -265,9 +262,9 @@ def test_deploy_passes_user_override_to_internal_deploy(self):
265262
builder, _ = _build_jumpstart_builder(instance_type=self.USER_INSTANCE_TYPE)
266263
builder.built_model = Mock()
267264

268-
with patch.object(ModelBuilder, "_is_model_customization", return_value=False), patch.object(
269-
ModelBuilder, "_deploy", return_value=Mock()
270-
) as mock_deploy:
265+
with patch.object(
266+
ModelBuilder, "_is_model_customization", return_value=False
267+
), patch.object(ModelBuilder, "_deploy", return_value=Mock()) as mock_deploy:
271268
builder.deploy(endpoint_name="test-endpoint")
272269

273270
mock_deploy.assert_called_once()

0 commit comments

Comments
 (0)