Skip to content

Use Storages for Cudagraph liveness - #96154

Closed
eellison wants to merge 9 commits into
gh/eellison/391/basefrom
gh/eellison/391/head
Closed

eellison wants to merge 9 commits into
gh/eellison/391/basefrom
gh/eellison/391/head

Conversation

@eellison

@eellison eellison commented Mar 7, 2023 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

In the previous PR we used tensors for liveness. This isn't actually correct as we should be treating a cudagraph output as dead only when its storage is dead, not the tensor impl output. The previous handling also had a particularly bad interaction with aot autograd detaching, since it would treat all outputs as dead.

I'm using StorageWeakRef from reductions.py. This is sufficient for checking if a storage has died, although it doesn't allow you to trigger an event immediately upon deallocation. That works fine for most of the handling of the storage weak ref. The one case it doesn't is if you deallocated a torch dynamo function and its cudagraph wrapper, but you still have a Tensor output of it that you need to wait on to deallocate the cudagraph memory pool. We would need to trigger an event in order to do proper deferred deletion of the cudagraph. I'm deferring that till #91395 has landed, but that shouldn't be a particularly common case.

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

Differential Revision: D43999890

@pytorch-bot

pytorch-bot Bot commented Mar 7, 2023 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

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

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

In the previous PR we used tensors for liveness. This isn't actually correct as we should be treating a cudagraph output as dead only when its storage is dead, not the tensor impl output. The previous handling also had a particularly bad interaction with aot autograd detaching, since it would treat all outputs as dead. 

I'm using `StorageWeakRef` from `reductions.py`. This is sufficient for checking if a storage has died, although it doesn't allow you to trigger an event immediately upon deallocation. That works fine for most of the handling of the storage weak ref. The one case it doesn't is if you deallocated a torch dynamo function and its cudagraph wrapper, but you still have a Tensor output of it that you need to wait on to deallocate the cudagraph memory pool.  We would need to trigger an event in order to do proper deferred deletion of the cudagraph. I'm deferring that till #91395 has landed, but that shouldn't be a particularly common case. 



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

[ghstack-poisoned]
In the previous PR we used tensors for liveness. This isn't actually correct as we should be treating a cudagraph output as dead only when its storage is dead, not the tensor impl output. The previous handling also had a particularly bad interaction with aot autograd detaching, since it would treat all outputs as dead. 

I'm using `StorageWeakRef` from `reductions.py`. This is sufficient for checking if a storage has died, although it doesn't allow you to trigger an event immediately upon deallocation. That works fine for most of the handling of the storage weak ref. The one case it doesn't is if you deallocated a torch dynamo function and its cudagraph wrapper, but you still have a Tensor output of it that you need to wait on to deallocate the cudagraph memory pool.  We would need to trigger an event in order to do proper deferred deletion of the cudagraph. I'm deferring that till #91395 has landed, but that shouldn't be a particularly common case. 



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

[ghstack-poisoned]
eellison added a commit that referenced this pull request Mar 7, 2023
ghstack-source-id: f7b0baa
Pull Request resolved: #96154
In the previous PR we used tensors for liveness. This isn't actually correct as we should be treating a cudagraph output as dead only when its storage is dead, not the tensor impl output. The previous handling also had a particularly bad interaction with aot autograd detaching, since it would treat all outputs as dead. 

I'm using `StorageWeakRef` from `reductions.py`. This is sufficient for checking if a storage has died, although it doesn't allow you to trigger an event immediately upon deallocation. That works fine for most of the handling of the storage weak ref. The one case it doesn't is if you deallocated a torch dynamo function and its cudagraph wrapper, but you still have a Tensor output of it that you need to wait on to deallocate the cudagraph memory pool.  We would need to trigger an event in order to do proper deferred deletion of the cudagraph. I'm deferring that till #91395 has landed, but that shouldn't be a particularly common case. 



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

[ghstack-poisoned]
In the previous PR we used tensors for liveness. This isn't actually correct as we should be treating a cudagraph output as dead only when its storage is dead, not the tensor impl output. The previous handling also had a particularly bad interaction with aot autograd detaching, since it would treat all outputs as dead. 

I'm using `StorageWeakRef` from `reductions.py`. This is sufficient for checking if a storage has died, although it doesn't allow you to trigger an event immediately upon deallocation. That works fine for most of the handling of the storage weak ref. The one case it doesn't is if you deallocated a torch dynamo function and its cudagraph wrapper, but you still have a Tensor output of it that you need to wait on to deallocate the cudagraph memory pool.  We would need to trigger an event in order to do proper deferred deletion of the cudagraph. I'm deferring that till #91395 has landed, but that shouldn't be a particularly common case. 



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

