Skip to content

Expose Stream Recording Apis in python - #96384

Closed
eellison wants to merge 14 commits into
gh/eellison/392/basefrom
gh/eellison/392/head
Closed

eellison wants to merge 14 commits into
gh/eellison/392/basefrom
gh/eellison/392/head

Conversation

@eellison

@eellison eellison commented Mar 9, 2023 •

Copy link
Copy Markdown
Contributor

@pytorch-bot

pytorch-bot Bot commented Mar 9, 2023 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

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

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

eellison added a commit that referenced this pull request Mar 9, 2023
@eellison
eellison requested a review from zdevito March 9, 2023 05:48
Comment thread test/test_cuda.py Resolved
…graph recording"


Exposes a way for users to do allocations to a private pool without doing a cudagraph capture. We assume that there is already an existing graph that was used to get a unique capture_id identifier, and then use that to reuse the existing apis. We mimic the existing cudagraph capture api by only doing allocations to a particular thread, just as the stream was thread-local.

This will be needed for the subsequent PR which will do warmup in a cudagraph pool. That pr also also adds some runtime checking which helped find a leaked cublas workspace allocation.

[ghstack-poisoned]
…graph recording"


Exposes a way for users to do allocations to a private pool without doing a cudagraph capture. We assume that there is already an existing graph that was used to get a unique capture_id identifier, and then use that to reuse the existing apis. We mimic the existing cudagraph capture api by only doing allocations to a particular thread, just as the stream was thread-local.

This will be needed for the subsequent PR which will do warmup in a cudagraph pool. That pr also also adds some runtime checking which helped find a leaked cublas workspace allocation.

[ghstack-poisoned]
…graph recording"


Exposes a way for users to do allocations to a private pool without doing a cudagraph capture. We assume that there is already an existing graph that was used to get a unique capture_id identifier, and then use that to reuse the existing apis. We mimic the existing cudagraph capture api by only doing allocations to a particular thread, just as the stream was thread-local.

This will be needed for the subsequent PR which will do warmup in a cudagraph pool. That pr also also adds some runtime checking which helped find a leaked cublas workspace allocation.

[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.

…graph recording"


Exposes a way for users to do allocations to a private pool without doing a cudagraph capture. We assume that there is already an existing graph that was used to get a unique capture_id identifier, and then use that to reuse the existing apis. We mimic the existing cudagraph capture api by only doing allocations to a particular thread, just as the stream was thread-local.

This will be needed for the subsequent PR which will do warmup in a cudagraph pool. That pr also also adds some runtime checking which helped find a leaked cublas workspace allocation.

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

[ghstack-poisoned]
…graph recording"


Exposes a way for users to do allocations to a private pool without doing a cudagraph capture. We assume that there is already an existing graph that was used to get a unique capture_id identifier, and then use that to reuse the existing apis. We mimic the existing cudagraph capture api by only doing allocations to a particular thread, just as the stream was thread-local.

This will be needed for the subsequent PR which will do warmup in a cudagraph pool. That pr also also adds some runtime checking which helped find a leaked cublas workspace allocation.

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

[ghstack-poisoned]
…graph recording"


Exposes a way for users to do allocations to a private pool without doing a cudagraph capture. We assume that there is already an existing graph that was used to get a unique capture_id identifier, and then use that to reuse the existing apis. We mimic the existing cudagraph capture api by only doing allocations to a particular thread, just as the stream was thread-local.

This will be needed for the subsequent PR which will do warmup in a cudagraph pool. That pr also also adds some runtime checking which helped find a leaked cublas workspace allocation.

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

[ghstack-poisoned]
@eellison eellison mentioned this pull request Mar 14, 2023
…graph recording"


Exposes a way for users to do allocations to a private pool without doing a cudagraph capture. We assume that there is already an existing graph that was used to get a unique capture_id identifier, and then use that to reuse the existing apis. We mimic the existing cudagraph capture api by only doing allocations to a particular thread, just as the stream was thread-local.

This will be needed for the subsequent PR which will do warmup in a cudagraph pool. That pr also also adds some runtime checking which helped find a leaked cublas workspace allocation.

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

[ghstack-poisoned]
…graph recording"


Exposes a way for users to do allocations to a private pool without doing a cudagraph capture. We assume that there is already an existing graph that was used to get a unique capture_id identifier, and then use that to reuse the existing apis. We mimic the existing cudagraph capture api by only doing allocations to a particular thread, just as the stream was thread-local.

This will be needed for the subsequent PR which will do warmup in a cudagraph pool. That pr also also adds some runtime checking which helped find a leaked cublas workspace allocation.

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

[ghstack-poisoned]
…graph recording"


Exposes a way for users to do allocations to a private pool without doing a cudagraph capture. We assume that there is already an existing graph that was used to get a unique capture_id identifier, and then use that to reuse the existing apis. We mimic the existing cudagraph capture api by only doing allocations to a particular thread, just as the stream was thread-local.

This will be needed for the subsequent PR which will do warmup in a cudagraph pool. That pr also also adds some runtime checking which helped find a leaked cublas workspace allocation.

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

[ghstack-poisoned]
…graph recording"


Exposes a way for users to do allocations to a private pool without doing a cudagraph capture. We assume that there is already an existing graph that was used to get a unique capture_id identifier, and then use that to reuse the existing apis. We mimic the existing cudagraph capture api by only doing allocations to a particular thread, just as the stream was thread-local.

This will be needed for the subsequent PR which will do warmup in a cudagraph pool. That pr also also adds some runtime checking which helped find a leaked cublas workspace allocation.

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

[ghstack-poisoned]
…graph recording"


Exposes a way for users to do allocations to a private pool without doing a cudagraph capture. We assume that there is already an existing graph that was used to get a unique capture_id identifier, and then use that to reuse the existing apis. We mimic the existing cudagraph capture api by only doing allocations to a particular thread, just as the stream was thread-local.

This will be needed for the subsequent PR which will do warmup in a cudagraph pool. That pr also also adds some runtime checking which helped find a leaked cublas workspace allocation.

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

[ghstack-poisoned]
@eellison eellison changed the title Expose API to allocate to private pool without doing cuda graph recording Expose Stream Recording Apis in python Mar 15, 2023

@zdevito zdevito left a comment

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.

Looks good. Couple minor comments.


m.def(
"_cuda_beginAllocateCurrentStreamToPool",
[](int device, at::cuda::MempoolId_t mempool_id) {

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: feels weird to use the default stream but explicit device vs (default device + default stream) or (explicit stream)

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.

True. Is there any way of passing a python object as CudaStream_t ?

Comment thread test/test_cuda.py
b = int8_cuda(LARGE_BUFFER)
del a, b

graph_thread = threading.Thread(target=use_pool)

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.

what is the intention of the threads here? In all likelihood without additional synchronization one is just going to run entirely before the other. Barriers placed inside the threads would guarantee some interleaving.

@eellison eellison added ciflow/trunk Trigger trunk jobs on your pull request topic: not user facing topic category labels Mar 16, 2023
@eellison

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

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 topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants