Repository navigation
fix: resolve the late XLA vs eager greedy divergences (Gemma3, Phi4MM vision, Gemma3n pin) - #3404
Merged
Merged
Conversation
Issue #3391 needs the top-2 logit margin measured on both sides at each late XLA versus eager greedy divergence before deciding near-tie versus defect. Two pinned probe tests record those margins and gate the parity they measured. pinned_gemma3_greedy_margin_probe (new src/loading/vlm_gemma3_margin_tests.rs) drives the production eager greedy loop and the XLA prepared-prefill loop the way the CLI does over the pinned gemma-3-4b-it-4bit fixture, dumps the per-step top-2 margins on both arms, and asserts the top-2 candidate-set agreement at every step: a real numeric divergence fails it, a ranking flip inside a near-tie set is documented. Measured on GB10: at the divergence step both arms rank {2258, 3355}; eager picks 2258 by 0.25 (exactly one bf16 ulp at a ~36-logit magnitude) and XLA picks 3355 by 0.87, so the token 16 flip is a cross-backend near-tie, not a defect. The probe's teacher-forced continuation runs through a new XlaPreparedPrefillLogits::decode_ragged_logits shim in src/lib/mlxcel-xla/src/batch.rs, which exposes the engine's ragged decode with full per-row logits for diagnostics. pinned_phi4mm_vision_bisect_probe (new src/loading/vlm_phi4mm_margin_tests.rs) bisects the Phi4MM vision path stage by stage against eager (preprocessing, per-crop encoder hidden states, pool and projection) and names the first diverging stage. Measured: the path is bit-identical at every stage (max abs 0.0) and the CLI repro produces identical tokens on both backends, so the reported divergence does not reproduce on current main; the probe gates that parity a future loader change would break. Both tests are #[ignore]d (they need the pinned checkpoints plus MLX and IREE CUDA) and run with --test-threads=1 under --features cuda,xla-iree. Refs #3391.
The Gemma3n canonical pinned test
xla_canonical_diagnostics::pinned_e2b_intermediates_prefill_decode_and_greedy_match
failed its production-CUDA prefix-decode top1 pin: pinned 854, observed
236798. The old comment called it an unproven close-ranking
cross-device flip, which did not satisfy the issue's rule that a
re-pin requires a proven cause with the measured margin.
Measured on GB10 at the fc344c98 MLX pin: the eager prefix-decode ranks
236798 first, leading 854 by a 0.3125-logit margin at a ~14-logit
magnitude, the XLA side agrees on 236798 by 0.375, and the mlx-vlm
0.7.8 CPU oracle ranks 854 first by 0.75. A cross-build, cross-device
close-ranking flip: both top-2 sets are {854, 236798}, the ranking
flips with the toolchain and device, and the margins sit within a few
bf16 steps at that magnitude. The pin tracks the production CUDA
numerics.
Both assert sites in the two pinned tests now pin 236798 with the
measured margins recorded next to the pin. The re-pinned one-row test
passes (1 passed, 0 failed). Refs #3391.
This was referenced Nov 28, 2026
inureyes
added a commit
that referenced
this pull request
Nov 28, 2026
* docs(reports): generate an index for TECHNICAL_REPORTS TECHNICAL_REPORTS/ held 980 files (490 en/ko pairs) with no index and no inbound link, so a report could not be found or mapped to its PR. A hand-kept table would drift on the next report, so the index is generated. - scripts/ci/gen_reports_index.py writes TECHNICAL_REPORTS/README.md: one row per report stem, newest number first, with the PR link, the cleaned H1 title, the date (file-name suffix, else the header Date/Updated line) and en/ko links. --check exits 1 when the committed index is stale. - tests/test_gen_reports_index.py covers the stale cases (new report, retitled report, hand edit, missing index), unpaired and pipe-bearing titles, and asserts the committed index is current and links every report file. It runs in verify-python-tooling and CI's python-tooling job, so a report PR that skips `make reports-index` fails there. - Makefile gains reports-index and verify-reports-index; docs/README.md points at the directory. TECHNICAL_REPORTS/ is gitignored, so the README is force-added like the reports. Closes #1708 * docs: move the PR #3404 report into the 0.9 folder PR #3404 merged after the folder split (#3506) and filed its report at the TECHNICAL_REPORTS/ root, which the layout check now rejects on main.
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
Resolve the three late XLA versus eager greedy divergences from #3391 by measuring the top-2 logit margins on both sides at each divergence step, then documenting the near-ties and re-pinning the Gemma3n prefix-decode top1 with the measured margins recorded next to the pin.
Findings and what changed
pinned_gemma3_greedy_margin_probedrives both loops the way the CLI does, records per-step margins, and asserts the top-2 candidate-set agreement at every step, so a real numeric divergence fails it.pinned_phi4mm_vision_bisect_probegates the stage parity a future loader change would break.What changed
src/loading/vlm_gemma3_margin_tests.rs(new): the Gemma3 greedy margin probe, plusXlaPreparedPrefillLogits::decode_ragged_logitsinsrc/lib/mlxcel-xla/src/batch.rsas the teacher-forced continuation shim.src/loading/vlm_phi4mm_margin_tests.rs(new): the Phi4MM three-stage vision bisect probe.src/models/gemma3n.rs: prefix-decode top1 re-pinned 854 to 236798, measured margins documented at both assert sites.Test plan
cargo check --features cuda,xla-iree --all-targetsandcargo check --no-default-features --features xla-diagnostics --all-targetsfinish with no errors.Closes #3391