Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/182971
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit dccf8bb with merge base c0b0064 ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@bbus has exported this pull request. If you are a Meta employee, you can view the originating Diff in D104403189. |
| # Dynamo's stream-tracing module. | ||
| from torch.fx.node import has_side_effect as _has_side_effect | ||
|
|
||
| _has_side_effect(torch.ops.streams.record_event.default) |
There was a problem hiding this comment.
I think we marked these already in torch/_dynamo/variables/streams.py
| # Don't generate ctx switching. Memory planning code (e.g., delete buffers) on current | ||
| # node goes to previous stream ctx. | ||
| return | ||
| elif self.current_stream_idx is None and stream is not None: |
There was a problem hiding this comment.
hmm not sure if this is needed? elif has the same effect here?
| the previous node's stream. NopKernelSchedulerNodes have stream=None and inherit the | ||
| enclosing stream context (or do nothing if no context is active yet). | ||
|
|
||
| Defaults missing nodes to the default stream: post-fusion reorder |
There was a problem hiding this comment.
We should probably fix this, I'm worried other data might be getting lost, we want to preserve metadata
| result = loaded(*inputs) | ||
| return result, code | ||
|
|
||
| def test_multistream_with_cudagraphs_raises_at_compile_time(self): |
There was a problem hiding this comment.
There isn't a fundamental blocker to this right? just not supported right now. Streams should be able to work with cudagraphs
There was a problem hiding this comment.
Yes, there is no fundamental limitation. Changed the error to not implemented.
|
|
||
|
|
||
| @unittest.skipIf(not TEST_CUDA, "requires CUDA") | ||
| class TestAOTIUserStreams(InductorTestCase): |
There was a problem hiding this comment.
Higher level note, could we just run all of the stream tests that exist in AOTI and parametrize it so we can run with both AOTI or normal Inductor?
There was a problem hiding this comment.
Updated the user_stream tests to be parametrized
…torch#182971) Summary: Pull Request resolved: pytorch#182971 Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism). Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation. **NOTE**: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism. Authored with Claude. Test Plan: buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=h100a -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:user_streams Differential Revision: D104403189
…torch#182971) Summary: Pull Request resolved: pytorch#182971 Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism). Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation. **NOTE**: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism. Authored with Claude. Test Plan: buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=h100a -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:user_streams Differential Revision: D104403189
…torch#182971) Summary: Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism). Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation. **NOTE**: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism. Authored with Claude. Test Plan: buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=h100a -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:user_streams Differential Revision: D104403189
…torch#182971) Summary: Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism). Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation. **NOTE**: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism. Authored with Claude. Test Plan: buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=h100a -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:user_streams Differential Revision: D104403189
…torch#182971) Summary: Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism). Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation. **NOTE**: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism. Authored with Claude. Test Plan: buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=h100a -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:user_streams Differential Revision: D104403189
| """ | ||
| if num_streams <= 1 or not V.graph.aot_mode: | ||
| # JIT cpp_wrapper + multi-stream is a separate, currently | ||
| # unsupported path. Skipping preserves the pre-existing behavior |
There was a problem hiding this comment.
It's better to error out loud if this path is not supported yet.
| self._multi_stream_helpers_emitted = True | ||
| self.header.splice( | ||
| maybe_hipify_code_wrapper( | ||
| """ |
There was a problem hiding this comment.
Let's make this as a header file under the aoti_runtime directory. Easier for other people to follow.
| // since destructors must not throw and CUDA may already | ||
| // be tearing down. | ||
| for (auto event : events) { | ||
| if (event != nullptr) (void)cudaEventDestroy(event); |
There was a problem hiding this comment.
Maybe write to std::cerr? similar to
|
|
||
| ~AOTIPerThreadStreamCache() { | ||
| for (auto stream : streams) { | ||
| if (stream != nullptr) (void)cudaStreamDestroy(stream); |
| }; | ||
|
|
||
| static thread_local AOTIPerThreadEventCache _aoti_event_cache; | ||
| static thread_local AOTIPerThreadStreamCache _aoti_aux_stream_cache; |
There was a problem hiding this comment.
These two can be left here instead of going to the new .h file.
…torch#182971) Summary: Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism). Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation. **NOTE**: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism. Authored with Claude. Test Plan: buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=h100a -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:user_streams Reviewed By: desertfire Differential Revision: D104403189
…torch#182971) Summary: Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism). Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation. **NOTE**: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism. Authored with Claude. Test Plan: buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=h100a -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:user_streams Reviewed By: desertfire Differential Revision: D104403189
…torch#182971) Summary: Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism). Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation. **NOTE**: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism. Authored with Claude. Test Plan: buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=h100a -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:user_streams Reviewed By: desertfire Differential Revision: D104403189
…torch#182971) Summary: Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism). Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation. **NOTE**: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism. Authored with Claude. Test Plan: buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=h100a -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:user_streams Reviewed By: desertfire Differential Revision: D104403189
…torch#182971) Summary: Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism). Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation. **NOTE**: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism. Authored with Claude. Test Plan: buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=h100a -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:user_streams Reviewed By: desertfire Differential Revision: D104403189
…torch#182971) Summary: Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism). Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation. **NOTE**: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism. Authored with Claude. Test Plan: buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=h100a -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:user_streams Reviewed By: desertfire Differential Revision: D104403189
…torch#182971) Summary: Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism). Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation. **NOTE**: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism. Authored with Claude. Test Plan: Lint/format: `arc lint -a` on all touched `caffe2` files -> No lint issues. Exercised end-to-end on an A100, rebased on `master`. Ran the full user-streams suite (both the JIT `torch.compile` path and the new AOTI path). The new `TestAOTIUserStreams` cases compile via `aoti_compile_and_package`, load, run, and compare to eager -- covering inline `cudaEventRecord` / `cudaStreamWaitEvent`, the per-thread `AOTIPerThreadStreamCache` / `AOTIPerThreadEventCache`, and loud compile-time rejection of `synchronize_stream`. The suite also covers the JIT cross-stream strided-copy regression. ``` buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=a100 -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:user_streams ``` Result: `Tests finished: Pass 71. Fail 0. Skip 7.` Reviewed By: desertfire Differential Revision: D104403189
…torch#182971) Summary: Pull Request resolved: pytorch#182971 Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism). Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation. **NOTE**: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism. Authored with Claude. Test Plan: Lint/format: `arc lint -a` on all touched `caffe2` files -> No lint issues. Exercised end-to-end on an A100, rebased on `master`. Ran the full user-streams suite (both the JIT `torch.compile` path and the new AOTI path). The new `TestAOTIUserStreams` cases compile via `aoti_compile_and_package`, load, run, and compare to eager -- covering inline `cudaEventRecord` / `cudaStreamWaitEvent`, the per-thread `AOTIPerThreadStreamCache` / `AOTIPerThreadEventCache`, and loud compile-time rejection of `synchronize_stream`. The suite also covers the JIT cross-stream strided-copy regression. ``` buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=a100 -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:user_streams ``` Result: `Tests finished: Pass 71. Fail 0. Skip 7.` Reviewed By: desertfire Differential Revision: D104403189
…torch#182971) Summary: Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism). Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation. **NOTE**: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism. Authored with Claude. Test Plan: Lint/format: `arc lint -a` on all touched `caffe2` files -> No lint issues. Exercised end-to-end on an A100, rebased on `master`. Ran the full user-streams suite (both the JIT `torch.compile` path and the new AOTI path). The new `TestAOTIUserStreams` cases compile via `aoti_compile_and_package`, load, run, and compare to eager -- covering inline `cudaEventRecord` / `cudaStreamWaitEvent`, the per-thread `AOTIPerThreadStreamCache` / `AOTIPerThreadEventCache`, and loud compile-time rejection of `synchronize_stream`. The suite also covers the JIT cross-stream strided-copy regression. ``` buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=a100 -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:user_streams ``` Result: `Tests finished: Pass 71. Fail 0. Skip 7.` Reviewed By: desertfire Differential Revision: D104403189
…torch#182971) Summary: Pull Request resolved: pytorch#182971 Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism). Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation. **NOTE**: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism. Authored with Claude. Test Plan: Lint/format: `arc lint -a` on all touched `caffe2` files -> No lint issues. Exercised end-to-end on an A100, rebased on `master`. Ran the full user-streams suite (both the JIT `torch.compile` path and the new AOTI path). The new `TestAOTIUserStreams` cases compile via `aoti_compile_and_package`, load, run, and compare to eager -- covering inline `cudaEventRecord` / `cudaStreamWaitEvent`, the per-thread `AOTIPerThreadStreamCache` / `AOTIPerThreadEventCache`, and loud compile-time rejection of `synchronize_stream`. The suite also covers the JIT cross-stream strided-copy regression. ``` buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=a100 -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:user_streams ``` Result: `Tests finished: Pass 71. Fail 0. Skip 7.` Reviewed By: desertfire Differential Revision: D104403189
…torch#182971) Summary: Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism). Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation. **NOTE**: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism. Authored with Claude. Test Plan: Lint/format: `arc lint -a` on all touched `caffe2` files -> No lint issues. Exercised end-to-end on an A100, rebased on `master`. Ran the full user-streams suite (both the JIT `torch.compile` path and the new AOTI path). The new `TestAOTIUserStreams` cases compile via `aoti_compile_and_package`, load, run, and compare to eager -- covering inline `cudaEventRecord` / `cudaStreamWaitEvent`, the per-thread `AOTIPerThreadStreamCache` / `AOTIPerThreadEventCache`, and loud compile-time rejection of `synchronize_stream`. The suite also covers the JIT cross-stream strided-copy regression. ``` buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=a100 -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:user_streams ``` Result: `Tests finished: Pass 71. Fail 0. Skip 7.` Reviewed By: desertfire Differential Revision: D104403189
f7416d9 to
c0a5f8d
Compare
…torch#182971) Summary: Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism). Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation. **NOTE**: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism. Authored with Claude. Test Plan: Lint/format: `arc lint -a` on all touched `caffe2` files -> No lint issues. OSS `lintrunner` (noclang linter set) run locally -> clean. Exercised end-to-end on an A100, rebased on `master`. Full user-streams suite (JIT `torch.compile` + AOTI paths), including the new `TestAOTIUserStreams` (inline `cudaEventRecord` / `cudaStreamWaitEvent`, per-thread `AOTIPerThreadStreamCache` / `AOTIPerThreadEventCache`, loud rejection of `synchronize_stream`) and the JIT cross-stream strided-copy regression: ``` buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=a100 -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:user_streams ``` Result: `Tests finished: Pass 71. Fail 0. Skip 7.` AOTI pinned non-blocking copy, which lowers to `torch.ops.streams.synchronize_event` (this diff emits it inline as `cudaEventSynchronize`): ``` buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=a100 -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:test_aot_inductor -- test_copy_non_blocking_is_pinned_cuda ``` Result: `Tests finished: Pass 3. Fail 0.` Reviewed By: desertfire Differential Revision: D104403189
…torch#182971) Summary: Pull Request resolved: pytorch#182971 Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism). Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation. **NOTE**: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism. Authored with Claude. Test Plan: Lint/format: `arc lint -a` on all touched `caffe2` files -> No lint issues. OSS `lintrunner` (noclang linter set) run locally -> clean. Exercised end-to-end on an A100, rebased on `master`. Full user-streams suite (JIT `torch.compile` + AOTI paths), including the new `TestAOTIUserStreams` (inline `cudaEventRecord` / `cudaStreamWaitEvent`, per-thread `AOTIPerThreadStreamCache` / `AOTIPerThreadEventCache`, loud rejection of `synchronize_stream`) and the JIT cross-stream strided-copy regression: ``` buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=a100 -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:user_streams ``` Result: `Tests finished: Pass 71. Fail 0. Skip 7.` AOTI pinned non-blocking copy, which lowers to `torch.ops.streams.synchronize_event` (this diff emits it inline as `cudaEventSynchronize`): ``` buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=a100 -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:test_aot_inductor -- test_copy_non_blocking_is_pinned_cuda ``` Result: `Tests finished: Pass 3. Fail 0.` Reviewed By: desertfire Differential Revision: D104403189
…torch#182971) Summary: Pull Request resolved: pytorch#182971 Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism). Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation. **NOTE**: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism. Authored with Claude. Test Plan: Lint/format: `arc lint -a` on all touched `caffe2` files -> No lint issues. OSS `lintrunner` (noclang linter set) run locally -> clean. Exercised end-to-end on an A100, rebased on `master`. Full user-streams suite (JIT `torch.compile` + AOTI paths), including the new `TestAOTIUserStreams` (inline `cudaEventRecord` / `cudaStreamWaitEvent`, per-thread `AOTIPerThreadStreamCache` / `AOTIPerThreadEventCache`, loud rejection of `synchronize_stream`) and the JIT cross-stream strided-copy regression: ``` buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=a100 -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:user_streams ``` Result: `Tests finished: Pass 71. Fail 0. Skip 7.` AOTI pinned non-blocking copy, which lowers to `torch.ops.streams.synchronize_event` (this diff emits it inline as `cudaEventSynchronize`): ``` buck2 test mode/opt-split-dwarf -c fbcode.use_link_groups=True -c fbcode.fbgemm_codegen_inference_mode=true -c fbcode.dwp=true -c fbcode.enable_gpu_sections=true -c fbcode.nvcc_arch=a100 -c fbcode.platform=platform010 -c fbcode.split-dwarf=true fbcode//caffe2/test/inductor:test_aot_inductor -- test_copy_non_blocking_is_pinned_cuda ``` Result: `Tests finished: Pass 3. Fail 0.` Reviewed By: mlazos, desertfire Differential Revision: D104403189
|
@pytorchbot merge (Initiating merge automatically since Phabricator Diff has merged) |
Merge startedYour 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 |
Summary:
Extending user-streams to AOT inductor. This mechanism will also be later leveraged for compiler created multi-streams (profile guided parallelism).
Leverages thread local storage without freeing for stream and event creation. Later PRs will include mechanisms to change the stream priority at creation.
NOTE: Internally at Meta we tightly control the host threads that run AOTI models making it favorable to have a TLS mechanism.
Authored with Claude.
Test Plan:
Lint/format:
arc lint -aon all touchedcaffe2files -> No lint issues. OSSlintrunner(noclang linter set) run locally -> clean.Exercised end-to-end on an A100, rebased on
master.Full user-streams suite (JIT
torch.compile+ AOTI paths), including the newTestAOTIUserStreams(inlinecudaEventRecord/cudaStreamWaitEvent, per-threadAOTIPerThreadStreamCache/AOTIPerThreadEventCache, loud rejection ofsynchronize_stream) and the JIT cross-stream strided-copy regression:Result:
Tests finished: Pass 71. Fail 0. Skip 7.AOTI pinned non-blocking copy, which lowers to
torch.ops.streams.synchronize_event(this diff emits it inline ascudaEventSynchronize):Result:
Tests finished: Pass 3. Fail 0.Reviewed By: mlazos, desertfire
Differential Revision: D104403189
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo