KEMBAR78
[ONNX] Set fallback=False by default by justinchuby · Pull Request #162726 · pytorch/pytorch · GitHub
Skip to content

Conversation

justinchuby
Copy link
Collaborator

@justinchuby justinchuby commented Sep 11, 2025

This change addresses confusing error messages users encounter when using the ONNX exporter with default settings. Previously, fallback=True was the default, which would attempt to fall back to the TorchScript exporter when the dynamo path failed, leading to mixed error messages that obscured the actual issues.

Problem

When fallback=True by default:

  • Users get confusing error messages mixing dynamo and TorchScript export failures
  • Error messages tell users to provide the f argument unnecessarily
  • Dynamo error messages get flushed with TorchScript errors when both paths fail
  • Users expecting the dynamo path get unexpected fallback behavior

Solution

Changed the default from fallback=True to fallback=False in both:

  • torch.onnx.export() function
  • torch.onnx._internal.exporter._compat.export_compat() function

Impact

Before:

# Would fallback to TorchScript on dynamo failure, causing mixed error messages
torch.onnx.export(model, args)

After:

# Clean dynamo-only errors by default
torch.onnx.export(model, args)

# Advanced users can still opt-in to fallback behavior
torch.onnx.export(model, args, fallback=True)

Fixes #162697

cc @titaiwangms

@pytorch-bot
Copy link

pytorch-bot bot commented Sep 11, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/162726

Note: Links to docs will display an error until the docs builds have been completed.

⏳ No Failures, 2 Pending

As of commit 8b9acb6 with merge base 07d2531 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Sep 11, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: justinchuby / name: Justin Chu (8b9acb6)

@pytorch-bot pytorch-bot bot added the release notes: onnx torch.onnx related changes that should show up in the release notes label Sep 11, 2025
@justinchuby justinchuby added module: onnx Related to torch.onnx topic: improvements topic category topic: bug fixes topic category and removed topic: improvements topic category labels Sep 11, 2025
@justinchuby justinchuby requested a review from xadupre September 11, 2025 14:35
@justinchuby justinchuby added this to the 2.9.0 milestone Sep 11, 2025
Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
@justinchuby justinchuby added the ciflow/trunk Trigger trunk jobs on your pull request label Sep 11, 2025
@justinchuby
Copy link
Collaborator Author

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@justinchuby
Copy link
Collaborator Author

@pytorchbot merge -f "all related tests passed"

@pytorchmergebot
Copy link
Collaborator

The merge job was canceled or timed out. This most often happen if two merge requests were issued for the same PR, or if merge job was waiting for more than 6 hours for tests to finish. In later case, please do not hesitate to reissue the merge command
For more information see pytorch-bot wiki.

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@justinchuby
Copy link
Collaborator Author

@pytorchbot cherry-pick --onto release/2.9 --fixes "Critical fixes to new features: ONNX exporter's switch to pt2 export as default - corrected behavior" -c critical

@pytorchbot
Copy link
Collaborator

Cherry picking #162726

Command git -C /home/runner/work/pytorch/pytorch cherry-pick -x 43d9b5ecaa68c19422c5697165b2277bd67572ba returned non-zero exit code 1

