Skip to content

Commit 6a7829b

Browse files
authored
Merge branch 'main' into athitten/chat_endpoint
2 parents 28614a2 + 3c261f6 commit 6a7829b

39 files changed

Lines changed: 198 additions & 3804 deletions

.github/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ TensorRT-LLM:
3333
- nemo_export/trt_llm/**/*
3434
- nemo_export/tensorrt_llm*.py
3535
- tests/functional_tests/tests_trtllm/**/*
36-
- scripts/export/export_to_trt_llm.py
36+
- scripts/export/export_hf_to_nemo2.py
3737
- docs/llm/**/optimized/**/*
3838
- docs/mm/**/optimized/**/*
3939

.github/workflows/release-docs.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Copyright (c) 2025, NVIDIA CORPORATION.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
name: Release docs
15+
on:
16+
workflow_dispatch:
17+
inputs:
18+
dry-run:
19+
description: Whether to run the workflow in dry-run mode
20+
required: true
21+
type: boolean
22+
default: true
23+
version-number:
24+
description: Version number to release this as (use `latest` for main branch)
25+
required: true
26+
type: string
27+
notify-emails:
28+
description: Email addresses to send the notification to. Format as "me@me.com,you@you.com".
29+
required: true
30+
type: string
31+
aws-region:
32+
description: AWS region
33+
required: false
34+
type: string
35+
default: us-east-1
36+
37+
jobs:
38+
build-docs:
39+
uses: NVIDIA-NeMo/FW-CI-templates/.github/workflows/_build_docs.yml@v0.67.0
40+
41+
publish-docs:
42+
runs-on: ubuntu-latest
43+
needs: [build-docs]
44+
steps:
45+
- uses: actions/checkout@v6
46+
with:
47+
repository: NVIDIA-NeMo/FW-CI-templates
48+
ref: v0.67.2
49+
path: FW-CI-templates
50+
51+
- uses: ./FW-CI-templates/.github/actions/publish-docs
52+
# This workflow runs either on main, or on a version tag. Any other git ref will lead
53+
# to an error.
54+
# If its on main, it will publish to "latest" directory in Akamai.
55+
# If its on a versioned tag, it will extract the version number from the tag (strip `v` prefix)
56+
# and publish to the versioned directory in Akamai.
57+
with:
58+
dry-run: ${{ inputs.dry-run }}
59+
artifacts-name: docs-html
60+
artifacts-path: _build/html
61+
emails-csv: ${{ inputs.notify-emails && format('{0},{1}', vars.docs_release_emails, inputs.notify-emails) || vars.docs_release_emails }}
62+
overwrite-latest-on-tag: false
63+
run-on-version-tag-only: ${{ github.ref_name != 'main' }}
64+
request-name: export-deploy-publish-docs-${{ github.run_id }}
65+
aws-region: ${{ inputs.aws-region }}
66+
aws-role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
67+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
68+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
69+
akamai-host: ${{ secrets.AKAMAI_HOST }}
70+
akamai-client-token: ${{ secrets.AKAMAI_CLIENT_TOKEN }}
71+
akamai-client-secret: ${{ secrets.AKAMAI_CLIENT_SECRET }}
72+
akamai-access-token: ${{ secrets.AKAMAI_ACCESS_TOKEN }}
73+
s3-target-root: ${{ secrets.S3_BUCKET_NAME }}
74+
s3-target-path: nemo/export-deploy

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,13 @@ In order to run examples with NeMo models, a NeMo checkpoint is required. Please
242242
huggingface-cli login
243243
```
244244

245-
4. Run the following Python code to generate the NeMo 2.0 checkpoint:
245+
4. Run the following Python code to generate the NeMo checkpoint:
246246

247-
```shell
248-
python scripts/export/export_hf_to_nemo2.py \
249-
--hf_model meta-llama/Llama-3.2-1B \
250-
--output_path /opt/checkpoints/hf_llama32_1B_nemo2 \
251-
--config Llama32Config1B
247+
```python
248+
from nemo.collections import llm
249+
250+
# Example: Converting Hugging Face model to NeMo format
251+
# See NeMo documentation for detailed instructions
252252
```
253253

254254
## 🚀 Export and Deploy Examples
@@ -297,9 +297,9 @@ from nemo_export.tensorrt_llm import TensorRTLLM
297297
from nemo_deploy import DeployPyTriton
298298

299299
# Export model to TensorRT-LLM
300-
exporter = TensorRTLLM(model_dir="/tmp/hf_llama32_1B_nemo2")
300+
exporter = TensorRTLLM(model_dir="/tmp/llama32_1B_nemo")
301301
exporter.export(
302-
nemo_checkpoint_path="/opt/checkpoints/hf_llama32_1B_nemo2",
302+
nemo_checkpoint_path="/opt/checkpoints/llama32_1B_nemo",
303303
tensor_parallelism_size=1,
304304
)
305305

@@ -328,8 +328,8 @@ from nemo_deploy import DeployPyTriton
328328
# Export model to vLLM
329329
exporter = vLLMExporter()
330330
exporter.export(
331-
nemo_checkpoint="/opt/checkpoints/hf_llama32_1B_nemo2",
332-
model_dir="/tmp/hf_llama32_1B_nemo2",
331+
nemo_checkpoint="/opt/checkpoints/llama32_1B_nemo",
332+
model_dir="/tmp/llama32_1B_nemo",
333333
tensor_parallel_size=1,
334334
)
335335

@@ -355,10 +355,10 @@ You can also deploy NeMo and Hugging Face models directly using Triton Inference
355355

356356
```python
357357
from nemo_deploy import DeployPyTriton
358-
from nemo_deploy.nlp.megatronllm_deployable import MegatronLLMDeployableNemo2
358+
from nemo_deploy.llm.megatronllm_deployable import MegatronLLMDeployable
359359

360-
model = MegatronLLMDeployableNemo2(
361-
nemo_checkpoint_filepath="/opt/checkpoints/hf_llama32_1B_nemo2",
360+
model = MegatronLLMDeployable(
361+
nemo_checkpoint_filepath="/opt/checkpoints/llama32_1B_nemo",
362362
num_devices=1,
363363
num_nodes=1,
364364
)

nemo_deploy/deploy_ray.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,13 @@ def _stop(self):
171171

172172
def deploy_inframework_model(
173173
self,
174-
nemo_checkpoint: str,
174+
megatron_checkpoint: str,
175175
num_gpus: int = 1,
176176
tensor_model_parallel_size: int = 1,
177177
pipeline_model_parallel_size: int = 1,
178178
expert_model_parallel_size: int = 1,
179179
context_parallel_size: int = 1,
180-
model_id: str = "nemo-model",
180+
model_id: str = "megatron-model",
181181
num_cpus_per_replica: float = 8,
182182
num_replicas: int = 1,
183183
enable_cuda_graphs: bool = False,
@@ -186,13 +186,11 @@ def deploy_inframework_model(
186186
max_batch_size: int = 32,
187187
random_seed: Optional[int] = None,
188188
test_mode: bool = False,
189-
megatron_checkpoint_filepath: str = None,
190189
model_type: str = "gpt",
191-
model_format: str = "nemo",
192190
micro_batch_size: Optional[int] = None,
193191
**model_config_kwargs,
194192
):
195-
"""Deploy an inframework NeMo/Megatron model using Ray Serve.
193+
"""Deploy an inframework Megatron model using Ray Serve.
196194
197195
This method handles the complete deployment lifecycle including:
198196
- Starting Ray Serve
@@ -201,22 +199,20 @@ def deploy_inframework_model(
201199
- Keeping the deployment running until interrupted
202200
203201
Args:
204-
nemo_checkpoint (str): Path to the .nemo checkpoint file.
202+
megatron_checkpoint (str): Path to the Megatron checkpoint directory.
205203
num_gpus (int, optional): Number of GPUs per node. Defaults to 1.
206204
tensor_model_parallel_size (int, optional): Tensor model parallel size. Defaults to 1.
207205
pipeline_model_parallel_size (int, optional): Pipeline model parallel size. Defaults to 1.
208206
expert_model_parallel_size (int, optional): Expert model parallel size. Defaults to 1.
209207
context_parallel_size (int, optional): Context parallel size. Defaults to 1.
210-
model_id (str, optional): Model identifier for API responses. Defaults to "nemo-model".
208+
model_id (str, optional): Model identifier for API responses. Defaults to "megatron-model".
211209
num_cpus_per_replica (float, optional): CPUs per model replica. Defaults to 8.
212210
num_replicas (int, optional): Number of replicas for deployment. Defaults to 1.
213211
enable_cuda_graphs (bool, optional): Enable CUDA graphs. Defaults to False.
214212
enable_flash_decode (bool, optional): Enable Flash Attention decode. Defaults to False.
215213
legacy_ckpt (bool, optional): Use legacy checkpoint format. Defaults to False.
216214
test_mode (bool, optional): Enable test mode. Defaults to False.
217-
megatron_checkpoint_filepath (str, optional): Path to the Megatron checkpoint file. Defaults to None.
218215
model_type (str, optional): Type of model to load. Defaults to "gpt".
219-
model_format (str, optional): Format of model to load. Defaults to "nemo".
220216
micro_batch_size (Optional[int], optional): Micro batch size for model execution. Defaults to None.
221217
222218
Raises:
@@ -244,7 +240,7 @@ def deploy_inframework_model(
244240
num_replicas=num_replicas,
245241
ray_actor_options={"num_cpus": num_cpus_per_replica},
246242
).bind(
247-
nemo_checkpoint_filepath=nemo_checkpoint,
243+
megatron_checkpoint_filepath=megatron_checkpoint,
248244
num_gpus=gpus_per_replica,
249245
tensor_model_parallel_size=tensor_model_parallel_size,
250246
pipeline_model_parallel_size=pipeline_model_parallel_size,
@@ -256,9 +252,7 @@ def deploy_inframework_model(
256252
legacy_ckpt=legacy_ckpt,
257253
max_batch_size=max_batch_size,
258254
random_seed=random_seed,
259-
megatron_checkpoint_filepath=megatron_checkpoint_filepath,
260255
model_type=model_type,
261-
model_format=model_format,
262256
micro_batch_size=micro_batch_size,
263257
**model_config_kwargs,
264258
)

nemo_deploy/llm/megatronllm_deployable.py

Lines changed: 11 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@
2727
from nemo_deploy import ITritonDeployable
2828
from nemo_deploy.llm.inference.inference_base import create_mcore_engine
2929
from nemo_deploy.utils import (
30-
NEMO2,
3130
broadcast_list,
3231
cast_output,
33-
nemo_checkpoint_version,
3432
str_ndarray2list,
3533
)
3634
from nemo_export_deploy_common.import_utils import MISSING_TRITON_MSG, UnavailableError, null_decorator
@@ -54,73 +52,16 @@
5452
LOGGER = logging.getLogger("NeMo")
5553

5654

57-
class MegatronLLMDeploy:
58-
"""A factory class for creating deployable instances of Megatron LLM models.
59-
60-
This class provides a method to get the appropriate deployable instance
61-
based on the version of the NeMo checkpoint model used.
62-
"""
63-
64-
@staticmethod
65-
def get_deployable(
66-
nemo_checkpoint_filepath: str,
67-
num_devices: int = None,
68-
num_nodes: int = None,
69-
tensor_model_parallel_size: int = 1,
70-
pipeline_model_parallel_size: int = 1,
71-
expert_model_parallel_size: int = 1,
72-
context_parallel_size: int = 1,
73-
max_batch_size: int = 32,
74-
random_seed: Optional[int] = None,
75-
enable_flash_decode: bool = False,
76-
enable_cuda_graphs: bool = False,
77-
legacy_ckpt: bool = False,
78-
):
79-
"""Returns the appropriate deployable instance for the given NeMo checkpoint.
80-
81-
Args:
82-
nemo_checkpoint_filepath (str): Path to the .nemo checkpoint file.
83-
num_devices (int): Number of devices to use for deployment.
84-
num_nodes (int): Number of nodes to use for deployment.
85-
tensor_model_parallel_size (int): Size of the tensor model parallelism.
86-
pipeline_model_parallel_size (int): Size of the pipeline model parallelism.
87-
context_parallel_size (int): Size of the context parallelism.
88-
enable_flash_decode (bool): Whether to enable flash decode for inference.
89-
enable_cuda_graphs (bool): Whether to enable CUDA graphs for inference.
90-
legacy_ckpt (bool): Whether to use legacy checkpoint format. Defaults to False.
91-
92-
Returns:
93-
ITritonDeployable: An instance of a deployable class compatible with Triton inference server.
94-
"""
95-
if nemo_checkpoint_version(nemo_checkpoint_filepath) == NEMO2:
96-
return MegatronLLMDeployableNemo2(
97-
num_devices=num_devices,
98-
num_nodes=num_nodes,
99-
nemo_checkpoint_filepath=nemo_checkpoint_filepath,
100-
tensor_model_parallel_size=tensor_model_parallel_size,
101-
pipeline_model_parallel_size=pipeline_model_parallel_size,
102-
context_parallel_size=context_parallel_size,
103-
expert_model_parallel_size=expert_model_parallel_size,
104-
max_batch_size=max_batch_size,
105-
random_seed=random_seed,
106-
enable_flash_decode=enable_flash_decode,
107-
enable_cuda_graphs=enable_cuda_graphs,
108-
legacy_ckpt=legacy_ckpt,
109-
)
110-
else:
111-
raise Exception("Only NeMo 2.0 checkpoint is supported.")
112-
113-
11455
def dict_to_str(messages):
11556
"""Serializes dict to str."""
11657
return json.dumps(messages)
11758

11859

119-
class MegatronLLMDeployableNemo2(ITritonDeployable):
120-
"""Triton inference server compatible deploy class for a .nemo model file.
60+
class MegatronLLMDeployable(ITritonDeployable):
61+
"""Triton inference server compatible deploy class for a Megatron model checkpoint.
12162
12263
Args:
123-
nemo_checkpoint_filepath (str): path for the nemo checkpoint.
64+
megatron_checkpoint_filepath (str): path for the megatron checkpoint.
12465
num_devices (int): number of GPUs.
12566
num_nodes (int): number of nodes.
12667
tensor_model_parallel_size (int): tensor parallelism.
@@ -136,17 +77,15 @@ class MegatronLLMDeployableNemo2(ITritonDeployable):
13677
enable_flash_decode (bool): enable flash decode for inference. Defaults to False.
13778
enable_cuda_graphs (bool): enable CUDA graphs for inference. Defaults to False.`
13879
legacy_ckpt (bool): use legacy checkpoint format. Defaults to False.
139-
megatron_checkpoint_filepath (str): path for the megatron checkpoint.
140-
model_type (str): type of model to load. Defaults to "gpt".(Only for Megatron models)
141-
model_format (str): format of model to load. Defaults to "nemo".
142-
micro_batch_size (Optional[int]): micro batch size for model execution. Defaults to None.(Only for Megatron models)
80+
model_type (str): type of model to load. Defaults to "gpt".
81+
micro_batch_size (Optional[int]): micro batch size for model execution. Defaults to None.
14382
"""
14483

14584
def __init__(
14685
self,
86+
megatron_checkpoint_filepath: str,
14787
num_devices: int = None,
14888
num_nodes: int = None,
149-
nemo_checkpoint_filepath: str = None,
15089
tensor_model_parallel_size: int = 1,
15190
pipeline_model_parallel_size: int = 1,
15291
context_parallel_size: int = 1,
@@ -159,27 +98,20 @@ def __init__(
15998
max_batch_size: int = 8,
16099
random_seed: Optional[int] = None,
161100
legacy_ckpt: bool = False,
162-
megatron_checkpoint_filepath: str = None,
163101
model_type: str = "gpt",
164-
model_format: str = "nemo",
165102
micro_batch_size: Optional[int] = None,
166103
**model_config_kwargs,
167104
):
168105
if not HAVE_TRITON:
169106
raise UnavailableError(MISSING_TRITON_MSG)
170-
if model_format == "nemo":
171-
checkpoint_filepath = nemo_checkpoint_filepath
172-
elif model_format == "megatron":
173-
if model_type not in ["gpt", "mamba"]:
174-
raise ValueError(f"Model type {model_type} not supported for Megatron models.")
175-
checkpoint_filepath = megatron_checkpoint_filepath
176-
else:
177-
raise ValueError(f"Model format {model_format} not supported.")
107+
108+
if model_type not in ["gpt", "mamba"]:
109+
raise ValueError(f"Model type {model_type} not supported for Megatron models.")
178110

179111
self.mcore_engine, self.inference_wrapped_model, self.mcore_tokenizer = create_mcore_engine(
180112
num_devices=num_devices,
181113
num_nodes=num_nodes,
182-
path=Path(checkpoint_filepath),
114+
path=Path(megatron_checkpoint_filepath),
183115
params_dtype=params_dtype,
184116
inference_batch_times_seqlen_threshold=inference_batch_times_seqlen_threshold,
185117
inference_max_seq_length=inference_max_seq_length,
@@ -193,7 +125,7 @@ def __init__(
193125
enable_cuda_graphs=enable_cuda_graphs,
194126
legacy_ckpt=legacy_ckpt,
195127
model_type=model_type,
196-
model_format=model_format,
128+
model_format="megatron",
197129
micro_batch_size=micro_batch_size,
198130
**model_config_kwargs,
199131
)

0 commit comments

Comments
 (0)