Repository navigation
[CUDA] Add SM partitioning with cuDevSmResourceSplit - #198178
MatthiasKohl wants to merge 1 commit into
Conversation
Add reusable SMPartition resources and disjoint green-context SM allocation through cuDevSmResourceSplit. Start review with SMPartition.split and its broadcasting, discovery, co-scheduling, and backfill options, then follow GreenContext construction and recursive subdivision through sm_partition. Retain the shared stream execution and lookup helpers, non-owning context wrappers, cached SM counts, and CUDA bindings version checks. Include their documentation and test coverage; locality-domain functionality and its NVML helpers are added separately on top of this commit. Test Plan Ran lint with autofixes through spin using the base_env environment: ```bash PATH=/home/mjoux/base_env/bin:$PATH spin lint -a docs/source/cuda.md test/test_cuda.py torch/cuda/__init__.py torch/cuda/_utils.py torch/cuda/green_contexts.py torch/testing/_internal/common_utils.py git diff --check ``` Tests were not run, as requested; live-system testing is left to the author. Authored with an AI assistant.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/198178
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ❌ 3 New FailuresAs of commit f2cc896 with merge base 9b6e452 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
| workqueue_concurrency_limit: int | None = None, | ||
| sm_partition: SMPartition | None = None, | ||
| device_id: int | None = None, | ||
| green_context_obj: Any | None = None, |
There was a problem hiding this comment.
remove this arg and related functionality, along with get_green_context_from_stream - the original PR didn't actually show that it's needed for fork-join functionality, when it's needed you'll add it in a separate PR. Also, remove _is_owning, we won't need it in this case
| """ | ||
| self._ensure_alive() | ||
| curr_idx = self._curr_stream_idx + 1 | ||
| self._curr_stream_idx += 1 |
There was a problem hiding this comment.
remove changes related to stream handling from this PR, put them in a separate PR. This is still not fixing the race correctly, an index can be reserved before its slot contains a stream. If A stalls creating slot 0 while B makes
another 32 requests, B wraps around and reads None from slot 0. A failed creation similarly leaves a hole. So, move the change to a separate PR (also remove tests related to this change)
| """ | ||
| if not green_ctx_streams: | ||
| raise ValueError("Need at least one green context to execute in!") | ||
| if len(green_ctx_streams) == 1: |
There was a problem hiding this comment.
this gives a materially different semantics to single stream vs multi-stream execution - multi-stream skips sync
| ): | ||
| torch.cuda.set_stream(green_ctx_stream) | ||
| green_ctx_stream.wait_event(main_event) | ||
| fn(i) |
There was a problem hiding this comment.
if fn raises, event won't be recorded and synchronization will be bypassed
Add reusable SMPartition resources and disjoint green-context SM allocation through cuDevSmResourceSplit.
This fixes issue #195378.
Additionally adds shared stream execution and lookup helpers, non-owning context wrappers, cached SM counts, and CUDA bindings version checks, and improve green context docs accordingly.
Locality-domain functionality and its NVML helpers are added separately on top of this PR.
Authored (partially) with an AI assistant.