Skip to content

fix(xla): Gemma 3 eager-MLX/IREE boundary gate fails on main from a stale reference activation #2985

Closed

Description

@Jaeyeong-CHOI

Summary

The pinned Gemma 3 eager-MLX/IREE boundary gate (xla_gemma3_reference_check, the #869 gate) fails on main with the first divergence at siglip.hidden.block4.output. The IREE graph is not at fault. The gate builds its own eager MLX reference and runs the SigLIP tower on the erf GELU, while the loader and the OpenXLA emitter have run the tanh GELU for this checkpoint since #2552. No CI job compiles or runs the gate, so nothing reported it. Generation is unaffected (the loader and the OpenXLA path agree), but the gate can no longer confirm a change to either path.

Background

run_gemma3_eager_mlx_iree_prepared_boundary parses the pinned config with serde_json::from_value::<VLMConfig> (src/loading/vlm_gemma_xla_tests.rs:768) and builds SigLipVisionModel from it. The pinned config.json has no vision_config.hidden_act, so the field stays the serde default VisionHiddenActivation::ExactGelu (src/vision/config.rs, the #[default] variant). #2552 resolved an omitted key to the tanh GELU in the loader (default_missing_hidden_act_to_siglip, src/loading/vlm_gemma.rs:171) and in the OpenXLA vision config (src/lib/mlxcel-xla/src/emitter/vision_config.rs:451, SigLIP to GeluPytorchTanh). The gate's parse dates from #917 and did not get that resolution, so the reference first diverges at block 0's MLP activation and the error compounds through the tower.

Proposed Solution

Build the gate's eager reference from the same config resolution the loader uses, not a bare serde parse. Move the config parse and the missing-activation resolution into one function that the loader and the gate both call, so the reference tracks the loader's activation for this and future checkpoints.

Implementation Notes

  • src/loading/vlm_gemma_xla_tests.rs:768: serde_json::from_value parse of the pinned config; the gate panics at :1106 (Gemma3 eager MLX/IREE first divergence).
  • src/vision/config.rs: ExactGelu is the serde #[default] for an absent or null hidden_act.
  • src/loading/vlm_gemma.rs:171: default_missing_hidden_act_to_siglip resolves the omitted key to tanh.
  • src/lib/mlxcel-xla/src/emitter/vision_config.rs:451: an omitted key resolves to GeluPytorchTanh for gemma3 / siglip, QuickGelu for CLIP.
  • The gate compiles only under the xla-reference-diagnostics feature and needs the pinned checkpoint, which is why no workflow catches it.

Acceptance Criteria

  • The gate prints PASS all pinned Gemma3 eager MLX/IREE boundary stages and exits 0 on the pinned checkpoint.
  • All 34 boundary stages pass with the reference resolved the way the loader resolves the config.
  • The gate's eager reference and the loader share one config-resolution function, so the two cannot drift again.

Original Suggestion

Title: fix(xla): the pinned Gemma 3 eager-MLX/IREE boundary gate fails on main

Summary

The pinned Gemma 3 boundary gate (xla_gemma3_reference_check, the #869 gate) fails on main with Gemma3 eager MLX/IREE first divergence: siglip.hidden.block4.output. The IREE graph is not at fault. The gate builds its own eager MLX reference, and that reference runs the SigLIP tower on the erf GELU, while the loader and the OpenXLA emitter have run the tanh GELU for this checkpoint since #2552. No CI job compiles or runs the gate, so nothing reported it.

Reproduction steps

# mlx-community/gemma-3-4b-it-4bit at 93724907d4ed, the revision the gate pins
bash scripts/iree/setup-cuda.sh
eval "$(bash scripts/iree/setup-cuda.sh --env)"
cargo run --locked --profile test-fast --features cuda,xla-reference-diagnostics \
  --example xla_gemma3_reference_check -- \
  --model models/gemma-3-4b-it-4bit --image tests/fixtures/test_image.png --device local-task

Expected behavior

[gemma3-vlm-boundary] PASS all pinned Gemma3 eager MLX/IREE boundary stages, exit 0.

Actual behavior

Exit 101. Of the 34 stage lines, 23 are PASS and 11 are FAIL:

[gemma3-vlm-boundary] stage=siglip.hidden.block3.output status=PASS elements=4718592 atol=8.000e-2 rtol=4.000e-2 max_abs=7.163715e-2 max_rel=1.305640e4 failures=0 non_finite=0 first_failure=None
[gemma3-vlm-boundary] stage=siglip.hidden.block4.output status=FAIL elements=4718592 atol=8.000e-2 rtol=4.000e-2 max_abs=1.066561e-1 max_rel=1.742586e4 failures=5 non_finite=0 first_failure=Some(61889)
...
thread 'main' (1065246) panicked at src/loading/vlm_gemma_xla_tests.rs:1106:13:
Gemma3 eager MLX/IREE first divergence: siglip.hidden.block4.output at flat index 61889

mlxcel version

main @ ce6855b

Install method

Built from source

Platform

Linux + CUDA (gb10)

Model checkpoint

mlx-community/gemma-3-4b-it-4bit @ 93724907d4ed1745d2fe50baadf3b0b01a65abf2

Relevant logs

max_abs of the IREE output against the eager MLX reference, on ce6855bc8 as it is and with the reference's config resolved the way the loader resolves it. Same command, same host, same checkpoint:

Stage main Reference on tanh
siglip.block0.layer_norm2 2.384e-5 2.384e-5
siglip.block0.mlp_fc1 3.058e-5 3.058e-5
siglip.block0.mlp_activation 4.766e-4 1.274e-5
siglip.block0.mlp_fc2 2.270e-2 2.003e-5
siglip.block0.output 2.270e-2 1.669e-5
siglip.hidden.block3.output 7.164e-2 7.553e-4
siglip.hidden.block4.output 1.067e-1, FAIL 7.629e-4
siglip.hidden.block20.output 5.604, FAIL 1.000e-2
siglip.hidden.last_pre_layernorm 343.3, FAIL 0.2395
siglip.selected.post_layernorm 1.540, FAIL 1.720e-3
projector.avg_pool_projection 0.4582, FAIL 4.331e-4

Additional context

  • Cause. run_gemma3_eager_mlx_iree_prepared_boundary parses the pinned config with serde_json::from_value::<VLMConfig> (src/loading/vlm_gemma_xla_tests.rs:768) and builds SigLipVisionModel from it. The pinned config.json has no vision_config.hidden_act, so the field stays the serde default, VisionHiddenActivation::ExactGelu (src/vision/config.rs:59). fix(vision): add GELU selector, use tanh where checkpoints declare it #2552 (58db639) resolved an omitted key to the tanh GELU in the loader (default_missing_hidden_act_to_siglip, src/loading/vlm_gemma.rs:171) and in the OpenXLA vision config (src/lib/mlxcel-xla/src/emitter/vision_config.rs:451). The gate's parse dates from feat: add Gemma3 VLM OpenXLA path (#869) #917 and was not part of that change.
  • Why it is the activation. Every stage up to siglip.block0.mlp_fc1 reads the same with either reference. The error first moves at block 0's MLP activation, to 4.766e-4, and the largest difference between the erf and the tanh GELU is 4.732e-4 (at |x| = 2.70). With the reference on tanh that stage reads 1.274e-5 and all 34 stages pass.
  • Why CI did not see it. reference_boundary is compiled only with the xla-reference-diagnostics feature. The xla-compile job checks cuda,xla-iree and xla-diagnostics, and no workflow builds the example. Running it also needs the pinned checkpoint.
  • Generation is not affected. load_gemma3_vlm and the OpenXLA path agree with each other. Only the gate's reference is off, which means the gate cannot confirm a change to either path at the moment. I ran into this while validating perf(cuda): fuse the f32 tanh GELU into one bit-exact kernel (#2780) #2967, whose description records the failure as the behaviour of main on this host. This is the cause.
  • Not run. The gate on a commit before fix(vision): add GELU selector, use tanh where checkpoints declare it #2552: "since fix(vision): add GELU selector, use tanh where checkpoints declare it #2552" is read from the diff, not measured. The other reference gates (xla_molmo_reference_check, xla_llava_reference_check, xla_youtu_vl_reference_check): I do not have their checkpoints here. Metal and ROCm.
  • A fix with tests is ready on a branch: the loader's config parse and resolution, moved into one function that the loader and the gate both call.

Pre-submission checks

  • I searched existing issues and did not find a duplicate
  • This is not a security vulnerability (those go to SECURITY.md instead)

Activity

  1. changed the title [-]fix(xla): the pinned Gemma 3 eager-MLX/IREE boundary gate fails on main[/-] [+]fix(xla): Gemma 3 eager-MLX/IREE boundary gate fails on main from a stale reference activation[/+] on Nov 12, 2026
  2. added
    status:ready
    type:bug
    priority:medium
    area:inference
    modeltype:vlm
    on Nov 12, 2026
  3. added a commit that references this issue on Nov 15, 2026
    4a5bb51
  4. added this to the 0.9 milestone on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:inferencemodeltype:vlmpriority:mediumstatus:readytype:bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions