Skip to content

Added CPU runtime benchmarking and expanded BenchmarkResult to store CPU runtimes #3206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

SSYernar
Copy link
Contributor

Summary:

  • Added feature to becnhmark CPU runtimes alongside with GPU measurements.
  • Expanded BenchmarkResult class to store both device measurements
  • Adapted files that are importing BenchmarkResult to ensure compatibility

Now we can compare CPU and GPU runtimes without running and analyzing PyTorch Profiler. BenchmarkResults can help users to detect if the module/function/operator is CPU-bounded or GPU-bounded.

Example metrics of FBGEMM operators:

Operator CPU Runtime GPU Runtime GPU Memory
[fallback] pytorch generic 5.41 ms 2.66 ms 1.01 GB
[Prod] KeyedTensor.regroup_dup 2.13 ms 2.48 ms 1.01 GB
[Module] KTRegroupAsDict_dup 0.14 ms 0.75 ms 1.01 GB
[2 Ops] permute_multi_embs_dup 0.88 ms 1.44 ms 1.01 GB
[1 Op] KT_regroup_dup 0.99 ms 1.54 ms 1.01 GB

We can see that [fallback] pytorch generic is CPU-bounded

Differential Revision: D78503319

SSYernar added 2 commits July 17, 2025 11:46
…ark_core` (pytorch#3191)

Summary:

Removed redundant logic in `benchmark` and `benchmark_func` by moving shared timing, memory, and profiling code into a new `_run_benchmark_core` function. Ensured the backward-compatibility.

Differential Revision: D78290979
…CPU runtimes

Summary:
* Added feature to becnhmark CPU runtimes alongside with GPU measurements.
* Expanded `BenchmarkResult` class to store both device measurements
* Adapted files that are importing `BenchmarkResult` to ensure compatibility

Now we can compare CPU and GPU runtimes without running and analyzing PyTorch Profiler. BenchmarkResults can help users to detect if the module/function/operator is CPU-bounded or GPU-bounded. 

Example metrics of FBGEMM operators:
| Operator                                    | CPU Runtime | GPU Runtime | GPU Memory |
|---------------------------------------------|-------------|-------------|------------|
| **[fallback] pytorch generic**              | 5.41 ms     | 2.66 ms     | 1.01 GB    |
| **[Prod] KeyedTensor.regroup_dup**          | 2.13 ms     | 2.48 ms     | 1.01 GB    |
| **[Module] KTRegroupAsDict_dup**            | 0.14 ms     | 0.75 ms     | 1.01 GB    |
| **[2 Ops] permute_multi_embs_dup**          | 0.88 ms     | 1.44 ms     | 1.01 GB    |
| **[1 Op] KT_regroup_dup**                   | 0.99 ms     | 1.54 ms     | 1.01 GB    |

We can see that `[fallback] pytorch generic`  is CPU-bounded

Differential Revision: D78503319
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 17, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78503319

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants