Repository navigation
fix(xla): compile the Gemma3n decode without aggressive fusion - #3375
Merged
Merged
Conversation
Since #3048 every decode compile passed --iree-dispatch-creation-enable-aggressive-fusion. On the Gemma3n decode graph the AltUp magnitude and a later RMSNorm square the same activation, IREE shares that x * x, and aggressive fusion pulls it into the RMSNorm reduction dispatch as a second, unreduced result. The CUDA VectorDistribute pipeline cannot distribute that store, so iree-compile fails with "'func.func' op failed to distribute" (main_dispatch_10_reduction_2048_f32) and Gemma3n text and audio generation fail on the CUDA device. The bundle flag assembly moves into bundle_compile_flags, and decode_compile_flags adds aggressive fusion only for the Dense decode graph it was measured on. Gemma3n stays on the compiler defaults on every device. The Dense flag set is unchanged, so its cached decode artifacts are reused. Tests: unit tests pin the flag split, and gemma3n_cuda_decode_compiles compiles the production e2b decode for CUDA with the production flags (skipped without the checkpoint, an NVIDIA driver, or a CUDA-capable iree-compile); it fails on the old flags with the reported error. On GB10, gemma-3n e2b and e4b text and e4b audio are token-exact with eager at --temp 0 -n 16. Closes #3363
Member
Author
Implementation Review SummaryReviewed against #3363 (body and comments). No CRITICAL, HIGH, or MEDIUM findings; no code changes pushed.
LOW, not fixed: the compile test uses a pid-named temp dir and assumes a |
inureyes
marked this pull request as ready for review
November 24, 2026 02:30
This was referenced Nov 28, 2026
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.
Summary
Gemma3n could not generate on
MLXCEL_XLA_DEVICE=cudabecause #3048 added--iree-dispatch-creation-enable-aggressive-fusionto every decode compile. In the Gemma3n decode graph the AltUp magnitude and a later RMSNorm square the same activation, IREE shares thatx * x, and aggressive fusion pulls it into the RMSNorm reduction dispatch (main_dispatch_10_reduction_2048_f32) as a second, unreduced result that the CUDAVectorDistributepipeline cannot distribute ('func.func' op failed to distribute).decode_compile_flagsadds aggressive fusion only forRuntimeConfig::Dense, the graph perf(xla): hold the decode KV cache in a module global to remove the per-step 32 MB copies #3043 measured it on. Gemma3n keeps the compiler defaults on every device. The doc comment names the failing dispatch and the IREE version so the exemption can be revisited on an upgrade.bundle_compile_flagsunchanged, so the regression test compiles with exactly the production flag set. The Dense decode flag list is byte-identical, so existing cached Dense decode artifacts still hit.Test plan
gemma3n_cuda_decode_compiles: emits the production gemma-3n-e2b decode and compiles it for CUDA with the production flags. It is skipped without the checkpoint, an NVIDIA driver, or a CUDA-capable iree-compile. With the old flags it fails with the reported error on the same MLIR hash as the sweep's cached graph.MLXCEL_SDPA_DETERMINISTIC=1) vsMLXCEL_BACKEND=xla MLXCEL_XLA_DEVICE=cuda,--temp 0 -n 16, token IDs identical: gemma-3n-e2b text ("Paris"), gemma-3n-e4b text, gemma-3n-e4b audio transcript ("Chapter 1. Mrs. Rachel Lind is Surprised. ...", 16/16 tokens).cargo check --features cuda,xla-iree --all-targets,cargo check --no-default-features --features xla-diagnostics --all-targets,cargo clippy -p mlxcel-xla --features iree --lib --tests -D warnings,cargo fmt --check.Closes #3363