From 87d76c75755c2f0403838b288b1eb4f7d4522aee Mon Sep 17 00:00:00 2001 From: Jan Lasek Date: Wed, 18 Dec 2024 13:22:38 +0100 Subject: [PATCH 1/7] NIM 24.12 release branch Signed-off-by: Jan Lasek --- nemo/export/tensorrt_llm.py | 2 + requirements/requirements_infer_nim.txt | 2 + setup_export.py | 64 +++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 requirements/requirements_infer_nim.txt create mode 100644 setup_export.py diff --git a/nemo/export/tensorrt_llm.py b/nemo/export/tensorrt_llm.py index d1b5aa0e76d6..cbfb67f929aa 100644 --- a/nemo/export/tensorrt_llm.py +++ b/nemo/export/tensorrt_llm.py @@ -228,6 +228,8 @@ def export( build_rank (Optional[int]): rank to export the model on. If None, builds on all ranks. """ + if use_mcore_path: + raise RuntimeError("Using Megatron-Core export path is not yet supported for this version.") gpus_per_node = tensor_parallelism_size if gpus_per_node is None else gpus_per_node if Path(self.model_dir).exists(): diff --git a/requirements/requirements_infer_nim.txt b/requirements/requirements_infer_nim.txt new file mode 100644 index 000000000000..e023b485face --- /dev/null +++ b/requirements/requirements_infer_nim.txt @@ -0,0 +1,2 @@ +tensorstore==0.1.45 +zarr==2.18.2 diff --git a/setup_export.py b/setup_export.py new file mode 100644 index 000000000000..be149479915f --- /dev/null +++ b/setup_export.py @@ -0,0 +1,64 @@ +# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import setuptools +import os + + +def req_file(filename, folder="requirements"): + with open(os.path.join(folder, filename), encoding='utf-8') as f: + content = f.readlines() + # you may also want to remove whitespace characters + # Example: `\n` at the end of each line + return [x.strip() for x in content] + + +def setup_export(): + install_requires = req_file("requirements_infer_nim.txt") + + setuptools.setup( + name="NeMo Export", + # Versions should comply with PEP440. For a discussion on single-sourcing + # the version across setup.py and the project code, see + # https://packaging.python.org/en/latest/single_source_version.html + version=24.12, + description="NeMo Export - a module to export nemo checkpoints to TensorRT-LLM", + long_description="NeMo Export - a module to export nemo checkpoints to TensorRT-LLM", + # Author details + author="NVIDIA", + license='Apache2', + packages=[ + "nemo", + "nemo.export", + "nemo.export.trt_llm", + "nemo.export.vllm", + "nemo.export.multimodal", + "nemo.export.quantize", + "nemo.export.utils", + "nemo.export.trt_llm.converter", + "nemo.export.trt_llm.nemo_ckpt_loader", + "nemo.export.trt_llm.qnemo", + "nemo.deploy", + ], + install_requires=install_requires, + # Add in any packaged data. + include_package_data=True, + exclude=['tools', 'tests'], + package_data={'': ['*.tsv', '*.txt', '*.far', '*.fst', '*.cpp', 'Makefile']}, + zip_safe=False, + ) + + +if __name__ == '__main__': + setup_export() From e3412dfb611d3cf5ca244bf6949ddc30d18b04da Mon Sep 17 00:00:00 2001 From: Jan Lasek Date: Wed, 18 Dec 2024 18:40:23 +0100 Subject: [PATCH 2/7] Version fix Signed-off-by: Jan Lasek --- setup_export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup_export.py b/setup_export.py index be149479915f..cb6194545921 100644 --- a/setup_export.py +++ b/setup_export.py @@ -32,7 +32,7 @@ def setup_export(): # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # https://packaging.python.org/en/latest/single_source_version.html - version=24.12, + version="24.12", description="NeMo Export - a module to export nemo checkpoints to TensorRT-LLM", long_description="NeMo Export - a module to export nemo checkpoints to TensorRT-LLM", # Author details From e13e9db96774781b702866bf2dca2d1f65759800 Mon Sep 17 00:00:00 2001 From: Jan Lasek Date: Fri, 31 Jan 2025 16:23:45 +0100 Subject: [PATCH 3/7] Remove use_mcore_path Signed-off-by: Jan Lasek --- nemo/export/tensorrt_llm.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/nemo/export/tensorrt_llm.py b/nemo/export/tensorrt_llm.py index 057c06882311..f71be0b15a04 100644 --- a/nemo/export/tensorrt_llm.py +++ b/nemo/export/tensorrt_llm.py @@ -227,8 +227,6 @@ def export( build_rank (Optional[int]): rank to export the model on. If None, builds on all ranks. """ - if use_mcore_path: - raise RuntimeError("Using Megatron-Core export path is not yet supported for this version.") gpus_per_node = tensor_parallelism_size if gpus_per_node is None else gpus_per_node if Path(self.model_dir).exists(): From 0c9a361b7b284549d5e3ea428747eeb8a0f365b2 Mon Sep 17 00:00:00 2001 From: Jan Lasek Date: Fri, 31 Jan 2025 16:53:23 +0100 Subject: [PATCH 4/7] Restructure setup_export.py Signed-off-by: Jan Lasek --- setup_export.py | 87 +++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/setup_export.py b/setup_export.py index cb6194545921..f3489fbd68b7 100644 --- a/setup_export.py +++ b/setup_export.py @@ -1,4 +1,4 @@ -# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. +# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,53 +12,56 @@ # See the License for the specific language governing permissions and # limitations under the License. -import setuptools +import importlib.util import os +import setuptools + +spec = importlib.util.spec_from_file_location('package_info', 'nemo/package_info.py') +package_info = importlib.util.module_from_spec(spec) +spec.loader.exec_module(package_info) + + +__contact_emails__ = package_info.__contact_emails__ +__contact_names__ = package_info.__contact_names__ +__download_url__ = package_info.__download_url__ +__license__ = package_info.__license__ +__repository_url__ = package_info.__repository_url__ +__version__ = package_info.__version__ def req_file(filename, folder="requirements"): with open(os.path.join(folder, filename), encoding='utf-8') as f: content = f.readlines() - # you may also want to remove whitespace characters - # Example: `\n` at the end of each line return [x.strip() for x in content] -def setup_export(): - install_requires = req_file("requirements_infer_nim.txt") - - setuptools.setup( - name="NeMo Export", - # Versions should comply with PEP440. For a discussion on single-sourcing - # the version across setup.py and the project code, see - # https://packaging.python.org/en/latest/single_source_version.html - version="24.12", - description="NeMo Export - a module to export nemo checkpoints to TensorRT-LLM", - long_description="NeMo Export - a module to export nemo checkpoints to TensorRT-LLM", - # Author details - author="NVIDIA", - license='Apache2', - packages=[ - "nemo", - "nemo.export", - "nemo.export.trt_llm", - "nemo.export.vllm", - "nemo.export.multimodal", - "nemo.export.quantize", - "nemo.export.utils", - "nemo.export.trt_llm.converter", - "nemo.export.trt_llm.nemo_ckpt_loader", - "nemo.export.trt_llm.qnemo", - "nemo.deploy", - ], - install_requires=install_requires, - # Add in any packaged data. - include_package_data=True, - exclude=['tools', 'tests'], - package_data={'': ['*.tsv', '*.txt', '*.far', '*.fst', '*.cpp', 'Makefile']}, - zip_safe=False, - ) - - -if __name__ == '__main__': - setup_export() +setuptools.setup( + name="NeMo-Export", + version=__version__, + description="NeMo Export - a package to export NeMo checkpoints to TensorRT-LLM", + long_description="NeMo Export - a package to export NeMo checkpoints to TensorRT-LLM", + url=__repository_url__, + download_url=__download_url__, + author=__contact_names__, + maintainer=__contact_names__, + maintainer_email=__contact_emails__, + license=__license__, + packages=[ + "nemo", + "nemo.export", + "nemo.export.trt_llm", + "nemo.export.vllm", + "nemo.export.multimodal", + "nemo.export.quantize", + "nemo.export.utils", + "nemo.export.trt_llm.converter", + "nemo.export.trt_llm.nemo_ckpt_loader", + "nemo.export.trt_llm.qnemo", + "nemo.deploy", + ], + install_requires=req_file("requirements_infer_nim.txt"), + include_package_data=True, + exclude={'': ['tools', 'tests']}, + package_data={'': ['*.tsv', '*.txt', '*.far', '*.fst', '*.cpp', 'Makefile']}, + zip_safe=False, +) From 890e52955ccb1df56d2f3a39fcddfcb0e681e291 Mon Sep 17 00:00:00 2001 From: Jan Lasek Date: Fri, 31 Jan 2025 18:01:48 +0100 Subject: [PATCH 5/7] Simplify listing packages Signed-off-by: Jan Lasek --- setup_export.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/setup_export.py b/setup_export.py index f3489fbd68b7..4857a52b406f 100644 --- a/setup_export.py +++ b/setup_export.py @@ -46,22 +46,7 @@ def req_file(filename, folder="requirements"): maintainer=__contact_names__, maintainer_email=__contact_emails__, license=__license__, - packages=[ - "nemo", - "nemo.export", - "nemo.export.trt_llm", - "nemo.export.vllm", - "nemo.export.multimodal", - "nemo.export.quantize", - "nemo.export.utils", - "nemo.export.trt_llm.converter", - "nemo.export.trt_llm.nemo_ckpt_loader", - "nemo.export.trt_llm.qnemo", - "nemo.deploy", - ], + packages=setuptools.find_packages(include=["nemo", "nemo.export*"]), install_requires=req_file("requirements_infer_nim.txt"), - include_package_data=True, - exclude={'': ['tools', 'tests']}, - package_data={'': ['*.tsv', '*.txt', '*.far', '*.fst', '*.cpp', 'Makefile']}, zip_safe=False, ) From dcae1344d1b9f39d0569f00c4b64e1c1c450e506 Mon Sep 17 00:00:00 2001 From: Jan Lasek Date: Mon, 3 Feb 2025 12:12:34 +0100 Subject: [PATCH 6/7] Change package name (to conform nemo_toolkit) Signed-off-by: Jan Lasek --- setup_export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup_export.py b/setup_export.py index 4857a52b406f..17443f22b6b7 100644 --- a/setup_export.py +++ b/setup_export.py @@ -36,7 +36,7 @@ def req_file(filename, folder="requirements"): setuptools.setup( - name="NeMo-Export", + name="nemo_export", version=__version__, description="NeMo Export - a package to export NeMo checkpoints to TensorRT-LLM", long_description="NeMo Export - a package to export NeMo checkpoints to TensorRT-LLM", From 2ec3a8b1420bc465210501fbe2c2f658f6dcbba4 Mon Sep 17 00:00:00 2001 From: Jan Lasek Date: Mon, 3 Feb 2025 14:41:59 +0100 Subject: [PATCH 7/7] Add required nemo.deploy package Signed-off-by: Jan Lasek --- setup_export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup_export.py b/setup_export.py index 17443f22b6b7..2e77d376864a 100644 --- a/setup_export.py +++ b/setup_export.py @@ -46,7 +46,7 @@ def req_file(filename, folder="requirements"): maintainer=__contact_names__, maintainer_email=__contact_emails__, license=__license__, - packages=setuptools.find_packages(include=["nemo", "nemo.export*"]), + packages=setuptools.find_packages(include=["nemo", "nemo.export*", "nemo.deploy"]), install_requires=req_file("requirements_infer_nim.txt"), zip_safe=False, )