Skip to content

Fix torch.fx for the newer "|" union syntax - #169453

Closed
cyyever wants to merge 2 commits into
pytorch:mainfrom
cyyever:import_union
Closed

cyyever wants to merge 2 commits into
pytorch:mainfrom
cyyever:import_union

Conversation

@cyyever

@cyyever cyyever commented Dec 3, 2025 •

Copy link
Copy Markdown
Collaborator

This PR fixes torch.fx handling of the newer | type. Otherwise, they could be errors like

"/torch/package/importer.py", line 95, in get_name
     name = obj.__name__
    AttributeError: 'types.UnionType' object has no attribute '__name__'. Did you mean: '__ne__'?

cc @ezyang @EikanWang @jgong5 @wenzhe-nrv

@pytorch-bot

pytorch-bot Bot commented Dec 3, 2025 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

⏳ No Failures, 34 Pending

As of commit 07434f2 with merge base 3051687 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@cyyever
cyyever requested review from aorenste and huydhn December 3, 2025 05:12
@cyyever

cyyever commented Dec 3, 2025

Copy link
Copy Markdown
Collaborator Author

@pytorchbot label "topic: not user facing"

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Dec 3, 2025
Comment thread torch/package/importer.py Resolved
@huydhn

huydhn commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

Let me find a reviewer who know this part to have a second opinion

@cyyever

cyyever commented Dec 3, 2025

Copy link
Copy Markdown
Collaborator Author

@huydhn @aorenste See the discussion at https://bugs.python.org/issue44524

@cyyever
cyyever force-pushed the import_union branch 2 times, most recently from 87b6501 to 691f2e0 Compare December 3, 2025 07:55
@cyyever cyyever changed the title Fix module_name finding of Union Fix torch.fx for the newer "|" union Dec 3, 2025
@cyyever cyyever changed the title Fix torch.fx for the newer "|" union Fix torch.fx for the newer "|" union syntax Dec 3, 2025
@cyyever
cyyever requested review from XuehaiPan and albanD December 3, 2025 08:01
@cyyever
cyyever force-pushed the import_union branch 3 times, most recently from e4f46de to 9b55ff5 Compare December 3, 2025 08:56

@albanD albanD 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.

Thanks!

@cyyever
cyyever marked this pull request as draft December 3, 2025 23:45
Signed-off-by: cyy <[email protected]>
Signed-off-by: cyy <[email protected]>
@pytorch-bot pytorch-bot Bot removed the oncall: fx label Dec 4, 2025
@pytorch-bot

pytorch-bot Bot commented Dec 4, 2025

Copy link
Copy Markdown

The label oncall: fx is only applicable to issues and has been removed. Please only use this label on issues.

@cyyever

cyyever commented Dec 4, 2025

Copy link
Copy Markdown
Collaborator Author

@pytorchmergebot merge -f "ROCm pending"

@pytorchmergebot

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

@cyyever
cyyever deleted the import_union branch December 4, 2025 04:03
@pytorch-auto-revert

Copy link
Copy Markdown

@pytorchbot revert -m "Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable" -c autorevert

This PR is attributed to have caused regression in:

Please investigate and fix the issues.

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot successfully started a revert job. Check the current status here.
Questions? Feedback? Please reach out to the PyTorch DevX Team

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@cyyever your PR has been successfully reverted.

pytorchmergebot added a commit that referenced this pull request Dec 4, 2025
This reverts commit a15066c.

Reverted #169453 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](#169453 (comment)))
@pytorchmergebot pytorchmergebot added Reverted ci-no-td Do not run TD on this PR labels Dec 4, 2025
@cyyever
cyyever restored the import_union branch December 4, 2025 06:24
@cyyever cyyever reopened this Dec 4, 2025
@cyyever

cyyever commented Dec 4, 2025

Copy link
Copy Markdown
Collaborator Author

@pytorchmergebot merge -f "Unrelated autorevert"

@pytorchmergebot

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

@cyyever
cyyever deleted the import_union branch December 4, 2025 07:48
umechand-amd pushed a commit to ROCm/pytorch that referenced this pull request Dec 8, 2025
This reverts commit a15066c.

Reverted pytorch#169453 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](pytorch#169453 (comment)))
umechand-amd pushed a commit to ROCm/pytorch that referenced this pull request Dec 8, 2025
This PR fixes torch.fx handling of the newer `|` type. Otherwise, they could be errors like
```
"/torch/package/importer.py", line 95, in get_name
     name = obj.__name__
    AttributeError: 'types.UnionType' object has no attribute '__name__'. Did you mean: '__ne__'?
```

Pull Request resolved: pytorch#169453
Approved by: https://github.com/albanD, https://github.com/malfet
JacobSzwejbka pushed a commit that referenced this pull request Dec 8, 2025
This PR fixes torch.fx handling of the newer `|` type. Otherwise, they could be errors like
```
"/torch/package/importer.py", line 95, in get_name
     name = obj.__name__
    AttributeError: 'types.UnionType' object has no attribute '__name__'. Did you mean: '__ne__'?
```

Pull Request resolved: #169453
Approved by: https://github.com/albanD, https://github.com/malfet
JacobSzwejbka pushed a commit that referenced this pull request Dec 8, 2025
This reverts commit a15066c.

Reverted #169453 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](#169453 (comment)))
JacobSzwejbka pushed a commit that referenced this pull request Dec 8, 2025
This PR fixes torch.fx handling of the newer `|` type. Otherwise, they could be errors like
```
"/torch/package/importer.py", line 95, in get_name
     name = obj.__name__
    AttributeError: 'types.UnionType' object has no attribute '__name__'. Did you mean: '__ne__'?
```

Pull Request resolved: #169453
Approved by: https://github.com/albanD, https://github.com/malfet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td Do not run TD on this PR ciflow/trunk Trigger trunk jobs on your pull request Merged module: fx open source Reverted topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants