Skip to content

Commit 23cf89b

Browse files
trvachovnasretdinovr
authored andcommitted
Allow exception in hf ckpt load attempt before fallback to standard l… (NVIDIA-NeMo#14214)
* Allow exception in hf ckpt load attempt before fallback to standard load strategy Signed-off-by: Timur Rvachov <[email protected]> * Make exception RuntimeError specific Signed-off-by: Timur Rvachov <[email protected]> --------- Signed-off-by: Timur Rvachov <[email protected]>
1 parent 8fecd1c commit 23cf89b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

nemo/lightning/io/api.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,12 @@ def export_ckpt(
266266
_output_path = output_path or Path(path) / target
267267

268268
if target == "hf":
269-
modelopt_export_kwargs = modelopt_export_kwargs or {}
270-
# First try to export via ModelOpt route. If rejected, return to the default route
271-
output = export_hf_checkpoint(path, _output_path, **modelopt_export_kwargs)
269+
try:
270+
modelopt_export_kwargs = modelopt_export_kwargs or {}
271+
# First try to export via ModelOpt route. If rejected, return to the default route
272+
output = export_hf_checkpoint(path, _output_path, **modelopt_export_kwargs)
273+
except RuntimeError:
274+
output = None
272275
if output is not None:
273276
return output
274277

0 commit comments

Comments
 (0)