Skip to content

[Codegen][GPU] Emit gpu.subgroup_reduce for group reductions - #25021

Closed
adliek wants to merge 2 commits into
iree-org:mainfrom
adliek:subgroup-reduce
Closed

adliek wants to merge 2 commits into
iree-org:mainfrom
adliek:subgroup-reduce

Conversation

@adliek

@adliek adliek commented Oct 11, 2026

Copy link
Copy Markdown

Replace the shuffle butterfly in emitGPUGroupReduction with gpu.subgroup_reduce. SPIR-V lowers that to one GroupNonUniform reduction, and ExpandGPUOps still chooses DPP or shuffles for LLVMGPU. Drop expandSubgroupReduce: it only selected the old shuffle expansion.

Build integer identities at the element width so i32 maxsi, minsi, and "and" are not truncated.

setReductionConfig numbers lanes using the preferred subgroup size. On a target that can run more than one size, such as RDNA, the driver may pick the other size and a subgroup reduction then counts lanes twice. Record the chosen size so Vulkan can require it. Leave the size unset when the target has only one valid size. A recorded size is a required size, and pipeline creation fails when subgroupSizeControl is unavailable.
Fixes #18516
Fixes #20318
Assisted-by: Cursor Grok 4.7
Signed-off-by: Alexander Dick [email protected]

adliek and others added 2 commits October 11, 2026 10:50
Replace the shuffle butterfly in emitGPUGroupReduction with
gpu.subgroup_reduce. SPIR-V lowers that to one GroupNonUniform
reduction, and ExpandGPUOps still chooses DPP or shuffles for LLVMGPU.
Drop expandSubgroupReduce: it only selected the old shuffle expansion,
which every caller had opted out of.

Build integer identities at the element width so i32 maxsi, minsi, and
and are not truncated.

Fixes iree-org#18516
Fixes iree-org#20318

Assisted-by: Cursor Grok 4.7
Signed-off-by: Alexander Dick <[email protected]>
Co-authored-by: Cursor <[email protected]>
setReductionConfig numbers lanes using the preferred subgroup size. On a
target that can run more than one size, such as RDNA, the driver may
pick the other size and a subgroup reduction then counts lanes twice.
Record the chosen size so Vulkan can require it.

Leave the size unset when the target has only one legal size. A recorded
size is a required size, and pipeline creation fails when
subgroupSizeControl is unavailable.

Assisted-by: Cursor Grok 4.7
Signed-off-by: Alexander Dick <[email protected]>
Co-authored-by: Cursor <[email protected]>
@github-actions

Copy link
Copy Markdown

Hello @adliek 👋

Thank you for submitting a Pull Request to IREE! It looks like this is your first one. We have one ask, and you can also find some general tips below.


Action required: acknowledge IREE project policies

IREE is a Linux Foundation project. All participants are expected to follow the LF Projects Code of Conduct.

All contributions to IREE must follow our IREE AI Tool Use Policy. In particular:

  • Contributors must fully understand, and vouch for, all submitted changes and the intent behind them.
  • Substantial use of LLM/generative AI tools must be noted in the PR description, e.g. via Assisted-by: tool-name or Co-authored-by: tool-name tool@email trailers.
  • Contributors must write PR descriptions themselves. There must always be a human in the loop: contributors must respond to reviews and questions by themselves.
    If a response includes LLM-assisted segments (e.g. reproducers, LLM agent analysis excerpts), the segment should be clearly marked as "assisted", same as for PR contents.
  • GitHub issues labeled as "Good first issue" are explicitly designated as learning opportunities for newcomers to the project. With exceptions for boilerplate edits, AI tool usage for resolutions to such issues is forbidden.

We kindly ask you to reply to this message and confirm that you understand and accept the cited policies, particularly the AI Tool Use Policy.


General guidance

Our general Contributing guide contains information and links to detailed guides on code quality, testing, commit summaries and our CI system.

A common point for new PRs: if a DCO signing check fails for you, check out the section on Developer Certificate of Origin.
In these cases, it should suffice to amend your commit signature(s) per the guide and force-push the PR branch.

If you have any questions, feel free to leave a comment here, or ask away on IREE Discord.

Thank you,
The IREE Community

@adliek

adliek commented Oct 11, 2026

Copy link
Copy Markdown
Author

Hello @adliek 👋

Thank you for submitting a Pull Request to IREE! It looks like this is your first one. We have one ask, and you can also find some general tips below.

Action required: acknowledge IREE project policies

IREE is a Linux Foundation project. All participants are expected to follow the LF Projects Code of Conduct.

All contributions to IREE must follow our IREE AI Tool Use Policy. In particular:

* Contributors must fully understand, and vouch for, **all** submitted changes and the intent behind them.

* Substantial use of LLM/generative AI tools must be noted in the PR description, e.g. via `Assisted-by: tool-name` or `Co-authored-by: tool-name tool@email` trailers.

* Contributors must write PR descriptions themselves. There must always be a human in the loop: contributors must respond to reviews and questions by themselves.
  If a response includes LLM-assisted segments (e.g. reproducers, LLM agent analysis excerpts), the segment should be clearly marked as "assisted", same as for PR contents.

* GitHub issues labeled as "Good first issue" are explicitly designated as learning opportunities for newcomers to the project. With exceptions for boilerplate edits, AI tool usage for resolutions to such issues is **forbidden**.

We kindly ask you to reply to this message and confirm that you understand and accept the cited policies, particularly the AI Tool Use Policy.

General guidance

Our general Contributing guide contains information and links to detailed guides on code quality, testing, commit summaries and our CI system.

A common point for new PRs: if a DCO signing check fails for you, check out the section on Developer Certificate of Origin. In these cases, it should suffice to amend your commit signature(s) per the guide and force-push the PR branch.

If you have any questions, feel free to leave a comment here, or ask away on IREE Discord.

Thank you, The IREE Community

I understand this policy. I have use AI assistance and was not aware of the "Good first issue" policy. Therefore, I will close this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Codegen] Don't do our own subgroup reduce expansion [gpu] Cleanup: Use gpu.subgroup_reduce rather than building shuffles manually

1 participant