Skip to content

[ONNX] Use ASCII markers for export progress output - #199522

Closed
Mohit-25-tech wants to merge 3 commits into
pytorch:mainfrom
Mohit-25-tech:fix/onnx-export-ascii-progress-unknown
Closed

Mohit-25-tech wants to merge 3 commits into
pytorch:mainfrom
Mohit-25-tech:fix/onnx-export-ascii-progress-unknown

Conversation

@Mohit-25-tech

@Mohit-25-tech Mohit-25-tech commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #199501

The dynamo ONNX exporter uses Unicode check/cross markers (✅ / ❌) in
fixed verbose progress messages.

On terminals using a strict non-UTF-8 encoding such as cp1252, these
characters cannot be encoded and can raise UnicodeEncodeError, causing
an otherwise valid ONNX export to fail.

This PR replaces the fixed Unicode progress markers with ASCII
[OK] and [FAIL] markers.

Changes

  • Replace fixed ✅ progress markers with [OK]
  • Replace fixed ❌ progress markers with [FAIL]
  • Apply the change consistently in:
    • torch/onnx/_internal/exporter/_capture_strategies.py
    • torch/onnx/_internal/exporter/_core.py
  • Add a regression test covering strict cp1252 stdout through the
    public torch.onnx.export(..., dynamo=True, verbose=True) API.
  • Leave Unicode used in generated reports unchanged.

Behavior

The existing:

  • verbose behavior
  • progress messages
  • control flow
  • exception handling
  • failure behavior

remain unchanged. Only the fixed progress markers are changed to
ASCII-safe representations.

Testing

  • py_compile on the edited files — passed
  • Strict cp1252 stdout smoke test — passed
  • Scoped git diff --check — passed
  • Public ONNX exporter regression tests could not be executed locally
    because this source checkout lacks the generated PyTorch version/native
    _C build and required ONNX test dependencies.

The regression test is designed to reproduce the encoding failure using
a strict cp1252 TextIOWrapper.

cc @justinchuby @titaiwangms @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @chauhang @amjames @jataylo @azahed98

@pytorch-bot pytorch-bot Bot added ciflow/inductor ciflow/torchtitan Run TorchTitan integration tests module: dynamo release notes: onnx torch.onnx related changes that should show up in the release notes labels Oct 2, 2026
@pytorch-bot

pytorch-bot Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

Please fix all CI failures and trigger merge by commenting "@pytorchbot merge".

🔗 Helpful Links

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

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

✅ No Failures

As of commit 2fa2e4c with merge base 2a741c2 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@pytorch-bot

pytorch-bot Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@Mohit-25-tech

Copy link
Copy Markdown
Contributor Author

@justinchuby Could you please approve the pending CI workflows for this PR when you have a chance? The ci/inductor and ci/torchtitan workflows are currently waiting for maintainer approval. Thanks!

@Skylion007

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorch-bot

pytorch-bot Bot commented Oct 2, 2026

Copy link
Copy Markdown

This PR needs to be approved by an authorized maintainer before merge.

@Skylion007

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -i

@pytorch-bot

pytorch-bot Bot commented Oct 2, 2026

Copy link
Copy Markdown

This PR needs to be approved by an authorized maintainer before merge.

@Mohit-25-tech

Copy link
Copy Markdown
Contributor Author

I investigated the two failing Inductor/AOTI checks. Both failures occur in generated C++/FileCheck paths that do not invoke the ONNX exporter code changed by this PR. No workflow, build configuration, or shared ONNX utility was changed. I therefore left the PR unchanged.

pytorchmergebot pushed a commit that referenced this pull request Oct 2, 2026
The Auto PR Triage ownership step still runs on Sonnet 4.6, while the other
Claude triage workflows (claude-issue-triage-run.yml,
claude-distributed-triage.yml) already moved to
`global.anthropic.claude-sonnet-5`. This switches the auto-pr-triage action
to the same model.

Motivation: a recent batch of re-triaged open source PRs (#199461, #199497,
#199513, #199522, #199537) all ended in `bot-triage-error` because the
Sonnet 4.6 ownership run failed. Mostly it quoted diff excerpts that are not
verbatim in the patch, which `validate_ownership.py` rejects. Once it
returned no `structured_output` for `--json-schema`. Other flags (`--effort
low`, `--json-schema`, the turn and budget caps) are supported unchanged on
Sonnet 5.

Test Plan:
The workflow runs on `pull_request_target`, so it executes from the base
branch and this change only takes effect after it lands. The Bedrock model ID
is the one the issue triage workflows already use in production:

```
git grep -n "global.anthropic.claude-sonnet-5" -- .github
```

After landing, re-label a few of the PRs above (remove `bot-triage-error`,
then remove and re-add `open source`) and check the Auto PR Triage runs.

This PR was authored with the help of an AI assistant (Claude Code).
Pull Request resolved: #199570
Approved by: https://github.com/janeyx99
@justinchuby

Copy link
Copy Markdown
Collaborator

Thanks

@janeyx99 janeyx99 added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Oct 6, 2026
@justinchuby

Copy link
Copy Markdown
Collaborator

@pytorchbot rebase -b main

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/main. Check the current status here

Mohit-25-tech and others added 3 commits November 1, 2026 17:39
The source-name cache removes definition scopes on DEDENT, which is absent
for same-line bodies. Those names therefore leaked into subsequent source
lines. Pop a definition after its logical newline when the next significant
token is not INDENT, preserving the name on the declaration itself.

Add coverage for one-line classes, functions, overloads and async functions,
alongside nested scopes and multiline signatures with comments before the body.

Fixes pytorch#199314

Test Plan:
Used a prebuilt CPU nightly and loaded the modified parser into the installed
package with the temporary run_funcname_tests.py bootstrap; no source build.

```powershell
$env:TORCHINDUCTOR_WINDOWS_TESTS='1'
.venv/Scripts/python.exe -I agent_space/run_funcname_tests.py test_misc.py MiscTests.test_funcname_cache MiscTests.test_funcname_cache_single_line -v
.venv/Scripts/python.exe -I agent_space/run_funcname_tests.py test_logging.py -k trace_source -v
.venv/Scripts/python.exe -I agent_space/run_funcname_tests.py test_logging.py -k trace_call -v
.venv/Scripts/python.exe -I agent_space/check_funcname_scopes.py
.venv/Scripts/python.exe -I agent_space/run_funcname_typecheck.py
.venv/Scripts/python.exe -I agent_space/run_python_lint.py --fix
git diff --check -- torch/_dynamo/funcname_cache.py test/dynamo/test_misc.py
```

The new regression passed and its snapshot failed against the original parser.
Ten AST scope checks and the Module._call_impl reproduction passed. Five
trace_source tests passed; the simple test hit a fallback because MSVC is absent.
The existing funcname test is skipped on Windows; four trace_call tests require
Python >=3.11 and were skipped on Python 3.10. Pyrefly reported zero errors.
The seven selected Python linters passed via Spin's helper. A temporary wrapper
normalized Windows extended paths for the unchanged official formatter.

Prepared with assistance from Codex.
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Successfully rebased fix/onnx-export-ascii-progress-unknown onto refs/remotes/origin/main, please pull locally before adding more changes (for example, via git checkout fix/onnx-export-ascii-progress-unknown && git pull --rebase)

@pytorchmergebot
pytorchmergebot force-pushed the fix/onnx-export-ascii-progress-unknown branch from fe4767a to 2fa2e4c Compare November 1, 2026 17:40

@justinchuby justinchuby left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pytorchbot merge

@pytorch-bot

pytorch-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown

+1

@justinchuby justinchuby added module: onnx Related to torch.onnx and removed module: dynamo labels Nov 3, 2026
@github-project-automation github-project-automation Bot moved this to Inbox in ONNX Nov 3, 2026
@github-project-automation github-project-automation Bot moved this from Inbox to Approved in ONNX Nov 3, 2026
@justinchuby justinchuby removed ciflow/inductor ciflow/torchtitan Run TorchTitan integration tests labels Nov 3, 2026
@pytorchmergebot

Copy link
Copy Markdown
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

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: Could not find commit that was pushed before comment 5755903344

Details for Dev Infra team

Raised by workflow job

@justinchuby

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -i

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged while ignoring the following 0 checks:

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

@github-project-automation github-project-automation Bot moved this from Approved to Done in ONNX Nov 3, 2026
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 5, 2026
## Summary

Fixes pytorch#199501

The dynamo ONNX exporter uses Unicode check/cross markers (`✅` / `❌`) in
fixed verbose progress messages.

On terminals using a strict non-UTF-8 encoding such as `cp1252`, these
characters cannot be encoded and can raise `UnicodeEncodeError`, causing
an otherwise valid ONNX export to fail.

This PR replaces the fixed Unicode progress markers with ASCII
`[OK]` and `[FAIL]` markers.

## Changes

- Replace fixed `✅` progress markers with `[OK]`
- Replace fixed `❌` progress markers with `[FAIL]`
- Apply the change consistently in:
  - `torch/onnx/_internal/exporter/_capture_strategies.py`
  - `torch/onnx/_internal/exporter/_core.py`
- Add a regression test covering strict `cp1252` stdout through the
  public `torch.onnx.export(..., dynamo=True, verbose=True)` API.
- Leave Unicode used in generated reports unchanged.

## Behavior

The existing:

- verbose behavior
- progress messages
- control flow
- exception handling
- failure behavior

remain unchanged. Only the fixed progress markers are changed to
ASCII-safe representations.

## Testing

- `py_compile` on the edited files — passed
- Strict `cp1252` stdout smoke test — passed
- Scoped `git diff --check` — passed
- Public ONNX exporter regression tests could not be executed locally
  because this source checkout lacks the generated PyTorch version/native
  `_C` build and required ONNX test dependencies.

The regression test is designed to reproduce the encoding failure using
a strict `cp1252` `TextIOWrapper`.

Pull Request resolved: pytorch#199522
Approved by: https://github.com/titaiwangms, https://github.com/justinchuby

Co-authored-by: Copilot <[email protected]>
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
## Summary

Fixes pytorch#199501

The dynamo ONNX exporter uses Unicode check/cross markers (`✅` / `❌`) in
fixed verbose progress messages.

On terminals using a strict non-UTF-8 encoding such as `cp1252`, these
characters cannot be encoded and can raise `UnicodeEncodeError`, causing
an otherwise valid ONNX export to fail.

This PR replaces the fixed Unicode progress markers with ASCII
`[OK]` and `[FAIL]` markers.

## Changes

- Replace fixed `✅` progress markers with `[OK]`
- Replace fixed `❌` progress markers with `[FAIL]`
- Apply the change consistently in:
  - `torch/onnx/_internal/exporter/_capture_strategies.py`
  - `torch/onnx/_internal/exporter/_core.py`
- Add a regression test covering strict `cp1252` stdout through the
  public `torch.onnx.export(..., dynamo=True, verbose=True)` API.
- Leave Unicode used in generated reports unchanged.

## Behavior

The existing:

- verbose behavior
- progress messages
- control flow
- exception handling
- failure behavior

remain unchanged. Only the fixed progress markers are changed to
ASCII-safe representations.

## Testing

- `py_compile` on the edited files — passed
- Strict `cp1252` stdout smoke test — passed
- Scoped `git diff --check` — passed
- Public ONNX exporter regression tests could not be executed locally
  because this source checkout lacks the generated PyTorch version/native
  `_C` build and required ONNX test dependencies.

The regression test is designed to reproduce the encoding failure using
a strict `cp1252` `TextIOWrapper`.

Pull Request resolved: pytorch#199522
Approved by: https://github.com/titaiwangms, https://github.com/justinchuby

Co-authored-by: Copilot <[email protected]>
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 triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[ONNX] torch.onnx.export crashes with UnicodeEncodeError on non-UTF-8 terminals (emojis in output)

9 participants