Skip to content

[xegpu][examples] Convert maximum to maxnum for faster reductions. - #306

Merged
tkarna merged 2 commits into
llvm:mainfrom
charithaintc:attention_perf_regression_fix
Oct 19, 2026
Merged

tkarna merged 2 commits into
llvm:mainfrom
charithaintc:attention_perf_regression_fix

Conversation

@charithaintc

@charithaintc charithaintc commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Recent LLVM change causes a significant perf degradation in attention example. This is caused by how SPIRV target lowers vector.reduction ops with maximumf kind. It seems with the recent changes causes maximumf to emit extra checks causing more instructions being executed in the hot fusion loop.

As a temporary solution this PR converts the maximum to maxnumf kind after all fusions are done. This assumes ignore NaN behavior which the caller needs to make sure.

Note: In my view, proper fix for this involve propagating user attached nnan nsz flags via vector.multi_red -> vector.reduciton -> LLVM -> SPIRV. currently there is no support for such propagation.

Assisted by: Codex

@tkarna tkarna left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@charithaintc

Copy link
Copy Markdown
Contributor Author

in sync with main. I installed latest torch-mlir and tested the attention cases.

please merge when you get a chance.

@tkarna
tkarna merged commit 783f1f6 into llvm:main Oct 19, 2026
3 checks passed
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.

2 participants