Skip to content

Avoid writing temporary modules to disk#157713

Closed
apmorton wants to merge 4 commits intopytorch:mainfrom
apmorton:patch-1
Closed

Avoid writing temporary modules to disk#157713
apmorton wants to merge 4 commits intopytorch:mainfrom
apmorton:patch-1

Conversation

@apmorton
Copy link
Copy Markdown
Contributor

@apmorton apmorton commented Jul 7, 2025

In some cases the warning from #147744 still gets emitted because atexit hooks aren't called.

Even in those cases, if the atexit hooks were called you could end up with issues due to the directory being deleted in one process, but still being used elsewhere.

It's better all round to load these modules entirely in-memory.

cc @H-Huang @awgu @wanchaol @fegin @fduwjj @wz337 @wconstab @d4l3k @pragupta @ezyang @msaroufim @dcci @EikanWang @jgong5 @wenzhe-nrv @sanchitintel

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Jul 7, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit 7350062 with merge base a2b6afe (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
Copy Markdown

linux-foundation-easycla bot commented Jul 7, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@pytorch-bot pytorch-bot bot added the oncall: distributed Add this issue/PR to distributed oncall triage queue label Jul 7, 2025
@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Jul 7, 2025
@apmorton
Copy link
Copy Markdown
Contributor Author

apmorton commented Jul 7, 2025

@pytorchbot label "topic: not user facing"

@pytorch-bot pytorch-bot bot added the topic: not user facing topic category label Jul 7, 2025
@apmorton apmorton marked this pull request as ready for review July 7, 2025 13:41
@jerryzh168 jerryzh168 requested review from ezyang and justinchuby July 8, 2025 22:24
@jerryzh168 jerryzh168 added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jul 8, 2025
@ezyang
Copy link
Copy Markdown
Contributor

ezyang commented Jul 9, 2025

This seems morally ok but @xush6528 should really take a look

@ezyang ezyang requested a review from xush6528 July 9, 2025 02:36
@xush6528
Copy link
Copy Markdown
Contributor

@apmorton Can you check if the test failures are relevant?

@apmorton
Copy link
Copy Markdown
Contributor Author

linux-jammy-py3-clang12-mobile-build / build seems unrelated; I've hopefully addressed the other two

@apmorton
Copy link
Copy Markdown
Contributor Author

@xush6528 CI is green

return generated_module
module = importlib.util.module_from_spec(spec)
sys.modules[generated_module_name] = module
spec.loader.exec_module(module)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Make sense to me.

@github-actions
Copy link
Copy Markdown
Contributor

Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as Stale.
Feel free to remove the Stale label if you feel this was a mistake.
If you are unable to remove the Stale label please contact a maintainer in order to do so.
If you want the bot to never mark this PR stale again, add the no-stale label.
Stale pull requests will automatically be closed after 30 days of inactivity.

@github-actions github-actions bot added the Stale label Sep 22, 2025
@apmorton
Copy link
Copy Markdown
Contributor Author

@xush6528 can we merge this?

@xush6528
Copy link
Copy Markdown
Contributor

I got this message:

Merging is blocked
You're not authorized to push to this branch. Visit https://docs.github.com/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches for more information.

@ezyang Do you know how to operate on this?

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@xush6528 has imported this pull request. If you are a Meta employee, you can view this in D83008532.

@ezyang
Copy link
Copy Markdown
Contributor

ezyang commented Sep 24, 2025

I guess apmorton didn't allow maintainer pushes. Can you just make a new PR with this change crediting apmorton and I will stamp it? Thanks.

@ezyang ezyang removed the Stale label Sep 24, 2025
@ezyang
Copy link
Copy Markdown
Contributor

ezyang commented Sep 24, 2025

@pytorchbot merge -r

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Sep 24, 2025
@pytorchmergebot
Copy link
Copy Markdown
Collaborator

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

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Successfully rebased patch-1 onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout patch-1 && git pull --rebase)

@pytorch-bot pytorch-bot bot removed the ciflow/trunk Trigger trunk jobs on your pull request label Sep 24, 2025
@ezyang
Copy link
Copy Markdown
Contributor

ezyang commented Oct 27, 2025

@pytorchbot merge -r

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

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

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Successfully rebased patch-1 onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout patch-1 && git pull --rebase)

@pytorch-bot pytorch-bot bot removed the ciflow/trunk Trigger trunk jobs on your pull request label Oct 27, 2025
@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: 3 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

@ezyang
Copy link
Copy Markdown
Contributor

ezyang commented Oct 27, 2025

@pytorchbot merge

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

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.

@ezyang
Copy link
Copy Markdown
Contributor

ezyang commented Oct 29, 2025

@pytorchbot merge

@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

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.

@ezyang
Copy link
Copy Markdown
Contributor

ezyang commented Oct 30, 2025

@pytorchbot merge -f "all green"

@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

BoyuanFeng pushed a commit that referenced this pull request Oct 31, 2025
In some cases the warning from #147744 still gets emitted because [atexit hooks aren't called](python/cpython#114279).

Even in those cases, if the atexit hooks _were_ called you could end up with issues due to the directory being deleted in one process, but still being used elsewhere.

It's better all round to load these modules entirely in-memory.

Pull Request resolved: #157713
Approved by: https://github.com/xush6528
etaf pushed a commit to etaf/pytorch-inductor-xpu that referenced this pull request Nov 4, 2025
In some cases the warning from pytorch#147744 still gets emitted because [atexit hooks aren't called](python/cpython#114279).

Even in those cases, if the atexit hooks _were_ called you could end up with issues due to the directory being deleted in one process, but still being used elsewhere.

It's better all round to load these modules entirely in-memory.

Pull Request resolved: pytorch#157713
Approved by: https://github.com/xush6528
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 oncall: distributed Add this issue/PR to distributed oncall triage queue oncall: jit Add this issue/PR to JIT oncall triage queue open source topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants