Skip to content

Commit f262588

Browse files
committed
Cleanup and additional fixes
Signed-off-by: Anand Joseph <anajoseph@nvidia.com>
1 parent 70d4873 commit f262588

5 files changed

Lines changed: 27 additions & 19 deletions

File tree

‎nemo2riva/cookbook.py‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def export_model(model, cfg, args, artifacts, metadata):
4848
format_meta = {"has_pytorch_checkpoint": True, "runtime": "PyTorch"}
4949
elif cfg.export_format == "NEMO":
5050
format_meta = {"has_pytorch_checkpoint": True, "runtime": "Python"}
51-
elif cfg.export_format == "TRT-LLM":
52-
format_meta = {"has_pytorch_checkpoint": False, "runtime": "TRT-LLM"}
51+
elif cfg.export_format == "STATE":
52+
format_meta = {"has_pytorch_checkpoint": False, "runtime": "Python"}
5353
# TODO: use submodel sections
5454
metadata.update(format_meta)
5555
runtime = format_meta["runtime"]
@@ -142,14 +142,13 @@ def export_model(model, cfg, args, artifacts, metadata):
142142

143143
elif cfg.export_format == "NEMO":
144144
model.save_to(export_file)
145-
elif cfg.export_format == "TRT-LLM":
145+
elif cfg.export_format == "STATE":
146146
if not isinstance(model, Exportable):
147147
logging.error("Your NeMo model class ({}) is not Exportable.".format(metadata['obj_cls']))
148148
sys.exit(1)
149-
model.transf_decoder.freeze()
150-
decoder_params = model.transf_decoder.state_dict()
151-
decoder_params.update(model.log_softmax.state_dict())
152-
torch.save(decoder_params, export_file)
149+
model.freeze()
150+
model_params = model.state_dict()
151+
torch.save(model_params, export_file)
153152

154153

155154

‎nemo2riva/patches/aed_canary.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def make_vocabulary_file(model, artifacts, **kwargs):
7272
lang = model.tokenizer.ids_to_lang([t_id])
7373
tokenizer_vocab['tokens'][lang][t_id] = model.tokenizer.ids_to_tokens([t_id])[0]
7474

75-
artifacts['vocab.json']={}
76-
artifacts['vocab.json']['content'] = json.dumps(tokenizer_vocab).encode('utf-8')
75+
#artifacts['vocab.json']={}
76+
#artifacts['vocab.json']['content'] = json.dumps(tokenizer_vocab).encode('utf-8')
7777
return tokenizer_vocab
7878

‎nemo2riva/schema.py‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
schema_dict = None
1919

20-
supported_formats = ["ONNX", "CKPT", "TS", "NEMO", "PYTORCH", "TRT-LLM"]
20+
supported_formats = ["ONNX", "CKPT", "TS", "NEMO", "PYTORCH", "STATE"]
2121

2222

2323
@dataclass
@@ -50,12 +50,13 @@ def get_export_config(export_obj, args):
5050
conf.export_file = list(export_obj)[0]
5151
attribs = export_obj[conf.export_file]
5252
conf.export_subnet = attribs.get('export_subnet', None)
53+
5354
conf.is_onnx=attribs.get('onnx', False)
54-
conf.trt_llm = False
55-
conf.weights_only = False
55+
56+
5657

5758
if not conf.is_onnx:
58-
conf.trt_llm = attribs.get('trtllm', False)
59+
conf.states_only = attribs.get('states_only', False)
5960
conf.is_torch = attribs.get('torch', False)
6061

6162
if conf.export_file.endswith('.onnx'):
@@ -64,10 +65,11 @@ def get_export_config(export_obj, args):
6465
conf.export_format = "TS"
6566
elif conf.export_file.endswith('.nemo'):
6667
conf.export_format = "NEMO"
67-
elif conf.trt_llm:
68-
conf.export_format = "TRT-LLM"
69-
elif conf.export_file.endswith('.pt'):
70-
conf.export_format = "PYTORCH"
68+
elif conf.is_torch:
69+
if conf.states_only:
70+
conf.export_format = "STATE"
71+
else:
72+
conf.export_format = "PYTORCH"
7173
else:
7274
conf.export_format = "CKPT"
7375
conf.autocast = attribs.get('autocast', False)

‎nemo2riva/validation_schemas/asr-scr-exported-aedmodel.yaml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ artifact_properties:
1414
export_subnet: encoder
1515
onnx: True
1616
- decoder.pt:
17-
trtllm: True
17+
export_subnet: transf_decoder
18+
states_only: True
19+
torch: True
20+
onnx: False
21+
- log_softmax.pt:
22+
export_subnet: log_softmax
23+
states_only: True
1824
torch: True
1925
onnx: False
2026

‎requirements.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
# SPDX-License-Identifier: MIT
33

44
nemo_toolkit>=1.6.0
5+
torch>=2.4.0
56
nvidia-eff>=0.6.4
67
nvidia-eff-tao-encryption>=0.1.8
78
nvidia-pyindex==1.0.6
8-
onnx==1.14.1
9+
onnx==1.16.1
910
onnxruntime==1.16.3
1011
onnxruntime-gpu==1.16.3
1112
onnx-graphsurgeon==0.3.27

0 commit comments

Comments
 (0)