Add block batch reduce algorithm - #5177
Open
pfultz2 wants to merge 8 commits into
Open
Conversation
Regressions detected 🔴 * No develop baseline was found for this PR's branch point; compared against the latest available develop run instead. |
|
… block-batch-reduce
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a batched GPU block-reduction algorithm for tiled fused reductions.
Changes:
- Adds batched accumulation, slicing, and result assignment.
- Adds JIT eligibility and tuning logic.
- Adds a cppcheck-safe math wrapper definition.
Review used a single pass without subagent fan-out. GPU verification on wave32 and wave64 remains necessary.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
reduce.hpp |
Implements the batched kernel algorithm. |
math.hpp |
Adds cppcheck macro handling. |
reduce.cpp |
Selects and tunes batched reductions. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+323
to
+327
| if(any_of(ins->inputs(), [&](instruction_ref input) { | ||
| if(input->name() != "@param") | ||
| return false; | ||
| return input->get_shape().lens() == rlens or input->get_shape().broadcasted(); | ||
| })) |
Comment on lines
+593
to
+597
| static std::size_t | ||
| batch_iterations(std::size_t n_per_block, std::size_t relements, std::size_t block_size) | ||
| { | ||
| return (n_per_block * relements) / block_size; | ||
| } |
Comment on lines
+275
to
+279
| /// Like block_reduce but computes N independent reductions in one pass. The | ||
| /// iteration space covers N consecutive segments of relements elements and | ||
| /// each lane accumulates into the vector slot of the segment it is reading. | ||
| template <index_int N, class Op, class T, class Size, class F> | ||
| __device__ auto block_batch_reduce(index idx, Op op, T init, Size n, F f) |
pfultz2
marked this pull request as ready for review
August 31, 2026 18:20
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.
Motivation
Technical Details
Changelog Category
Add a
CHANGELOG.mdentry for any option other thanNot ApplicableFollow the LLVM AI Tool Use Policy for contributions using AI.