Skip to content

fix(hlo): GroupNorm emits real stablehlo.reduce (IREE-compilable) - #754

Merged
michalharakal merged 1 commit into
developfrom
fix/groupnorm-real-reduce
Jun 23, 2026
Merged

michalharakal merged 1 commit into
developfrom
fix/groupnorm-real-reduce

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

Bug

The GroupNorm converter shipped in 0.32.0 (#752) lowered mean/variance with stablehlo.custom_call @reduce_mean / @reduce_variance (copied from the LayerNorm style). Those custom_calls are opaque to stock iree-compile — so a groupNorm module exports cleanly but fails to compile on IREE.

This was caught by the downstream skainet-iree-conformance harness, which wired a groupnorm op into its IREE pipeline and got GATE FAIL: groupnorm:compile.

Fix

Emit real stablehlo.reduce (add region) + divide, computing variance as E[x²] − E[x]² (population, ddof=0) — exactly as the standalone sum / mean / variance converters already do. No custom_call in the output.

Verified end-to-end

Against this source build, through the conformance harness (iree-compile + iree-run-module + numpy allclose):

PASS max_abs_err=1.192e-07 (rtol=1e-3 atol=1e-4)

GroupNormConverterTest updated to assert real stablehlo.reduce( and the absence of any custom_call; full skainet-compile-hlo jvmTest suite passes.

Follow-up

LayerNorm/RMSNorm still emit the @reduce_* custom_calls (they're not exercised on IREE in-tree, hence their ⚠️ status downstream). Giving them the same real-reduce treatment would make them IREE-compilable too — left as a separate change.

Targets a 0.32.1 patch release.

🤖 Generated with Claude Code

The 0.32.0 GroupNorm converter lowered mean/variance with
`stablehlo.custom_call @reduce_mean` / `@reduce_variance` (mirroring the
LayerNorm style). Those custom_calls are opaque to stock `iree-compile`, so a
groupNorm module exported fine but failed to compile on IREE — caught by the
downstream skainet-iree-conformance harness (groupnorm:compile).

Emit real `stablehlo.reduce` (add region) + divide instead, computing variance
as E[x^2] - E[x]^2 (population, ddof=0) — exactly as the standalone
`sum`/`mean`/`variance` converters already do. The module now compiles on
llvm-cpu and runs.

Verified end-to-end via the conformance harness against this source build:
iree-compile + iree-run-module + numpy validate -> PASS, max_abs_err=1.2e-7.

GroupNormConverterTest updated to assert real `stablehlo.reduce` and the absence
of any `custom_call`. (LayerNorm/RMSNorm still use the @reduce_* custom_calls;
making them IREE-compilable the same way is a follow-up.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@michalharakal
michalharakal merged commit a720ec5 into develop Jun 23, 2026
4 checks passed
@michalharakal
michalharakal deleted the fix/groupnorm-real-reduce branch June 23, 2026 08:34
MacOS pushed a commit to MacOS/SKaiNET that referenced this pull request Jul 10, 2026
Patch release. Bumps VERSION_NAME 0.31.2 -> 0.32.1 and brings the release
metadata current: develop never received the 0.32.0 release back-merge (PR SKaiNET-developers#753
was tagged + published but blocked from merging), so this consolidates the 0.32.0
AND 0.32.1 CHANGELOG / README "What's New" entries (supersedes SKaiNET-developers#753).

0.32.1 fix: GroupNorm now emits real stablehlo.reduce instead of
@reduce_mean/@reduce_variance custom_calls, so a groupNorm module compiles on
stock iree-compile. Verified end-to-end via skainet-iree-conformance:
PASS max_abs_err=1.2e-7. (PR SKaiNET-developers#754)

0.32.0 (folded in): GroupNorm StableHLO converter (SKaiNET-developers#752), SKEEP proposals docs
(SKaiNET-developers#750), quantization-process doc (SKaiNET-developers#747), dependency bumps.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant