Repository navigation
[pytorch][PR] [Flop Counter] Support Flop counter for a decomposed custom triton kernel in torch op - #169876
[pytorch][PR] [Flop Counter] Support Flop counter for a decomposed custom triton kernel in torch op#169876Lucaskabela wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/169876
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 Failures, 6 Unrelated FailuresAs of commit be47d44 with merge base e33fa0e ( NEW FAILURES - The following jobs have failed:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@Lucaskabela has exported this pull request. If you are a Meta employee, you can view the originating Diff in D81943083. |
|
@pytorchbot label "topic: not user facing" |
12e2802 to
ac91c96
Compare
…ernel in torch op (pytorch#169876) Summary: Modify our flop formula API to registering triton kernels, and provide an example of how to escape hatch triton op to leverage this API Context: For some custom `torch.library.op`, the operator decomposes into one or more custom kernels. To date, there has not been a good system for having these counted by FlopCounterMode, as the function will decompose to the wrapped kernels, and then check the registry. To support this use case, we modify the API, `register_flop_formula` on GPU kernels, and demonstrate how it is used to unwrap kernels in custom ops. ### Unit Test ``` python test/test_flop_counter.py TestFlopCounter.test_flop_counter_custom_triton ``` ``` . ---------------------------------------------------------------------- Ran 1 test in 0.005s ``` Differential Revision: D81943083 Pulled By: Lucaskabela
ac91c96 to
d627521
Compare
…ernel in torch op (pytorch#169876) Summary: Modify our flop formula API to registering triton kernels, and provide an example of how to escape hatch triton op to leverage this API Context: For some custom `torch.library.op`, the operator decomposes into one or more custom kernels. To date, there has not been a good system for having these counted by FlopCounterMode, as the function will decompose to the wrapped kernels, and then check the registry. To support this use case, we modify the API, `register_flop_formula` on GPU kernels, and demonstrate how it is used to unwrap kernels in custom ops. ### Unit Test ``` python test/test_flop_counter.py TestFlopCounter.test_flop_counter_custom_triton ``` ``` . ---------------------------------------------------------------------- Ran 1 test in 0.005s ``` Differential Revision: D81943083 Pulled By: Lucaskabela
…ernel in torch op (pytorch#169876) Summary: Modify our flop formula API to registering triton kernels, and provide an example of how to escape hatch triton op to leverage this API Context: For some custom `torch.library.op`, the operator decomposes into one or more custom kernels. To date, there has not been a good system for having these counted by FlopCounterMode, as the function will decompose to the wrapped kernels, and then check the registry. To support this use case, we modify the API, `register_flop_formula` on GPU kernels, and demonstrate how it is used to unwrap kernels in custom ops. ### Unit Test ``` python test/test_flop_counter.py ``` ``` .. ---------------------------------------------------------------------- Ran 25 tests in 1.021s OK (skipped=3) ``` Differential Revision: D81943083 Pulled By: Lucaskabela
d627521 to
be47d44
Compare
| @torch._functorch.config.patch("activation_memory_budget", 0.1) | ||
| @torch._functorch.config.patch("activation_memory_budget_solver", "dp") | ||
| @torch._functorch.config.patch("is_non_builtin_to_include", True) | ||
| def test_flop_counter_custom_triton_op_two_kernels_auto_ac(self): |
There was a problem hiding this comment.
New test covering op with multiple kernels @bdhirsh
|
@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 |
Merge failedReason: 3 jobs have failed, first few of them are: trunk / linux-jammy-rocm-py3.10 / test (default, 6, 6, linux.rocm.gpu.gfx942.1), trunk / linux-jammy-rocm-py3.10 / test (distributed, 1, 3, linux.rocm.gpu.gfx942.4), trunk / linux-jammy-rocm-py3.10 / test (default, 4, 6, linux.rocm.gpu.gfx942.1) Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge -i |
…stom triton kernel in torch op (pytorch#169876) Summary: Modify our flop formula API to registering triton kernels, and provide an example of how to escape hatch triton op to leverage this API Context: For some custom `torch.library.op`, the operator decomposes into one or more custom kernels. To date, there has not been a good system for having these counted by FlopCounterMode, as the function will decompose to the wrapped kernels, and then check the registry. To support this use case, we modify the API, `register_flop_formula` on GPU kernels, and demonstrate how it is used to unwrap kernels in custom ops. ### Unit Test ``` python test/test_flop_counter.py TestFlopCounter.test_flop_counter_custom_triton ``` ``` . ---------------------------------------------------------------------- Ran 1 test in 0.005s ``` Differential Revision: D81943083 Pulled By: Lucaskabela Pull Request resolved: pytorch#169876 Approved by: https://github.com/bdhirsh
…stom triton kernel in torch op (pytorch#169876) Summary: Modify our flop formula API to registering triton kernels, and provide an example of how to escape hatch triton op to leverage this API Context: For some custom `torch.library.op`, the operator decomposes into one or more custom kernels. To date, there has not been a good system for having these counted by FlopCounterMode, as the function will decompose to the wrapped kernels, and then check the registry. To support this use case, we modify the API, `register_flop_formula` on GPU kernels, and demonstrate how it is used to unwrap kernels in custom ops. ### Unit Test ``` python test/test_flop_counter.py TestFlopCounter.test_flop_counter_custom_triton ``` ``` . ---------------------------------------------------------------------- Ran 1 test in 0.005s ``` Differential Revision: D81943083 Pulled By: Lucaskabela Pull Request resolved: pytorch#169876 Approved by: https://github.com/bdhirsh
If one attempts to import `torch.utils.flop_count` on MacOS (or any other CPU system), they'll be greated with the following repeated warning ``` % python -c "import torch.utils.flop_counter" W0115 18:52:55.246000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.246000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.246000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels ``` which was introduced by #169876 Move import to top of flop_counter utils and only warn if system is compiled with GPU support that requires triton (i.e. CUDA/ROCM or XPU) ghstack-source-id: d2f3c83 Pull-Request: #172614
If one attempts to import `torch.utils.flop_count` on MacOS (or any other CPU system), they'll be greeted with the following repeated warning ``` % python -c "import torch.utils.flop_counter" W0115 18:52:55.246000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.246000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.246000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels W0115 18:52:55.247000 34027 torch/utils/flop_counter.py:45] triton not found; flop counting will not work for triton kernels ``` which was introduced by #169876 Move import to top of flop_counter utils and only warn if system is compiled with GPU support that requires triton (i.e. CUDA/ROCM or XPU) Pull Request resolved: #172614 Approved by: https://github.com/Lucaskabela
Summary:
Modify our flop formula API to registering triton kernels, and provide an example of how to escape hatch triton op to leverage this API
Context: For some custom
torch.library.op, the operator decomposes into one or more custom kernels. To date, there has not been a good system for having these counted by FlopCounterMode, as the function will decompose to the wrapped kernels, and then check the registry.To support this use case, we modify the API,
register_flop_formulaon GPU kernels, and demonstrate how it is used to unwrap kernels in custom ops.Unit Test
Differential Revision: D81943083
Pulled By: Lucaskabela