Skip to content

Commit 9175390

Browse files
nvda-mesharmaoandreeva-nvnv-kmcgill53
authored
build: update build.py to pass versions as input parameter and convert version map to dictionary (#7500)
Co-authored-by: Olga Andreeva <124622579+oandreeva-nv@users.noreply.github.com> Co-authored-by: Kyle McGill <101670481+nv-kmcgill53@users.noreply.github.com>
1 parent b06d1b0 commit 9175390

File tree

1 file changed

+83
-55
lines changed

1 file changed

+83
-55
lines changed

build.py

Lines changed: 83 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
# information.
5050
#
5151
# The TRITON_VERSION file indicates the Triton version and
52-
# TRITON_VERSION_MAP is used to determine the corresponding container
52+
# DEFAULT_TRITON_VERSION_MAP is used to determine the corresponding container
5353
# version and upstream container version (upstream containers are
5454
# dependencies required by Triton). These versions may be overridden.
5555

@@ -69,17 +69,17 @@
6969
# different versions are used then one backend or the other will
7070
# incorrectly load the other version of the openvino libraries.
7171
#
72-
TRITON_VERSION_MAP = {
73-
"2.53.0dev": (
74-
"24.12dev", # triton container
75-
"24.10", # upstream container
76-
"1.19.2", # ORT
77-
"2024.4.0", # ORT OpenVINO
78-
"2024.4.0", # Standalone OpenVINO
79-
"3.2.6", # DCGM version
80-
"0.5.5", # vLLM version
81-
"3.12.3", # RHEL Python version
82-
)
72+
73+
DEFAULT_TRITON_VERSION_MAP = {
74+
"release_version": "2.53.0dev",
75+
"triton_container_version": "24.12dev",
76+
"upstream_container_version": "24.10",
77+
"ort_version": "1.19.2",
78+
"ort_openvino_version": "2024.4.0",
79+
"standalone_openvino_version": "2024.4.0",
80+
"dcgm_version": "3.2.6",
81+
"vllm_version": "0.5.5",
82+
"rhel_py_version": "3.12.3",
8383
}
8484

8585
CORE_BACKENDS = ["ensemble"]
@@ -142,13 +142,9 @@ def target_machine():
142142

143143
def container_versions(version, container_version, upstream_container_version):
144144
if container_version is None:
145-
if version not in TRITON_VERSION_MAP:
146-
fail("container version not known for {}".format(version))
147-
container_version = TRITON_VERSION_MAP[version][0]
145+
container_version = FLAGS.triton_container_version
148146
if upstream_container_version is None:
149-
if version not in TRITON_VERSION_MAP:
150-
fail("upstream container version not known for {}".format(version))
151-
upstream_container_version = TRITON_VERSION_MAP[version][1]
147+
upstream_container_version = FLAGS.upstream_container_version
152148
return container_version, upstream_container_version
153149

154150

@@ -665,7 +661,7 @@ def onnxruntime_cmake_args(images, library_paths):
665661
None,
666662
os.getenv("TRITON_BUILD_ONNXRUNTIME_VERSION")
667663
if os.getenv("TRITON_BUILD_ONNXRUNTIME_VERSION")
668-
else TRITON_VERSION_MAP[FLAGS.version][2],
664+
else FLAGS.ort_version,
669665
)
670666
]
671667

@@ -701,15 +697,15 @@ def onnxruntime_cmake_args(images, library_paths):
701697
"onnxruntime",
702698
"TRITON_BUILD_CONTAINER_VERSION",
703699
None,
704-
TRITON_VERSION_MAP[FLAGS.version][1],
700+
FLAGS.triton_container_version,
705701
)
706702
)
707703

708704
# TODO: TPRD-333 OpenVino extension is not currently supported by our manylinux build
709705
if (
710706
(target_machine() != "aarch64")
711707
and (target_platform() != "rhel")
712-
and (TRITON_VERSION_MAP[FLAGS.version][3] is not None)
708+
and (FLAGS.ort_openvino_version is not None)
713709
):
714710
cargs.append(
715711
cmake_backend_enable(
@@ -721,7 +717,7 @@ def onnxruntime_cmake_args(images, library_paths):
721717
"onnxruntime",
722718
"TRITON_BUILD_ONNXRUNTIME_OPENVINO_VERSION",
723719
None,
724-
TRITON_VERSION_MAP[FLAGS.version][3],
720+
FLAGS.ort_openvino_version,
725721
)
726722
)
727723

@@ -744,7 +740,7 @@ def openvino_cmake_args():
744740
"openvino",
745741
"TRITON_BUILD_OPENVINO_VERSION",
746742
None,
747-
TRITON_VERSION_MAP[FLAGS.version][4],
743+
FLAGS.standalone_openvino_version,
748744
)
749745
]
750746
if target_platform() == "windows":
@@ -767,7 +763,7 @@ def openvino_cmake_args():
767763
"openvino",
768764
"TRITON_BUILD_CONTAINER_VERSION",
769765
None,
770-
TRITON_VERSION_MAP[FLAGS.version][1],
766+
FLAGS.upstream_container_version,
771767
)
772768
)
773769
return cargs
@@ -822,7 +818,7 @@ def fil_cmake_args(images):
822818
"fil",
823819
"TRITON_BUILD_CONTAINER_VERSION",
824820
None,
825-
TRITON_VERSION_MAP[FLAGS.version][1],
821+
FLAGS.upstream_container_version,
826822
)
827823
)
828824

@@ -968,7 +964,7 @@ def create_dockerfile_buildbase_rhel(ddir, dockerfile_name, argmap):
968964
wget
969965
"""
970966
# Requires openssl-devel to be installed first for pyenv build to be successful
971-
df += change_default_python_version_rhel(TRITON_VERSION_MAP[FLAGS.version][7])
967+
df += change_default_python_version_rhel(FLAGS.rhel_py_version)
972968
df += """
973969
974970
RUN pip3 install --upgrade pip \\
@@ -1230,7 +1226,6 @@ def create_dockerfile_linux(
12301226
LABEL com.amazonaws.sagemaker.capabilities.multi-models=true
12311227
COPY --chown=1000:1000 docker/sagemaker/serve /usr/bin/.
12321228
"""
1233-
12341229
# This is required since libcublasLt.so is not present during the build
12351230
# stage of the PyTorch backend
12361231
if not FLAGS.enable_gpu and ("pytorch" in backends):
@@ -1414,9 +1409,7 @@ def dockerfile_prepare_container_linux(argmap, backends, enable_gpu, target_mach
14141409
readline-devel
14151410
"""
14161411
# Requires openssl-devel to be installed first for pyenv build to be successful
1417-
df += change_default_python_version_rhel(
1418-
TRITON_VERSION_MAP[FLAGS.version][7]
1419-
)
1412+
df += change_default_python_version_rhel(FLAGS.rhel_py_version)
14201413
df += """
14211414
RUN pip3 install --upgrade pip \\
14221415
&& pip3 install --upgrade \\
@@ -1455,7 +1448,7 @@ def dockerfile_prepare_container_linux(argmap, backends, enable_gpu, target_mach
14551448
# vLLM needed for vLLM backend
14561449
RUN pip3 install vllm=={}
14571450
""".format(
1458-
TRITON_VERSION_MAP[FLAGS.version][6]
1451+
FLAGS.vllm_version
14591452
)
14601453

14611454
if "dali" in backends:
@@ -1487,7 +1480,6 @@ def dockerfile_prepare_container_linux(argmap, backends, enable_gpu, target_mach
14871480
""".format(
14881481
argmap["NVIDIA_BUILD_ID"], argmap["NVIDIA_BUILD_ID"], argmap["NVIDIA_BUILD_REF"]
14891482
)
1490-
14911483
return df
14921484

14931485

@@ -1647,9 +1639,7 @@ def create_build_dockerfiles(
16471639
"TRITON_VERSION": FLAGS.version,
16481640
"TRITON_CONTAINER_VERSION": FLAGS.container_version,
16491641
"BASE_IMAGE": base_image,
1650-
"DCGM_VERSION": ""
1651-
if FLAGS.version is None or FLAGS.version not in TRITON_VERSION_MAP
1652-
else TRITON_VERSION_MAP[FLAGS.version][5],
1642+
"DCGM_VERSION": FLAGS.dcgm_version,
16531643
}
16541644

16551645
# For CPU-only image we need to copy some cuda libraries and dependencies
@@ -2027,9 +2017,7 @@ def backend_build(
20272017
# installed within the container will not be picked up by the python backend stub process pybind
20282018
# bindings. It must instead must be installed via pyenv. We package it here for better usability.
20292019
if target_platform() == "rhel" and be == "python":
2030-
major_minor_version = ".".join(
2031-
(TRITON_VERSION_MAP[FLAGS.version][7]).split(".")[:2]
2032-
)
2020+
major_minor_version = ".".join((FLAGS.rhel_py_version).split(".")[:2])
20332021
version_matched_files = "/usr/lib64/libpython" + major_minor_version + "*"
20342022
cmake_script.cp(
20352023
version_matched_files, os.path.join(repo_install_dir, "backends", be)
@@ -2479,12 +2467,6 @@ def enable_all():
24792467
required=False,
24802468
help="The Triton container version to build. If not specified the container version will be chosen automatically based on --version value.",
24812469
)
2482-
parser.add_argument(
2483-
"--upstream-container-version",
2484-
type=str,
2485-
required=False,
2486-
help="The upstream container version to use for the build. If not specified the upstream container version will be chosen automatically based on --version value.",
2487-
)
24882470
parser.add_argument(
24892471
"--container-prebuild-command",
24902472
type=str,
@@ -2632,7 +2614,60 @@ def enable_all():
26322614
required=False,
26332615
help="Override specified backend CMake argument in the build as <backend>:<name>=<value>. The argument is passed to CMake as -D<name>=<value>. This flag only impacts CMake arguments that are used by build.py. To unconditionally add a CMake argument to the backend build use --extra-backend-cmake-arg.",
26342616
)
2635-
2617+
parser.add_argument(
2618+
"--release-version",
2619+
required=False,
2620+
default=DEFAULT_TRITON_VERSION_MAP["release_version"],
2621+
help="This flag sets the release version for Triton Inference Server to be built. Default: the latest released version.",
2622+
)
2623+
parser.add_argument(
2624+
"--triton-container-version",
2625+
required=False,
2626+
default=DEFAULT_TRITON_VERSION_MAP["triton_container_version"],
2627+
help="This flag sets the container version for Triton Inference Server to be built. Default: the latest released version.",
2628+
)
2629+
parser.add_argument(
2630+
"--upstream-container-version",
2631+
required=False,
2632+
default=DEFAULT_TRITON_VERSION_MAP["upstream_container_version"],
2633+
help="This flag sets the upstream container version for Triton Inference Server to be built. Default: the latest released version.",
2634+
)
2635+
parser.add_argument(
2636+
"--ort-version",
2637+
required=False,
2638+
default=DEFAULT_TRITON_VERSION_MAP["ort_version"],
2639+
help="This flag sets the ORT version for Triton Inference Server to be built. Default: the latest supported version.",
2640+
)
2641+
parser.add_argument(
2642+
"--ort-openvino-version",
2643+
required=False,
2644+
default=DEFAULT_TRITON_VERSION_MAP["ort_openvino_version"],
2645+
help="This flag sets the OpenVino version for Triton Inference Server to be built. Default: the latest supported version.",
2646+
)
2647+
parser.add_argument(
2648+
"--standalone-openvino-version",
2649+
required=False,
2650+
default=DEFAULT_TRITON_VERSION_MAP["standalone_openvino_version"],
2651+
help="This flag sets the standalon OpenVino version for Triton Inference Server to be built. Default: the latest supported version.",
2652+
)
2653+
parser.add_argument(
2654+
"--dcgm-version",
2655+
required=False,
2656+
default=DEFAULT_TRITON_VERSION_MAP["dcgm_version"],
2657+
help="This flag sets the DCGM version for Triton Inference Server to be built. Default: the latest supported version.",
2658+
)
2659+
parser.add_argument(
2660+
"--vllm-version",
2661+
required=False,
2662+
default=DEFAULT_TRITON_VERSION_MAP["vllm_version"],
2663+
help="This flag sets the vLLM version for Triton Inference Server to be built. Default: the latest supported version.",
2664+
)
2665+
parser.add_argument(
2666+
"--rhel-py-version",
2667+
required=False,
2668+
default=DEFAULT_TRITON_VERSION_MAP["rhel_py_version"],
2669+
help="This flag sets the Python version for RHEL platform of Triton Inference Server to be built. Default: the latest supported version.",
2670+
)
26362671
FLAGS = parser.parse_args()
26372672

26382673
if FLAGS.image is None:
@@ -2689,8 +2724,7 @@ def enable_all():
26892724
# Determine the versions. Start with Triton version, if --version
26902725
# is not explicitly specified read from TRITON_VERSION file.
26912726
if FLAGS.version is None:
2692-
with open(os.path.join(THIS_SCRIPT_DIR, "TRITON_VERSION"), "r") as vfile:
2693-
FLAGS.version = vfile.readline().strip()
2727+
FLAGS.version = DEFAULT_TRITON_VERSION_MAP["release_version"]
26942728

26952729
if FLAGS.build_parallel is None:
26962730
FLAGS.build_parallel = multiprocessing.cpu_count() * 2
@@ -2708,15 +2742,9 @@ def enable_all():
27082742
# explicitly. For release branches we use the release branch as
27092743
# the default, otherwise we use 'main'.
27102744
default_repo_tag = "main"
2711-
cver = FLAGS.container_version
2745+
cver = FLAGS.upstream_container_version
27122746
if cver is None:
2713-
if FLAGS.version not in TRITON_VERSION_MAP:
2714-
fail(
2715-
"unable to determine default repo-tag, container version not known for {}".format(
2716-
FLAGS.version
2717-
)
2718-
)
2719-
cver = TRITON_VERSION_MAP[FLAGS.version][0]
2747+
cver = FLAGS.triton_container_version
27202748
if not cver.endswith("dev"):
27212749
default_repo_tag = "r" + cver
27222750
log("default repo-tag: {}".format(default_repo_tag))

0 commit comments

Comments
 (0)