Harden repeat_arange benchmark with input validation and trace export (#5676)#5676
Closed
q10 wants to merge 1 commit into
Closed
Harden repeat_arange benchmark with input validation and trace export (#5676)#5676q10 wants to merge 1 commit into
q10 wants to merge 1 commit into
Conversation
Contributor
|
@q10 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D102041711. |
q10
added a commit
to q10/FBGEMM
that referenced
this pull request
Apr 23, 2026
…pytorch#5676) Summary: X-link: facebookresearch/FBGEMM#2618 Harden the repeat_arange benchmark with input validation, trace export, and documentation fixes This diff backports hardening improvements from the tritonbench port back into the original FBGEMM GPU `repeat_arange` benchmark. Specifically: 1. **Input validation** (`_validate_inputs`): Checks `batch_size` and `max_length` against int32 limits to prevent silent overflow in the CUDA kernel's `PackedTensorAccessor32` indexing 2. **Kineto trace export** (`_export_kineto_trace` + `--export-trace` CLI flag): Enables profiler trace export for kernel-level performance analysis on all 3 CLI subcommands (`bench-repeat-arange`, `bench-repeat-arange-quick`, `bench-repeat-arange-scaling`) 3. **Documentation fix**: Clarifies that the "reference" PyTorch implementation actually calls `torch.ops.fbgemm.asynchronous_complete_cumsum` (not pure PyTorch) 4. **Docstring changelog**: Records what was changed and the tritonbench port provenance ## Detailed Changes ### repeat_arange_benchmark.py - Added `INT32_MAX` constant and `_validate_inputs()` function that checks `batch_size >= 1`, `max_length >= 1`, `batch_size <= INT32_MAX`, and `batch_size * max_length <= INT32_MAX` - Added `_export_kineto_trace()` helper that runs both implementations under `torch.profiler.profile` and exports Chrome-compatible JSON traces - Added `--export-trace/--no-export-trace` click option to all three CLI subcommands - Added NOTE to `repeat_arange_pytorch` docstring documenting the `fbgemm.asynchronous_complete_cumsum` dependency Reviewed By: henrylhtsang Differential Revision: D102041711
q10
added a commit
to q10/FBGEMM
that referenced
this pull request
Apr 23, 2026
…pytorch#5676) Summary: X-link: facebookresearch/FBGEMM#2618 Harden the repeat_arange benchmark with input validation, trace export, and documentation fixes This diff backports hardening improvements from the tritonbench port back into the original FBGEMM GPU `repeat_arange` benchmark. Specifically: 1. **Input validation** (`_validate_inputs`): Checks `batch_size` and `max_length` against int32 limits to prevent silent overflow in the CUDA kernel's `PackedTensorAccessor32` indexing 2. **Kineto trace export** (`_export_kineto_trace` + `--export-trace` CLI flag): Enables profiler trace export for kernel-level performance analysis on all 3 CLI subcommands (`bench-repeat-arange`, `bench-repeat-arange-quick`, `bench-repeat-arange-scaling`) 3. **Documentation fix**: Clarifies that the "reference" PyTorch implementation actually calls `torch.ops.fbgemm.asynchronous_complete_cumsum` (not pure PyTorch) 4. **Docstring changelog**: Records what was changed and the tritonbench port provenance ## Detailed Changes ### repeat_arange_benchmark.py - Added `INT32_MAX` constant and `_validate_inputs()` function that checks `batch_size >= 1`, `max_length >= 1`, `batch_size <= INT32_MAX`, and `batch_size * max_length <= INT32_MAX` - Added `_export_kineto_trace()` helper that runs both implementations under `torch.profiler.profile` and exports Chrome-compatible JSON traces - Added `--export-trace/--no-export-trace` click option to all three CLI subcommands - Added NOTE to `repeat_arange_pytorch` docstring documenting the `fbgemm.asynchronous_complete_cumsum` dependency Reviewed By: henrylhtsang Differential Revision: D102041711
…pytorch#5676) Summary: X-link: https://github.com/facebookresearch/FBGEMM/pull/2618 Pull Request resolved: pytorch#5676 Harden the repeat_arange benchmark with input validation, trace export, and documentation fixes This diff backports hardening improvements from the tritonbench port back into the original FBGEMM GPU `repeat_arange` benchmark. Specifically: 1. **Input validation** (`_validate_inputs`): Checks `batch_size` and `max_length` against int32 limits to prevent silent overflow in the CUDA kernel's `PackedTensorAccessor32` indexing 2. **Kineto trace export** (`_export_kineto_trace` + `--export-trace` CLI flag): Enables profiler trace export for kernel-level performance analysis on all 3 CLI subcommands (`bench-repeat-arange`, `bench-repeat-arange-quick`, `bench-repeat-arange-scaling`) 3. **Documentation fix**: Clarifies that the "reference" PyTorch implementation actually calls `torch.ops.fbgemm.asynchronous_complete_cumsum` (not pure PyTorch) 4. **Docstring changelog**: Records what was changed and the tritonbench port provenance ## Detailed Changes ### repeat_arange_benchmark.py - Added `INT32_MAX` constant and `_validate_inputs()` function that checks `batch_size >= 1`, `max_length >= 1`, `batch_size <= INT32_MAX`, and `batch_size * max_length <= INT32_MAX` - Added `_export_kineto_trace()` helper that runs both implementations under `torch.profiler.profile` and exports Chrome-compatible JSON traces - Added `--export-trace/--no-export-trace` click option to all three CLI subcommands - Added NOTE to `repeat_arange_pytorch` docstring documenting the `fbgemm.asynchronous_complete_cumsum` dependency Reviewed By: henrylhtsang Differential Revision: D102041711
Contributor
|
This pull request has been merged in 90596c2. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
X-link: https://github.com/facebookresearch/FBGEMM/pull/2618
Harden the repeat_arange benchmark with input validation, trace export, and documentation fixes
This diff backports hardening improvements from the tritonbench port back into the original FBGEMM GPU
repeat_arangebenchmark. Specifically:_validate_inputs): Checksbatch_sizeandmax_lengthagainst int32 limits to prevent silent overflow in the CUDA kernel'sPackedTensorAccessor32indexing_export_kineto_trace+--export-traceCLI flag): Enables profiler trace export for kernel-level performance analysis on all 3 CLI subcommands (bench-repeat-arange,bench-repeat-arange-quick,bench-repeat-arange-scaling)torch.ops.fbgemm.asynchronous_complete_cumsum(not pure PyTorch)Detailed Changes
repeat_arange_benchmark.py
INT32_MAXconstant and_validate_inputs()function that checksbatch_size >= 1,max_length >= 1,batch_size <= INT32_MAX, andbatch_size * max_length <= INT32_MAX_export_kineto_trace()helper that runs both implementations undertorch.profiler.profileand exports Chrome-compatible JSON traces--export-trace/--no-export-traceclick option to all three CLI subcommandsrepeat_arange_pytorchdocstring documenting thefbgemm.asynchronous_complete_cumsumdependencyReviewed By: henrylhtsang
Differential Revision: D102041711