[ghstack-poisoned]
In the previous PR we used tensors for liveness. This isn't actually correct as we should be treating a cudagraph output as dead only when its storage is dead, not the tensor impl output. The previous handling also had a particularly bad interaction with aot autograd detaching, since it would treat all outputs as dead. 

I'm using `StorageWeakRef` from `reductions.py`. This is sufficient for checking if a storage has died, although it doesn't allow you to trigger an event immediately upon deallocation. That works fine for most of the handling of the storage weak ref. The one case it doesn't is if you deallocated a torch dynamo function and its cudagraph wrapper, but you still have a Tensor output of it that you need to wait on to deallocate the cudagraph memory pool.  We would need to trigger an event in order to do proper deferred deletion of the cudagraph. I'm deferring that till #91395 has landed, but that shouldn't be a particularly common case. 



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

[ghstack-poisoned]
@davidberard98

Copy link
Copy Markdown
Contributor

@davidberard98 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

In the previous PR we used tensors for liveness. This isn't actually correct as we should be treating a cudagraph output as dead only when its storage is dead, not the tensor impl output. The previous handling also had a particularly bad interaction with aot autograd detaching, since it would treat all outputs as dead. 

I'm using `StorageWeakRef` from `reductions.py`. This is sufficient for checking if a storage has died, although it doesn't allow you to trigger an event immediately upon deallocation. That works fine for most of the handling of the storage weak ref. The one case it doesn't is if you deallocated a torch dynamo function and its cudagraph wrapper, but you still have a Tensor output of it that you need to wait on to deallocate the cudagraph memory pool.  We would need to trigger an event in order to do proper deferred deletion of the cudagraph. I'm deferring that till #91395 has landed, but that shouldn't be a particularly common case. 



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

Differential Revision: [D43999890](https://our.internmc.facebook.com/intern/diff/D43999890)

[ghstack-poisoned]
In the previous PR we used tensors for liveness. This isn't actually correct as we should be treating a cudagraph output as dead only when its storage is dead, not the tensor impl output. The previous handling also had a particularly bad interaction with aot autograd detaching, since it would treat all outputs as dead. 

I'm using `StorageWeakRef` from `reductions.py`. This is sufficient for checking if a storage has died, although it doesn't allow you to trigger an event immediately upon deallocation. That works fine for most of the handling of the storage weak ref. The one case it doesn't is if you deallocated a torch dynamo function and its cudagraph wrapper, but you still have a Tensor output of it that you need to wait on to deallocate the cudagraph memory pool.  We would need to trigger an event in order to do proper deferred deletion of the cudagraph. I'm deferring that till #91395 has landed, but that shouldn't be a particularly common case. 



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

Differential Revision: [D43999890](https://our.internmc.facebook.com/intern/diff/D43999890)

[ghstack-poisoned]
In the previous PR we used tensors for liveness. This isn't actually correct as we should be treating a cudagraph output as dead only when its storage is dead, not the tensor impl output. The previous handling also had a particularly bad interaction with aot autograd detaching, since it would treat all outputs as dead. 

I'm using `StorageWeakRef` from `reductions.py`. This is sufficient for checking if a storage has died, although it doesn't allow you to trigger an event immediately upon deallocation. That works fine for most of the handling of the storage weak ref. The one case it doesn't is if you deallocated a torch dynamo function and its cudagraph wrapper, but you still have a Tensor output of it that you need to wait on to deallocate the cudagraph memory pool.  We would need to trigger an event in order to do proper deferred deletion of the cudagraph. I'm deferring that till #91395 has landed, but that shouldn't be a particularly common case. 



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

Differential Revision: [D43999890](https://our.internmc.facebook.com/intern/diff/D43999890)

[ghstack-poisoned]
@eellison eellison mentioned this pull request Mar 14, 2023
@eellison

Copy link
Copy Markdown
Contributor Author

Squashed into #89146

@eellison eellison closed this Mar 15, 2023
eellison added a commit that referenced this pull request Mar 16, 2023
ghstack-source-id: c2aa27e
Pull Request resolved: #89146

Use Storages for Cudagraph liveness

ghstack-source-id: c2aa27e
Pull Request resolved: #96154

Do warmup in cudagraph pool

ghstack-source-id: c2aa27e
Pull Request resolved: #96433

Comments for cuda graph trees

Signed-off-by: Edward Z. Yang <ezyangmeta.com>

ghstack-source-id: c2aa27e
Pull Request resolved: #96932
@facebook-github-bot
facebook-github-bot deleted the gh/eellison/391/head branch June 8, 2023 16:19
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.

2 participants