Repository navigation
fix(xla): round the Molmo v1 vision tower at eager's F16 boundaries - #3399
Merged
Merged
Conversation
The Molmo-7B checkpoint stores its CLIP tower in F16, so eager MLX stores an F16 tensor after every operator, while the XLA graph ran the tower in f32. The difference concentrated in the outlier channel 650 (|x| up to about 200), which dominates each LayerNorm's variance, and the Molmo gate failed vision.selected_layer_21 (8 elements over VISION, max_abs 2.80) and vision.selected_layer_14 (4 elements, max_abs 2.69). Not a regression on CUDA: the #870 merge commit already fails selected_layer_21 here (4 elements, max_abs 1.56); #870 was qualified with eager on ROCm. The graph now rounds to F16 at eager's materialisation points (new emitter/molmo_vision_f16.rs): dequantized weights, linear products and bias adds, pixels and patch embedding, the position add, LayerNorm (normalized value, then one fused affine), quick_gelu, the attention context and residual adds. Dropping any one of them fails the gate again. The Molmo operator numeric contract declares F16 output rounding on those operators, so the manifest digest changes. Molmo2 is unchanged. The VISION tolerance is unchanged. compare_stage also lists the first failing elements so a failure can be traced to a row and channel. Gate 14/14 on local-task (selected 21/14 max_abs 2.50/2.47) and cuda (1.81/1.78). Molmo CLI greedy 16 tokens on XLA cuda matches eager. Closes #3390
inureyes
force-pushed
the
fix/issue-3390-molmo-vision-bound
branch
from
November 24, 2026 12:17
1ec83c2 to
cdc649e
Compare
inureyes
marked this pull request as ready for review
November 24, 2026 12:19
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
The XLA Molmo v1 vision graph now rounds to F16 wherever eager MLX stores an F16 tensor for the F16 checkpoint, instead of running the CLIP tower in f32. The
xla_molmo_reference_checkgate passes 14/14 onlocal-taskandcudawith theVISIONbound (atol 0.25, rtol 0.05) unchanged.Root cause
3ba57b30, no digest patch needed: the double hash came in with fix(xla): repair the OpenXLA feature compile job after #2819 #2837),vision.selected_layer_21already fails on this GB10 (4 elements, max_abs 1.56) and layer 14 passes (max_abs 1.59). feat(xla): support Molmo sparse additive visual embeddings #870 was qualified with eager on ROCm (gfx1151). Intermediate commits were not bisected further once the base itself failed.emitter/molmo_vision_f16.rs): dequantized weight; linear product and bias add (two roundings, asquantized_matmulthenadd); pixels, patch product and position add; LayerNorm with f32 statistics, F16 normalized value, thenw*n+brounded once (the CUDA kernel's half FMA; rounding the product and the sum separately measured worse, layer 21 max_abs 2.81 against 2.50); quick_gelu with the F16 coefficient and three roundings; the attention context; both residual adds. Ablations onlocal-task: dropping any one of linear, attention context, residual, quick_gelu or the pre-tower roundings fails the gate again (2 to 12 elements per stage); dequant was ablated against the two-rounding LayerNorm and also fails without it.Results (GB10, eager MLX on CUDA)
The issue reported identical failures on
cudabefore the fix (layer 21 max_abs 2.80, layer 14 2.69). After the fix the worst selected-layer element is 0.12 inside the bound onlocal-task(it was 0.69 over); the projector went from 0.004 inside the bound to 0.22 inside.compare_stagenow also prints the first failing elements (index, observed, reference).Test plan
xla_molmo_reference_check, pinned revision5c04b3a4,test_image.png: 14/14 onlocal-taskand oncudamlxcel generateon molmo-7b-d-0924-4bit,--image tests/fixtures/test_image.png -n 16 --temp 0, eager (MLXCEL_SDPA_DETERMINISTIC=1) andMLXCEL_BACKEND=xla MLXCEL_XLA_DEVICE=cudawithout a pinned capacity: identical 16 token idscargo test -p mlxcel-xla --lib -- molmo operator_numeric_contract(new emitter tests and the updated Molmo pins fail on main),cargo clippy -p mlxcel-xla --lib --tests -- -D warningscargo check --features cuda,xla-iree --all-targets,cargo check --no-default-features --features xla-diagnostics --all-targets,cargo fmt --check,python3 scripts/insert_apache_header.py --checkhip) eager and IREE not run: no AMD host hereCloses #3390