Repository navigation
fix(xla): build the Gemma 3 gate's eager reference from the loader's config - #2986
Conversation
…config The pinned eager-MLX-versus-IREE boundary gate for Gemma 3 (`xla_gemma3_reference_check`, lablup#869) fails on main at `siglip.hidden.block4.output`. Its eager reference parsed `VLMConfig` directly, so the `vision_config.hidden_act` that the pinned config omits stayed the serde default, exact erf. The loader and the OpenXLA emitter have resolved that omitted key to the tanh GELU since lablup#2552, so the gate compared an erf tower with a tanh graph. `parse_gemma3_vlm_config` is the loader's parse and resolution moved into one function. `load_gemma3_vlm` and the gate both call it, so the gate's reference is the tower the loader builds.
|
Implementation hardening for #2986. Reviewed #2985: the eager reference now shares Gemma3 config parsing with the production loader, including omitted/null tanh activation defaults, explicit activation values, and error context. No additional security or performance defect was found. Validation: Both new Gemma3 config tests passed in the combined CUDA candidate suite. The recorded 34-boundary checkpoint evidence was reviewed; that complete checkpoint gate was not re-run. Commands: |
Summary
The pinned Gemma 3 eager-MLX-versus-IREE boundary gate (
xla_gemma3_reference_check, the #869 gate) fails onmainatsiglip.hidden.block4.output. Its eager reference builds the SigLIP tower on the erf GELU, while the loader and the OpenXLA graph have run the tanh GELU for this checkpoint since #2552. This moves the loader's config parse into one function that the loader and the gate both call. The gate then passes all 34 stages.Related issues
Closes #2985.
Type of change
fix— bug fixCause
run_gemma3_eager_mlx_iree_prepared_boundaryparsed the pinned config withserde_json::from_value::<VLMConfig>and builtSigLipVisionModelfrom it. The pinnedconfig.jsonhas novision_config.hidden_act, so the field stayed the serde default,VisionHiddenActivation::ExactGelu. #2552 resolved an omitted key to the tanh GELU inload_gemma3_vlm(default_missing_hidden_act_to_siglip) and in the OpenXLA vision config; the gate's own parse dates from #917 and was not part of that change. The gate has compared an erf tower with a tanh graph since.Change
parse_gemma3_vlm_configinsrc/loading/vlm_gemma.rs: theVLMConfigparse and thedefault_missing_hidden_act_to_siglipcall thatload_gemma3_vlmhad inline, as one function.load_gemma3_vlmcalls it. Generation does not change.VLMConfigitself, so its reference is the tower the loader builds and cannot drift from it again.src/loading/vlm_gemma_tests.rs, which run in the default suite and need no checkpoint: an omitted or nullhidden_actresolves to tanh while the direct parse stays erf, a declared name is kept, and a parse error keeps the loader's message.load_gemma3_iree_host_preprocessoralso parsesVLMConfigdirectly, but it builds no host tower and never readshidden_act, so it is left as it is.Before / after
GB10 (sm_121, CUDA 13.0), IREE
3.12.0rc20260721fromscripts/iree/setup-cuda.sh,mlx-community/gemma-3-4b-it-4bit@93724907d4ed.mainisce6855bc8. Same command on both:mainfirst divergence: siglip.hidden.block4.output at flat index 61889PASS all pinned Gemma3 eager MLX/IREE boundary stagesmax_absof the IREE output against the eager MLX reference:mainsiglip.block0.mlp_fc1siglip.block0.mlp_activationsiglip.block0.outputsiglip.hidden.block4.outputsiglip.hidden.block20.outputsiglip.hidden.last_pre_layernormprojector.avg_pool_projectionEvery stage up to
mlp_fc1reads the same on both sides of the change. The first one that moves is the activation, by 4.766e-4 onmain; the largest difference between the erf and the tanh GELU is 4.732e-4 (at |x| = 2.70). The stage lines are the same, on both sides, with--features xla-diagnostics,xla-reference-diagnostics.Generation, to confirm that the loader refactor moves nothing.
generate --image <fixture> -p "Describe the image." -n 48 --temp 0, release builds ofce6855bc8and of this PR:mainagainst this PRmlx-community/gemma-3-4b-it-4bit, nohidden_acttest_image_shapes.png,test_image.png"hidden_act": "gelu"The two checkpoints answer differently from each other on both fixtures, in both builds, so a declared key is still read.
Test plan
Run on this PR's commit (
752e7ad4d, one commit once6855bc8) on a DGX Spark (GB10).cargo fmt --all -- --checkcargo clippy --workspace --all-targets --features cuda -- -D warnings(the Linux spelling of the template's line)cargo build --release --features cudamain, exit 0 with 34 of 34 stages on this PR. Its retained libtest wrapper passes as well (MLXCEL_GEMMA3_FIXTURE=<checkpoint> cargo test --profile test-fast --features xla-diagnostics,xla-reference-diagnostics --lib pinned_gemma3_eager_mlx_matches_iree_prepared_boundary -- --include-ignored)cargo test --profile test-fast --features xla-diagnostics,xla-reference-diagnostics --lib reference_boundary -- --test-threads=1: 11 passed, which are the 10 unit tests of the gate module and one audio test whose name the filter also matchescargo test --profile test-fast --features cuda --lib loading::vlm::gemma -- --test-threads=1: 18 passed, the two new tests among them. With the resolution removed fromparse_gemma3_vlm_config,gemma3_vlm_config_resolves_an_omitted_hidden_act_to_the_siglip_tanh_gelufails (left: ExactGelu,right: GeluPytorchTanh)make verify-test-cuda(cargo test --workspace --profile test-fast --features cuda --no-fail-fast -- --test-threads=1): 186 of 187 test binaries pass (15488 tests passed, 1 failed, 496 ignored). The one failure isnative_env_tests::the_cuda_cache_defaults_reach_mlx, which fails the same way on a cleanmain(it is order-dependent; described in the notes of perf(cuda): fuse the f32 tanh GELU into one bit-exact kernel (#2780) #2967)ci.ymljobs a pull request from a fork does not get, run by hand:clippy(cargo clippy -p mlxcel --lib --tests -- -D warnings, default features),cpu-link(both commands; 13 tests passed),xla-compile(cargo check --features cuda,xla-iree --all-targets,cargo check --no-default-features --features xla-diagnostics --all-targets): all passcargo check --features xla-diagnostics,xla-reference-diagnostics --all-targets, the feature set that compiles the gate: passescargo clippy -p mlxcel --lib --tests --example xla_gemma3_reference_check --features xla-diagnostics,xla-reference-diagnostics -- -D warnings: the lib test target stops at one finding,field_reassign_with_defaultinsrc/server/batch/xla_worker_tests.rs:1417. A cleanmainstops at the same single finding, and it is not in a file this PR touchespython3 -m unittest discover -s tests -p 'test_*.py'(the command ofmake verify-python-tooling),scripts/insert_apache_header.py --check,scripts/ci/check_cross_repo_refs.py: 219 Python tests OK, license headers OK, cross-repo refs OKmlx-community/gemma-3-4b-it-4bitcargo deny check: not run and not applicable (no manifest, lockfile ordeny.tomlchange)make verifyNotes for reviewers
reference_boundaryis compiled only withxla-reference-diagnostics, which no workflow turns on, and running it needs the pinned checkpoint. That is why the failure went unreported, and it is why I ran the gate by hand here. This PR does not add a job for it.parse_gemma3_vlm_config. The gate itself is covered only by running it, which is the table above.vlm_gemma_xla_tests.rs. I did not run the gate on an older commit.xla_molmo_reference_check,xla_llava_reference_check,xla_youtu_vl_reference_check): I do not have their checkpoints on this host.mainon this host.Checklist
docs/: no user-facing behavior or supported-model change// Used by: ...comments:parse_gemma3_vlm_configis new and carries one.envfiles committed