Fix dynamic_shapes variable naming in ONNX dynamo export#15047
Merged
nithinraok merged 2 commits intoMar 17, 2026
Merged
Conversation
Fixes NVIDIA-NeMo#15040 When exporting Parakeet models to ONNX with use_dynamo=True, PyTorch's dynamo export expects the parameter name 'dynamic_shapes' not 'dynamic_axes'. This fix introduces a properly-named variable for the dynamo code path to avoid confusion and potential errors. Changes: - Introduced dynamic_shapes variable when use_dynamo=True - Updated torch.export.export call to use dynamic_shapes parameter - Updated logging to display the correct variable name The non-dynamo code path continues to use dynamic_axes as expected by torch.onnx.export. Tested by issue reporter who confirmed ONNX export succeeds after this change. Signed-off-by: Yashwant Bezawada <yashwant_b@me.com>
a58f3bc to
5d46494
Compare
Collaborator
|
CC @nithinraok |
Member
|
I should be reviewed by @borisfom but since its minor fix approving it. |
paarthneekhara
pushed a commit
to paarthneekhara/NeMo
that referenced
this pull request
Mar 19, 2026
…#15047) Fixes NVIDIA-NeMo#15040 When exporting Parakeet models to ONNX with use_dynamo=True, PyTorch's dynamo export expects the parameter name 'dynamic_shapes' not 'dynamic_axes'. This fix introduces a properly-named variable for the dynamo code path to avoid confusion and potential errors. Changes: - Introduced dynamic_shapes variable when use_dynamo=True - Updated torch.export.export call to use dynamic_shapes parameter - Updated logging to display the correct variable name The non-dynamo code path continues to use dynamic_axes as expected by torch.onnx.export. Tested by issue reporter who confirmed ONNX export succeeds after this change. Signed-off-by: Yashwant Bezawada <yashwant_b@me.com> Signed-off-by: Paarth Neekhara <paarth.n@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes issue #15040 where exporting Parakeet models to ONNX fails when using dynamo export due to incorrect variable naming in the export code path.
Root Cause
When
use_dynamo=True, the code creates a variable calleddynamic_axes(line 226) that is actually meant to bedynamic_shapesfor PyTorch's dynamo export API. Thetorch.export.export()function at line 249 expects adynamic_shapesparameter, but the code was passing the value through a variable nameddynamic_axes, causing confusion and errors.The issue reporter noted getting this warning:
Changes
File:
nemo/core/classes/exportable.pyLines 227-229: Introduced proper variable naming for dynamo export path
if use_dynamo: dynamic_shapes = dynamic_axesdynamic_axesfor the traditional ONNX export pathLine 234: Updated logging message
logging.info(f"Running export.export, dynamic shapes:{dynamic_axes}\n")logging.info(f"Running export.export, dynamic shapes:{dynamic_shapes}\n")Line 249: Fixed parameter name in
torch.export.export()dynamic_shapes=dynamic_axesdynamic_shapes=dynamic_shapesWhy This Approach?
The fix maintains backward compatibility:
use_dynamo=True): Usesdynamic_shapesvariable (lines 227-260)use_dynamo=False): Usesdynamic_axesvariable (lines 267-279)This separation makes the code clearer and avoids the confusion that led to the bug.
Testing
As reported by @jingzhaoou in #15040:
The fix has been tested with Parakeet model export and successfully generates ONNX files.
Impact
dynamic_axesFixes #15040