Skip to content

Make sure we dealloc on recording, not just replay - #97440

Closed
eellison wants to merge 22 commits into
gh/eellison/406/basefrom
gh/eellison/406/head
Closed

eellison wants to merge 22 commits into
gh/eellison/406/basefrom
gh/eellison/406/head

Conversation

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Mar 23, 2023 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ No Failures

As of commit 01642a2:
💚 Looks good so far! There are no failures yet. 💚

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

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
@eellison
eellison requested review from ezyang and removed request for ezyang March 28, 2023 04:41
Copy over non cuda graph inputs as we are allocating the recording inputs so they do not need to be allocated as we record the graph. 

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 ng5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
Copy over non cuda graph inputs as we are allocating the recording inputs so they do not need to be allocated as we record the graph. 

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 ng5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
Copy over non cuda graph inputs as we are allocating the recording inputs so they do not need to be allocated as we record the graph. 

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 ng5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
@eellison eellison changed the title [wip] Make sure we dealloc on recording, not just replay Mar 30, 2023
Copy over non cuda graph inputs as we are allocating the recording inputs so they do not need to be allocated as we record the graph. 

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 ng5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
@eellison eellison added the topic: not user facing topic category label Mar 30, 2023
@eellison
eellison requested a review from ezyang March 30, 2023 22:10
Copy over non cuda graph inputs as we are allocating the recording inputs so they do not need to be allocated as we record the graph. 

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire ng5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
@eellison
eellison requested a review from ngimel March 30, 2023 22:19
Copy over non cuda graph inputs as we are allocating the recording inputs so they do not need to be allocated as we record the graph. 

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire ng5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
Comment thread torch/_inductor/compile_fx.py Resolved
Comment thread torch/_inductor/cudagraph_trees.py Outdated

torch.cuda.synchronize()
self.stream = torch.cuda.Stream()
self.stream.wait_stream(torch.cuda.current_stream())

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.

weird that this used to work, what's going on here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure why this change triggered a failure in multi device scenario - but i added additional tests/run for multi device

Comment thread torch/_inductor/cudagraph_trees.py Resolved
Comment thread torch/_inductor/cudagraph_trees.py Outdated
self.graph, stream=self.stream, pool=self.cuda_graphs_pool
):
static_outputs = model(inputs)
with preserve_rng_state():

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.

nit: You don't actually need to nest the context managers right? You can chain this one with the rest.

)
unique_storages.remove(addr)
if addr not in unique_storages:
allocated_not_in_live_storages.append(addr)

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.

I guess addresses isn't going to be terribly useful but I guess we don't have stack traces (or maybe we do, if @zdevito's thing is on?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yea - I have a WIP branch that will add memory recording to improve error messages. Am working on it.

Copy over non cuda graph inputs as we are allocating the recording inputs so they do not need to be allocated as we record the graph. 

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire ng5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
Copy over non cuda graph inputs as we are allocating the recording inputs so they do not need to be allocated as we record the graph. 

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire ng5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
Copy over non cuda graph inputs as we are allocating the recording inputs so they do not need to be allocated as we record the graph. 

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire ng5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
Copy over non cuda graph inputs as we are allocating the recording inputs so they do not need to be allocated as we record the graph. 

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire ng5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
Copy over non cuda graph inputs as we are allocating the recording inputs so they do not need to be allocated as we record the graph. 

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire ng5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
eellison added a commit that referenced this pull request Apr 3, 2023
Copy over non cuda graph inputs as we are allocating the recording inputs so they do not need to be allocated as we record the graph. 

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire ng5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
@eellison eellison mentioned this pull request Apr 4, 2023
Copy over non cuda graph inputs as we are allocating the recording inputs so they do not need to be allocated as we record the graph. 

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire ng5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
@eellison eellison added the ciflow/trunk Trigger trunk jobs on your pull request label Apr 4, 2023
@eellison

eellison commented Apr 5, 2023

Copy link
Copy Markdown
Contributor Author

@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

eellison added a commit to eellison/pytorch that referenced this pull request Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants