Skip to content

Commit 376f2a7

Browse files
bhanutejagkBhanu Teja Goshikonda
andauthored
change: add image_uri_config for TensorFlow inference 2.20 and training 2.21 (#6230)
* change: add image_uri_config for TensorFlow inference 2.20 and training 2.21 Register the newly released SageMaker TensorFlow DLCs in tensorflow.json: * inference 2.20.0 -> tensorflow-inference:2.20.0-{cpu,gpu}-py312, plus the 2.20 minor alias * training 2.21.0 -> tensorflow-training:2.21.0-{cpu,gpu}-py312, plus the 2.21 minor alias Both are Python 3.12 / AL2023 builds, GPU variants on CUDA 12.9.1. The registry maps match the 38 regions already used by 2.19.0. Unlike earlier inference entries, 2.20.0 sets py_versions to ["py312"] because the published tags carry the Python suffix; the bare 2.20.0-cpu form used by 2.19 and earlier is not published for this release. Add tests/unit/image_uris/test_tensorflow.py, the first image-URI tests for the TensorFlow training and inference scopes, following the config-driven pattern used by test_vllm.py and test_sglang.py. * change: strengthen TensorFlow image_uri_config tests Address review feedback on the new TensorFlow image-URI tests: * Assert that the version covered by this file is the newest one registered in tensorflow.json, so adding a newer version fails with a message naming it. The previous membership check let a new version go silently uncovered. * Assert the new version's registry map against the previous release's rather than against its own entry. Reading the expected account out of the config under test meant a wrong account or a dropped region could never fail. * Cover the Python-version behaviour of the new inference entry: py312 is the only option for 2.20, and 2.19 still resolves to a tag with no py suffix. * Drop the incidental trailing newline added to tensorflow.json. * change: clarify TensorFlow image_uri_config test comments Correct the FULL_URI_REGIONS rationale: the registry map contains no ISO partition regions, and cn-north-1 is the only listed region with a non-default ECR domain. Narrow the REGISTRY_REFERENCE_VERSION comment to what the assertion actually guarantees. It catches a one-sided mistake in a new version's registry map, not a change applied to both versions, and it does not verify that the images are published in those regions. Also note that bumping it to the newly added version makes the account assertions tautological. Comments only; no assertions changed. --------- Co-authored-by: Bhanu Teja Goshikonda <bhanugk@amazon.com>
1 parent 18cb28c commit 376f2a7

2 files changed

Lines changed: 270 additions & 2 deletions

File tree

‎sagemaker-core/src/sagemaker/core/image_uri_config/tensorflow.json‎

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@
334334
"2.14": "2.14.1",
335335
"2.16": "2.16.1",
336336
"2.18": "2.18.0",
337-
"2.19": "2.19.0"
337+
"2.19": "2.19.0",
338+
"2.20": "2.20.0"
338339
},
339340
"versions": {
340341
"1.4.1": {
@@ -2515,6 +2516,52 @@
25152516
"us-west-2": "763104351884"
25162517
},
25172518
"repository": "tensorflow-inference"
2519+
},
2520+
"2.20.0": {
2521+
"py_versions": [
2522+
"py312"
2523+
],
2524+
"registries": {
2525+
"af-south-1": "626614931356",
2526+
"ap-east-1": "871362719292",
2527+
"ap-east-2": "975050140332",
2528+
"ap-northeast-1": "763104351884",
2529+
"ap-northeast-2": "763104351884",
2530+
"ap-northeast-3": "364406365360",
2531+
"ap-south-1": "763104351884",
2532+
"ap-south-2": "772153158452",
2533+
"ap-southeast-1": "763104351884",
2534+
"ap-southeast-2": "763104351884",
2535+
"ap-southeast-3": "907027046896",
2536+
"ap-southeast-4": "457447274322",
2537+
"ap-southeast-5": "550225433462",
2538+
"ap-southeast-6": "633930458069",
2539+
"ap-southeast-7": "590183813437",
2540+
"ca-central-1": "763104351884",
2541+
"ca-west-1": "204538143572",
2542+
"cn-north-1": "727897471807",
2543+
"cn-northwest-1": "727897471807",
2544+
"eu-central-1": "763104351884",
2545+
"eu-central-2": "380420809688",
2546+
"eu-north-1": "763104351884",
2547+
"eu-south-1": "692866216735",
2548+
"eu-south-2": "503227376785",
2549+
"eu-west-1": "763104351884",
2550+
"eu-west-2": "763104351884",
2551+
"eu-west-3": "763104351884",
2552+
"il-central-1": "780543022126",
2553+
"me-central-1": "914824155844",
2554+
"me-south-1": "217643126080",
2555+
"mx-central-1": "637423239942",
2556+
"sa-east-1": "763104351884",
2557+
"us-east-1": "763104351884",
2558+
"us-east-2": "763104351884",
2559+
"us-gov-east-1": "446045086412",
2560+
"us-gov-west-1": "442386744353",
2561+
"us-west-1": "763104351884",
2562+
"us-west-2": "763104351884"
2563+
},
2564+
"repository": "tensorflow-inference"
25182565
}
25192566
}
25202567
},
@@ -2820,7 +2867,8 @@
28202867
"2.14": "2.14.1",
28212868
"2.16": "2.16.2",
28222869
"2.18": "2.18.0",
2823-
"2.19": "2.19.0"
2870+
"2.19": "2.19.0",
2871+
"2.21": "2.21.0"
28242872
},
28252873
"versions": {
28262874
"1.4.1": {
@@ -5080,6 +5128,52 @@
50805128
"us-west-2": "763104351884"
50815129
},
50825130
"repository": "tensorflow-training"
5131+
},
5132+
"2.21.0": {
5133+
"py_versions": [
5134+
"py312"
5135+
],
5136+
"registries": {
5137+
"af-south-1": "626614931356",
5138+
"ap-east-1": "871362719292",
5139+
"ap-east-2": "975050140332",
5140+
"ap-northeast-1": "763104351884",
5141+
"ap-northeast-2": "763104351884",
5142+
"ap-northeast-3": "364406365360",
5143+
"ap-south-1": "763104351884",
5144+
"ap-south-2": "772153158452",
5145+
"ap-southeast-1": "763104351884",
5146+
"ap-southeast-2": "763104351884",
5147+
"ap-southeast-3": "907027046896",
5148+
"ap-southeast-4": "457447274322",
5149+
"ap-southeast-5": "550225433462",
5150+
"ap-southeast-6": "633930458069",
5151+
"ap-southeast-7": "590183813437",
5152+
"ca-central-1": "763104351884",
5153+
"ca-west-1": "204538143572",
5154+
"cn-north-1": "727897471807",
5155+
"cn-northwest-1": "727897471807",
5156+
"eu-central-1": "763104351884",
5157+
"eu-central-2": "380420809688",
5158+
"eu-north-1": "763104351884",
5159+
"eu-south-1": "692866216735",
5160+
"eu-south-2": "503227376785",
5161+
"eu-west-1": "763104351884",
5162+
"eu-west-2": "763104351884",
5163+
"eu-west-3": "763104351884",
5164+
"il-central-1": "780543022126",
5165+
"me-central-1": "914824155844",
5166+
"me-south-1": "217643126080",
5167+
"mx-central-1": "637423239942",
5168+
"sa-east-1": "763104351884",
5169+
"us-east-1": "763104351884",
5170+
"us-east-2": "763104351884",
5171+
"us-gov-east-1": "446045086412",
5172+
"us-gov-west-1": "442386744353",
5173+
"us-west-1": "763104351884",
5174+
"us-west-2": "763104351884"
5175+
},
5176+
"repository": "tensorflow-training"
50835177
}
50845178
}
50855179
}
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
13+
from __future__ import absolute_import
14+
15+
import pytest
16+
17+
from sagemaker.core import image_uris
18+
from sagemaker.core.common_utils import ALTERNATE_DOMAINS
19+
20+
GPU_INSTANCE = "ml.g5.2xlarge"
21+
CPU_INSTANCE = "ml.m5.xlarge"
22+
DEFAULT_DOMAIN = "amazonaws.com"
23+
24+
# Representative regions for the exact-URI assertions: three commercial, one China
25+
# (the only partition here with a non-default ECR domain) and one GovCloud. Every other
26+
# region is checked on account/region/repo/tag instead, which keeps the bulk of the
27+
# sweep independent of the host-suffix data in whichever botocore version is installed.
28+
FULL_URI_REGIONS = ["us-east-1", "us-west-2", "eu-west-1", "cn-north-1", "us-gov-west-1"]
29+
30+
# The newest TensorFlow version per scope, with the Python version baked into its tag.
31+
# Asserted below to be the *maximum* registered version, so adding a newer one to
32+
# tensorflow.json fails here until this mapping is updated deliberately.
33+
# tensorflow-inference:2.20.0-{cpu,gpu}-py312
34+
# tensorflow-training:2.21.0-{cpu,gpu}-py312
35+
LATEST = {
36+
"inference": ("2.20.0", "py312"),
37+
"training": ("2.21.0", "py312"),
38+
}
39+
40+
# The already-released version whose registry map a new version is expected to match.
41+
# This is the only account assertion in this file that is not derived from the entry it
42+
# checks, so it catches a one-sided mistake -- a typo in the new version's account, or a
43+
# dropped region -- which asserting against the new entry's own registries cannot. It
44+
# does not catch a change applied to both versions, and it says nothing about whether
45+
# the images are actually published in those regions.
46+
#
47+
# Keep this pointing at an older version. Bumping it to the newly added version makes
48+
# every account assertion in this file tautological again, silently.
49+
REGISTRY_REFERENCE_VERSION = "2.19.0"
50+
51+
52+
def _expected_repo(scope):
53+
return "tensorflow-inference" if scope == "inference" else "tensorflow-training"
54+
55+
56+
def _version_key(version):
57+
return tuple(int(part) for part in version.split("."))
58+
59+
60+
@pytest.mark.parametrize("scope", ["inference", "training"])
61+
@pytest.mark.parametrize("load_config", ["tensorflow.json"], indirect=True)
62+
def test_tensorflow_latest_version_is_registered(load_config, scope):
63+
"""The newest version in tensorflow.json is the one this file covers."""
64+
version, py_version = LATEST[scope]
65+
versions = load_config[scope]["versions"]
66+
assert version in versions, f"{version} missing from tensorflow.json {scope}"
67+
newest = max(versions, key=_version_key)
68+
assert newest == version, (
69+
f"tensorflow.json {scope} now registers {newest}, which this file does not cover. "
70+
f"Update LATEST in tests/unit/image_uris/test_tensorflow.py."
71+
)
72+
assert versions[version]["repository"] == _expected_repo(scope)
73+
assert versions[version]["py_versions"] == [py_version]
74+
assert load_config[scope]["processors"] == ["cpu", "gpu"]
75+
76+
77+
@pytest.mark.parametrize("scope", ["inference", "training"])
78+
@pytest.mark.parametrize("load_config", ["tensorflow.json"], indirect=True)
79+
def test_tensorflow_latest_version_registries_match_previous_release(load_config, scope):
80+
"""The newest version ships in the same regions and accounts as the previous release."""
81+
version, _ = LATEST[scope]
82+
versions = load_config[scope]["versions"]
83+
assert versions[version]["registries"] == versions[REGISTRY_REFERENCE_VERSION]["registries"]
84+
85+
86+
@pytest.mark.parametrize("scope", ["inference", "training"])
87+
@pytest.mark.parametrize("load_config", ["tensorflow.json"], indirect=True)
88+
def test_tensorflow_latest_version_uris(load_config, scope):
89+
"""Every (processor, region) for the newest version resolves to the expected tag."""
90+
version, py_version = LATEST[scope]
91+
version_config = load_config[scope]["versions"][version]
92+
repo = _expected_repo(scope)
93+
for processor, instance_type in (("cpu", CPU_INSTANCE), ("gpu", GPU_INSTANCE)):
94+
expected_tag = f"{version}-{processor}-{py_version}"
95+
for region, account in version_config["registries"].items():
96+
uri = image_uris.retrieve(
97+
framework="tensorflow",
98+
region=region,
99+
version=version,
100+
image_scope=scope,
101+
instance_type=instance_type,
102+
)
103+
assert uri.startswith(f"{account}.dkr.ecr.{region}."), uri
104+
assert uri.endswith(f"/{repo}:{expected_tag}"), uri
105+
106+
107+
@pytest.mark.parametrize("scope", ["inference", "training"])
108+
@pytest.mark.parametrize("load_config", ["tensorflow.json"], indirect=True)
109+
def test_tensorflow_latest_version_full_uri(load_config, scope):
110+
"""Exact URI (including domain) for representative commercial/China/GovCloud regions."""
111+
version, py_version = LATEST[scope]
112+
version_config = load_config[scope]["versions"][version]
113+
repo = _expected_repo(scope)
114+
for region in FULL_URI_REGIONS:
115+
account = version_config["registries"][region]
116+
domain = ALTERNATE_DOMAINS.get(region, DEFAULT_DOMAIN)
117+
for processor, instance_type in (("cpu", CPU_INSTANCE), ("gpu", GPU_INSTANCE)):
118+
uri = image_uris.retrieve(
119+
framework="tensorflow",
120+
region=region,
121+
version=version,
122+
image_scope=scope,
123+
instance_type=instance_type,
124+
)
125+
expected_tag = f"{version}-{processor}-{py_version}"
126+
assert uri == f"{account}.dkr.ecr.{region}.{domain}/{repo}:{expected_tag}"
127+
128+
129+
@pytest.mark.parametrize("scope", ["inference", "training"])
130+
@pytest.mark.parametrize("load_config", ["tensorflow.json"], indirect=True)
131+
def test_tensorflow_minor_alias_resolves_to_newest_patch(load_config, scope):
132+
"""The minor alias (2.20 / 2.21) points at its newest patch and keeps the py suffix."""
133+
version, py_version = LATEST[scope]
134+
alias = version.rsplit(".", 1)[0]
135+
assert load_config[scope]["version_aliases"][alias] == version
136+
for processor, instance_type in (("cpu", CPU_INSTANCE), ("gpu", GPU_INSTANCE)):
137+
uri = image_uris.retrieve(
138+
framework="tensorflow",
139+
region="us-west-2",
140+
version=alias,
141+
image_scope=scope,
142+
instance_type=instance_type,
143+
)
144+
# The alias is used verbatim as the tag prefix, matching the published
145+
# `<minor>-<processor>-py312` tags.
146+
assert uri.endswith(f"/{_expected_repo(scope)}:{alias}-{processor}-{py_version}"), uri
147+
148+
149+
@pytest.mark.parametrize("scope", ["inference", "training"])
150+
def test_tensorflow_latest_version_rejects_other_python_versions(scope):
151+
"""Only py312 is offered for the newest version, so any other py_version is an error."""
152+
version, _ = LATEST[scope]
153+
with pytest.raises(ValueError) as error:
154+
image_uris.retrieve(
155+
framework="tensorflow",
156+
region="us-west-2",
157+
version=version,
158+
py_version="py310",
159+
image_scope=scope,
160+
instance_type=CPU_INSTANCE,
161+
)
162+
assert "Unsupported Python version: py310." in str(error.value)
163+
164+
165+
def test_tensorflow_inference_2_19_keeps_tag_without_python_version():
166+
"""2.19 and earlier inference images have no py suffix; adding 2.20 must not change that."""
167+
uri = image_uris.retrieve(
168+
framework="tensorflow",
169+
region="us-west-2",
170+
version="2.19.0",
171+
image_scope="inference",
172+
instance_type=CPU_INSTANCE,
173+
)
174+
assert uri.endswith("/tensorflow-inference:2.19.0-cpu"), uri

0 commit comments

Comments
 (0)