Auto-merging torch/onnx/__init__.py
CONFLICT (content): Merge conflict in torch/onnx/__init__.py
error: could not apply 43d9b5ecaa6... [ONNX] Set fallback=False by default (#162726)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Details for Dev Infra team Raised by workflow job

@justinchuby
Copy link
Collaborator Author

@pytorchbot cherry-pick --onto release/2.9 --fixes "Critical fixes to new features: ONNX exporter's switch to pt2 export as default - corrected behavior" -c critical

@pytorchbot
Copy link
Collaborator

Cherry picking #162726

Command git -C /home/runner/work/pytorch/pytorch cherry-pick -x 43d9b5ecaa68c19422c5697165b2277bd67572ba returned non-zero exit code 1

Auto-merging torch/onnx/__init__.py
CONFLICT (content): Merge conflict in torch/onnx/__init__.py
error: could not apply 43d9b5ecaa6... [ONNX] Set fallback=False by default (#162726)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Details for Dev Infra team Raised by workflow job

@justinchuby justinchuby deleted the copilot/fix-162697 branch September 11, 2025 23:24
@titaiwangms titaiwangms added the topic: bc breaking topic category label Sep 15, 2025
markc-614 pushed a commit to markc-614/pytorch that referenced this pull request Sep 17, 2025
This change addresses confusing error messages users encounter when using the ONNX exporter with default settings. Previously, `fallback=True` was the default, which would attempt to fall back to the TorchScript exporter when the dynamo path failed, leading to mixed error messages that obscured the actual issues.

## Problem

When `fallback=True` by default:
- Users get confusing error messages mixing dynamo and TorchScript export failures
- Error messages tell users to provide the `f` argument unnecessarily
- Dynamo error messages get flushed with TorchScript errors when both paths fail
- Users expecting the dynamo path get unexpected fallback behavior

## Solution

Changed the default from `fallback=True` to `fallback=False` in both:
- `torch.onnx.export()` function
- `torch.onnx._internal.exporter._compat.export_compat()` function

## Impact

**Before:**
```python
# Would fallback to TorchScript on dynamo failure, causing mixed error messages
torch.onnx.export(model, args)
```

**After:**
```python
# Clean dynamo-only errors by default
torch.onnx.export(model, args)

# Advanced users can still opt-in to fallback behavior
torch.onnx.export(model, args, fallback=True)
```

Fixes pytorch#162697

Pull Request resolved: pytorch#162726
Approved by: https://github.com/titaiwangms, https://github.com/xadupre
mansiag05 pushed a commit to mansiag05/pytorch that referenced this pull request Sep 22, 2025
This change addresses confusing error messages users encounter when using the ONNX exporter with default settings. Previously, `fallback=True` was the default, which would attempt to fall back to the TorchScript exporter when the dynamo path failed, leading to mixed error messages that obscured the actual issues.

## Problem

When `fallback=True` by default:
- Users get confusing error messages mixing dynamo and TorchScript export failures
- Error messages tell users to provide the `f` argument unnecessarily
- Dynamo error messages get flushed with TorchScript errors when both paths fail
- Users expecting the dynamo path get unexpected fallback behavior

## Solution

Changed the default from `fallback=True` to `fallback=False` in both:
- `torch.onnx.export()` function
- `torch.onnx._internal.exporter._compat.export_compat()` function

## Impact

**Before:**
```python
# Would fallback to TorchScript on dynamo failure, causing mixed error messages
torch.onnx.export(model, args)
```

**After:**
```python
# Clean dynamo-only errors by default
torch.onnx.export(model, args)

# Advanced users can still opt-in to fallback behavior
torch.onnx.export(model, args, fallback=True)
```

Fixes pytorch#162697

Pull Request resolved: pytorch#162726
Approved by: https://github.com/titaiwangms, https://github.com/xadupre
cleonard530 pushed a commit to cleonard530/pytorch that referenced this pull request Sep 22, 2025
This change addresses confusing error messages users encounter when using the ONNX exporter with default settings. Previously, `fallback=True` was the default, which would attempt to fall back to the TorchScript exporter when the dynamo path failed, leading to mixed error messages that obscured the actual issues.

## Problem

When `fallback=True` by default:
- Users get confusing error messages mixing dynamo and TorchScript export failures
- Error messages tell users to provide the `f` argument unnecessarily
- Dynamo error messages get flushed with TorchScript errors when both paths fail
- Users expecting the dynamo path get unexpected fallback behavior

## Solution

Changed the default from `fallback=True` to `fallback=False` in both:
- `torch.onnx.export()` function
- `torch.onnx._internal.exporter._compat.export_compat()` function

## Impact

**Before:**
```python
# Would fallback to TorchScript on dynamo failure, causing mixed error messages
torch.onnx.export(model, args)
```

**After:**
```python
# Clean dynamo-only errors by default
torch.onnx.export(model, args)

# Advanced users can still opt-in to fallback behavior
torch.onnx.export(model, args, fallback=True)
```

Fixes pytorch#162697

Pull Request resolved: pytorch#162726
Approved by: https://github.com/titaiwangms, https://github.com/xadupre
dsashidh pushed a commit to dsashidh/pytorch that referenced this pull request Sep 26, 2025
This change addresses confusing error messages users encounter when using the ONNX exporter with default settings. Previously, `fallback=True` was the default, which would attempt to fall back to the TorchScript exporter when the dynamo path failed, leading to mixed error messages that obscured the actual issues.

## Problem

When `fallback=True` by default:
- Users get confusing error messages mixing dynamo and TorchScript export failures
- Error messages tell users to provide the `f` argument unnecessarily
- Dynamo error messages get flushed with TorchScript errors when both paths fail
- Users expecting the dynamo path get unexpected fallback behavior

## Solution

Changed the default from `fallback=True` to `fallback=False` in both:
- `torch.onnx.export()` function
- `torch.onnx._internal.exporter._compat.export_compat()` function

## Impact

**Before:**
```python
# Would fallback to TorchScript on dynamo failure, causing mixed error messages
torch.onnx.export(model, args)
```

**After:**
```python
# Clean dynamo-only errors by default
torch.onnx.export(model, args)

# Advanced users can still opt-in to fallback behavior
torch.onnx.export(model, args, fallback=True)
```

Fixes pytorch#162697

Pull Request resolved: pytorch#162726
Approved by: https://github.com/titaiwangms, https://github.com/xadupre
@Camyll
Copy link
Contributor

Camyll commented Oct 1, 2025

@pytorchbot cherry-pick --onto release/2.9 --fixes "Critical fixes to new features: ONNX exporter's switch to pt2 export as default - corrected behavior" -c critical

@justinchuby
Copy link
Collaborator Author

@Camyll i think this was merged as part of a cherry-pick?

@Camyll
Copy link
Contributor

Camyll commented Oct 1, 2025

@Camyll i think this was merged as part of a cherry-pick?

The cherry pick attempt failed due to a merge conflict, I'm trying again with the bot to see if it got resolved, otherwise I'll manually cherrypick

@justinchuby
Copy link
Collaborator Author

justinchuby commented Oct 1, 2025

I meant it should be part of #162637

@pytorchbot
Copy link
Collaborator

Cherry picking #162726

Command git -C /home/runner/work/pytorch/pytorch cherry-pick -x 43d9b5ecaa68c19422c5697165b2277bd67572ba returned non-zero exit code 1

The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:

    git commit --allow-empty

Otherwise, please use 'git cherry-pick --skip'
On branch cherry-pick-162726-by-pytorch_bot_bot_
You are currently cherry-picking commit 43d9b5ecaa6.
  (all conflicts fixed: run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

nothing to commit, working tree clean
Details for Dev Infra team Raised by workflow job

@Camyll
Copy link
Contributor

Camyll commented Oct 1, 2025

I meant it should be part of #162637

I see thanks for clarifying, I misread the bot message! We have a workflow that still doesn't recognize it as being cherrypicked which is why it got flagged to me. I'll close the issue thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged module: onnx Related to torch.onnx open source release notes: onnx torch.onnx related changes that should show up in the release notes topic: bc breaking topic category topic: bug fixes topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ONNX] Set fallback=False by default

6 participants