-
Notifications
You must be signed in to change notification settings - Fork 333
Fix[bug] ONNX models generated by llm_export.py are missing some i/o #1157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -363,7 +363,26 @@ def main(args): | |
| onnx_dir = args.output_dir + "_raw" if args.save_original else args.output_dir | ||
| # Surgeon graph based on precision | ||
| raw_onnx_path = f"{onnx_dir}/model.onnx" | ||
| extra_inputs, extra_dyn_axes = {}, {} | ||
|
|
||
| batch_size = 1 | ||
| seq_len = 8 | ||
| dummy_input_ids = torch.randint(0, 1000, (batch_size, seq_len), dtype=torch.long) | ||
| dummy_attention_mask = torch.ones((batch_size, seq_len), dtype=torch.long) | ||
| dummy_position_ids = torch.arange(seq_len).unsqueeze(0).repeat(batch_size, 1) | ||
|
|
||
| # Correct assignment — no trailing comma | ||
| extra_inputs = { | ||
| "input_ids": dummy_input_ids, | ||
| "attention_mask": dummy_attention_mask, | ||
| "position_ids": dummy_position_ids, | ||
| } | ||
| extra_dyn_axes = { | ||
| "input_ids": {0: "batch", 1: "seq_len"}, | ||
| "attention_mask": {0: "batch", 1: "seq_len"}, | ||
| "position_ids": {0: "batch", 1: "seq_len"}, | ||
| "logits": {0: "batch", 1: "seq_len"}, | ||
| } | ||
|
Comment on lines
+374
to
+384
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Read-only verification of signature/call-path mismatch
rg -n -C3 'def forward\(self, input_ids.*past_key_values' modelopt/onnx/llm_export_utils/export_utils.py
rg -n -C8 'torch_to_onnx\(' modelopt/onnx/llm_export_utils/export_utils.py
rg -n -C8 'extra_inputs = \{|extra_dyn_axes = \{' examples/torch_onnx/llm_export.pyRepository: NVIDIA/Model-Optimizer Length of output: 2743
The wrapper's Suggested minimal fix- extra_inputs = {
- "input_ids": dummy_input_ids,
- "attention_mask": dummy_attention_mask,
- "position_ids": dummy_position_ids,
- }
- extra_dyn_axes = {
- "input_ids": {0: "batch", 1: "seq_len"},
- "attention_mask": {0: "batch", 1: "seq_len"},
- "position_ids": {0: "batch", 1: "seq_len"},
- "logits": {0: "batch", 1: "seq_len"},
- }
+ extra_inputs = {}
+ extra_dyn_axes = {"logits": {0: "batch_size", 1: "seq_len"}}If 🤖 Prompt for AI Agents |
||
|
|
||
| export_raw_llm( | ||
| model=model, | ||
| output_dir=onnx_dir, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a non-UTF-8 character at this line