Skip to content

[export] Enable context manager returns for dynamo graph capture.#168102

Closed
zhxchen17 wants to merge 1 commit intomainfrom
zhxchen17/export/ctx_return
Closed

[export] Enable context manager returns for dynamo graph capture.#168102
zhxchen17 wants to merge 1 commit intomainfrom
zhxchen17/export/ctx_return

Conversation

@zhxchen17
Copy link
Contributor

@zhxchen17 zhxchen17 commented Nov 18, 2025

Summary:
This adds the ability to trace through the code which has context manager enabled
and returned in a user callable.

Since we rely on side effects to return user defined variables, we cannot disable
side effects by default anymore in the short term. So we decide to leave
side effect config up to the caller side of dynamo_graph_capture_for_export,
and still disable it for torch.export by default. In the short term we will
just assume dynamo_graph_capture_for_export is a low level API and it's user
responsibility to control side effect options.

Test Plan:
CI
Reviewers:

Subscribers:

Tasks:

Tags:

Fixes #ISSUE_NUMBER

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @chauhang @amjames @Lucaskabela

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 18, 2025

🔗 Helpful Links

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

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

⏳ No Failures, 1 Pending

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

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

Summary:
This adds the ability to trace through the code which has context manager enabled
and returned in a user callable.

Since we rely on side effects to return user defined variables, we cannot disable
side effects by default anymore in the short term. So we decide to leave
side effect config up to the caller side of dynamo_graph_capture_for_export,
and still disable it for torch.export by default. In the short term we will
just assume dynamo_graph_capture_for_export is a low level API and it's user
responsibility to control side effect options.

Test Plan:
CI
Reviewers:

Subscribers:

Tasks:

Tags:
@zhxchen17 zhxchen17 force-pushed the zhxchen17/export/ctx_return branch from f13ed2d to d934885 Compare November 19, 2025 01:15
@zhxchen17
Copy link
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 19, 2025
@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

@github-actions github-actions bot deleted the zhxchen17/export/ctx_return branch December 20, 2025 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants