Skip to content

[Frontend] Drop stale single-reduction-axis guard breaking test_diffusion#250

Merged
YWHyuk merged 1 commit into
developfrom
bugfix/diffusion-stale-multi-reduction-guard
May 27, 2026
Merged

[Frontend] Drop stale single-reduction-axis guard breaking test_diffusion#250
YWHyuk merged 1 commit into
developfrom
bugfix/diffusion-stale-multi-reduction-guard

Conversation

@YWHyuk
Copy link
Copy Markdown
Collaborator

@YWHyuk YWHyuk commented May 27, 2026

Summary

Removes the dead guard at `mlir_codegen_backend.py:909-910`. The guard claimed multi-axis reduction was unsupported, but the codegen below it actually iterates all reduction loops and produces correct output — `test_diffusion`, added specifically to validate multi-axis support, passed for ~9 months while this guard had no `raise` and was effectively a no-op.

PR #237 (5045837) added a `raise` to the guard as part of a four-item correctness fix. The intent ("missing raise") was correct in form but wrong in substance: the guard itself was stale. With the raise added, every diffusion CI run now fails at this guard.

Timeline

  1. `8eacf27` (early 2025): reduce/elementwise refactor restricted codegen to `reductions.loops[0]` and added the guard (no raise — silently dead).
  2. `c61f67d` "Support multi reduction dim + Add Diffusion model test" (2025-08-14): restored `for reduction_loop in reductions.loops:` iteration to support multi-axis. test_diffusion added in the same commit, passed. Guard left behind.
  3. `5045837` ([Bug][Frontend] Multiple codegen correctness issues (missing raise, None ordering, dup check_bounds, validation kwarg typo) #237 fix, 2026-05-26): added `raise` to the guard. test_diffusion now fails — the very test added by `c61f67d` to prove multi-axis works.

Evidence the codegen handles multi-axis

  • `test_diffusion` (UNet2DConditionModel) passed under develop@`48c4979` while exercising this code path with multiple reduction loops, output checked via `torch.allclose(rtol=atol=1e-4)`.
  • The iteration that emits the loops (`for reduction_loop in reductions.loops:` with proper `code.indent(...)` per loop) is structurally correct for N loops.

Scope

Fixes the diffusion failures observed on PR CI runs since `5045837` landed on develop (e.g. run #404, #418).

Test plan

🤖 Generated with Claude Code

…sion

The guard at mlir_codegen_backend.py:909-910

    if len(reductions.loops) > 1:
        raise NotImplementedError("Not support multiple reduction axis..")

was a leftover from when the codegen was deliberately limited to a
single reduction axis, but multi-axis support was restored months ago
and the guard was never removed.

Timeline:
- 8eacf27 ("Optimize reduce/elementwise code", 2025): replaced
  `for reduction in reductions.loops` with `reductions.loops[0]`,
  added this guard (no `raise` — silently dead).
- c61f67d ("Support multi reduction dim + Add Diffusion model test",
  2025-08-14): restored the `for reduction_loop in reductions.loops`
  iteration explicitly to support multi-axis reduction. test_diffusion
  was added in this same commit and passed. The guard was left in
  place — harmless because still `raise`-less.
- 5045837 ("Fix four codegen correctness issues surfaced by review",
  2026-05-26, issue #237): added the missing `raise`, framing it as a
  "silently fell through to incorrect codegen" fix. In fact the
  codegen below the guard (which iterates all reduction loops) was
  correct — c61f67d had made it so — and adding `raise` broke the
  very test (test_diffusion) that c61f67d added to validate multi-axis
  support.

Right fix is to delete the guard, not add `raise` to it. The other
three items in #237 are unrelated and stand.

Verified: file py_compiles. CI test_diffusion is the empirical proof
that the post-guard codegen handles multi-axis correctly within the
allclose tolerance the test uses.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@YWHyuk YWHyuk merged commit 7acf8f7 into develop May 27, 2026
1 check 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.

1 participant