Skip to content

[CUDA] Serialize green-context stream-pool initialization - #199129

Closed
MatthiasKohl wants to merge 12 commits into
gh/MatthiasKohl/3/basefrom
gh/MatthiasKohl/3/head
Closed

MatthiasKohl wants to merge 12 commits into
gh/MatthiasKohl/3/basefrom
gh/MatthiasKohl/3/head

Conversation

@MatthiasKohl

@MatthiasKohl MatthiasKohl commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Stack from ghstack (oldest at bottom):

Fix potential races in green context stream pool slot selection/creation/indexing.

Authored with an AI assistant.

The lock covers creation through publication; failed creation leaves the index unchanged.

Test Plan

Tested on Rubin with driver R610 + CUDA 13.4 compat.
All 3 focused stream-pool tests passed.

python test/test_cuda.py TestGreenContextStreamPool -v

). This stack adds:

1. convenience functions to allocate localized memory
2. convenience function to execute operations in several green contexts through the fork/join pattern
3. minor fixes to green contexts discovered during testing of localized workloads

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

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

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

@MatthiasKohl
MatthiasKohl marked this pull request as ready for review September 30, 2026 10:35
@MatthiasKohl
MatthiasKohl requested a review from ngimel September 30, 2026 10:36
MatthiasKohl added a commit to MatthiasKohl/pytorch that referenced this pull request Sep 30, 2026
Fix potential races in green context stream pool slot selection/creation/indexing.

> Authored with an AI assistant.
>
> The lock covers creation through publication; failed creation leaves the index unchanged.

Test Plan

Tested on Rubin with driver R610 + CUDA 13.4 compat.
All 3 focused stream-pool tests passed.

```sh
python test/test_cuda.py TestGreenContextStreamPool -v
```


ghstack-source-id: 098f9c4
Pull-Request: pytorch#199129
@ngimel

ngimel commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

AI-assisted
Could we remove the standalone test_failed_stream_creation and retain the parametrized concurrency test? Failure already left the slot/index unchanged before this PR, and fail_first=True below covers failure followed by successful reuse. The standalone test repeats the mocked setup without exercising the race being fixed.

> AI-assisted: map-style stream execution, localized-output docs, trim redundant tests.

[ghstack-poisoned]
@MatthiasKohl

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 8, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: This PR needs a release notes: label
If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Details for Dev Infra team Raised by workflow job

@MatthiasKohl MatthiasKohl added the release notes: cuda release notes category label Oct 8, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #199130

pytorchmergebot pushed a commit that referenced this pull request Oct 8, 2026
….t. MPS (#199130)

Improve documentation of the NVML based check for locality support: later attachment to MPS isn't supported.

> Authored with an AI assistant.
>
> The limitation concerns the pre-initialization NVML estimate. Already attached clients use the CUDA driver path; query again after attachment rather than reusing an earlier estimate. These regression tests do not test dynamic MPS attachment.

Test Plan

Tested on Rubin with driver R610 + CUDA 13.4 compat.
All 10 existing locality-query regression tests passed.

```sh
python test/test_cuda.py TestCudaGreenContextsCUDA -k locality -v
```
Pull Request resolved: #199130
Approved by: https://github.com/ngimel
ghstack dependencies: #199127, #199128, #199129
cyyever pushed a commit to BakeLab/pytorch that referenced this pull request Oct 11, 2026
…9129)

Fix potential races in green context stream pool slot selection/creation/indexing.

> Authored with an AI assistant.
>
> The lock covers creation through publication; failed creation leaves the index unchanged.

Test Plan

Tested on Rubin with driver R610 + CUDA 13.4 compat.
All 3 focused stream-pool tests passed.

```sh
python test/test_cuda.py TestGreenContextStreamPool -v
```
Pull Request resolved: pytorch#199129
Approved by: https://github.com/ngimel
ghstack dependencies: pytorch#199127, pytorch#199128
cyyever pushed a commit to BakeLab/pytorch that referenced this pull request Oct 11, 2026
….t. MPS (pytorch#199130)

Improve documentation of the NVML based check for locality support: later attachment to MPS isn't supported.

> Authored with an AI assistant.
>
> The limitation concerns the pre-initialization NVML estimate. Already attached clients use the CUDA driver path; query again after attachment rather than reusing an earlier estimate. These regression tests do not test dynamic MPS attachment.

Test Plan

Tested on Rubin with driver R610 + CUDA 13.4 compat.
All 10 existing locality-query regression tests passed.

```sh
python test/test_cuda.py TestCudaGreenContextsCUDA -k locality -v
```
Pull Request resolved: pytorch#199130
Approved by: https://github.com/ngimel
ghstack dependencies: pytorch#199127, pytorch#199128, pytorch#199129
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 open source release notes: cuda release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants