Repository navigation
feat(xla): run the operator micro-oracles against MLX on CUDA - #3269
Merged
Merged
Conversation
The micro-oracle executor only accepted local IREE CPU targets and compared against hand-written Rust references, so every report was a canonical decomposition and NumericOracleClaim::ProductionMlx was never produced. The executor now resolves an IREE toolchain for local-*, cuda, and hip, and runs a probe artifact against any reference closure. The new public entry run_production_probe takes an external reference with its NumericBackendIdentity and builds the artifact's operator contract with the production contract builder, so the probe carries the identity scheme production v3 manifests use. Probes cover dense matmul, Q4 qmv (1 row) and qmm (16 rows, MLX qmm_sm80) against emitted dequant_affine plus the F16 projection, RMSNorm, LayerNorm, softmax, SiLU and GELU projections, residual add, cumsum, and the Gemma3n first SSCP convolution, which shares its operand layout and BF16 result helpers with the production subsampler. Comparisons reuse the canonical suite's modes; Q4 uses the Qwen same-input threshold and the convolution the Gemma3n audio stage bound. The xla_mlx_micro_oracle example (cuda, xla-micro-oracle) supplies MLX CUDA references and records MLX commit, overlay and Q4 kernel digests (refusing pre-#923 or stale kernels), MLX_ENABLE_TF32, compiled CUDA architectures, and device. Every family reference-check example now pins MLX_ENABLE_TF32=0 before MLX starts and refuses any other value. Refs #3212
5 tasks done
The Qwen3-VL DeepStack oracle could only score a synthetic four-token prompt and reported nothing about how close the top-1 decision was, so a greedy divergence against eager MLX could not be told apart from an XLA defect. - `--token-ids` replays an actual unexpanded prompt plus teacher-forced generated tokens, so the final-position logits can be read at any greedy index. - The report records the top-5 logits and the top-2 margin for IREE, for eager MLX, and for eager MLX fed the IREE vision features. - Every vision block now gets a same-input projection control. Blocks 0 and 1 stay gated as before; blocks 2 and later are reported under `same_input_report` and never gated, so no threshold changes. - A same-input language control runs the eager language model on the IREE main-merger and DeepStack features through the new `Qwen3VLModel::get_input_embeddings_from_features`, which shares the merge, DeepStack-state and MRoPE-state code with `get_input_embeddings`. - Each comparison records the reference peak magnitude and the element that most exceeds the tolerance. On `tests/fixtures/test_image.png` at generated index 8 (GB10, CUDA) the IREE top-2 are 6437 at 22.8980 and 4285 at 22.8781 (margin 0.0198). Eager MLX gives 4285 at 22.875 and 6437 at 22.75, a margin of 0.125, which is one bf16 step at that magnitude. When eager MLX is fed the IREE vision features the two tokens tie exactly at 23.0. Every same-input control passes, and all three post-injection language layers pass with zero failures when both sides see the same vision input. The divergence is a near-tie inside the reported drift (final-logit max_abs 0.31 chained, 0.26 same-input), not an XLA defect.
This was referenced Nov 23, 2026
The production-MLX SSCP convolution probe gated only the Gemma3n audio stage max_abs bound of 5e-3 and reported the stage RMS bound of 5e-4 without enforcing it, so the probe admitted outputs the family gate would reject. The fixture makes the comparison exact by construction: the BF16-exact dyadic operands give products that are multiples of 2^-14, and every 3x3 window sum stays far inside the 24-bit F32 significand, so any F32 accumulation order or FMA contraction yields the same sum and both backends round one value to BF16. The probe now uses ExactBits, and a unit test checks the window-sum bound on the actual fixture so a future fixture change cannot silently void the argument. Validated with the mlxcel-xla production and numeric_probe unit tests, clippy on mlxcel-xla, and xla_mlx_micro_oracle on GB10 cuda under gpu-lock: 11 of 11 pass, the SSCP report in exact-bits mode with max_abs 0. Refs #3212
Member
Author
Implementation Review SummaryIntent
Findings Addressed
Remaining Items
Verification
|
Member
Author
Security and Performance ReviewNo CRITICAL, HIGH, or MEDIUM findings, so no fix commits were pushed. The two items the implementation review already left open (overlay digest computed from the checkout, TF32 missing from some JSON reports) are not repeated here. Checked
LOW
|
…fest The micro-oracle identity walker used Path::is_dir, which follows symlinks, so a symlink loop under the overlay tree could recurse without bound. It now classifies entries with DirEntry::file_type, which does not follow links, and hashes a symlink as its link target under a "symlink:" prefix so the digest stays deterministic. A unit test covers a loop. The Youtu-VL reference example now records MLX_ENABLE_TF32 in its JSON manifest through the shared mlx_reference_policy helper, like the Qwen, vision and llava reports. The Youtu-VL oracle accepts that optional top-level key on the mlxcel capture only, requires the value 0, and still rejects it on the HF reference; a test covers all three cases (the Python test could not be run here because numpy is not installed; both files compile). Validation: - cargo fmt --check - cargo clippy -p mlxcel-xla --lib --tests --features iree,micro-oracle -- -D warnings - cargo clippy --features cuda,xla-diagnostics,xla-reference-diagnostics,xla-micro-oracle --examples -- -D warnings - cargo test -p mlxcel-xla --lib --profile test-fast --features iree,micro-oracle numeric_probe (16 passed) Refs #3212
inureyes
marked this pull request as ready for review
November 23, 2026 02:18
…da-mlx-micro-oracles # Conflicts: # CHANGELOG.md # src/lib/mlxcel-xla/src/numeric_probe.rs
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
The micro-oracle executor now runs the emitted IREE operation on
cudaandhipas well as local CPU, andmlxcel_xla::run_production_probetakes an external reference with its backend identity, somlxcel-xlanever calls MLX. The newxla_mlx_micro_oracleexample (--features cuda,xla-micro-oracle) supplies MLX CUDA references throughmlxcel-coreand producesproduction-mlxreports. Every family reference-check example pinsMLX_ENABLE_TF32=0before MLX starts, refuses any other value, and records it.production_operator_contract, emitter revisionmlxcel-xla-stablehlo-emitter-v1); the SSCP convolution reuses Gemma3n's ownsubsample.convolutiondeclaration and the subsampler's operand-layout and BF16-result helpers, factored out ofsscp_convwithout changing its emission order.--atol/--rtol0.08; the convolution uses ExactBits, because its BF16-exact fixture keeps every window sum exact in F32 under any accumulation order (the Gemma3n stage gate'smax_abs5e-3 plus RMS 5e-4 has no single element-wise mode). No new tolerance.qmm_sm80_r2revision, and writes Q4 reports in a separateq4_post_923_reportssection.Evidence (GB10 spark-102, all GPU work under
gpu-lock)MLX
fc344c98, overlays sha256543a0239..., Q4 kernel sha256abbae771...,MLX_ENABLE_TF32=0, CUDA archs121, NVIDIA GB10 sm_121. IREE compiler 3.12.0rc20260721 @dc9601f8, runtimelibiree-runtime-sha256-41529a0b...,--iree-hal-target-device=cuda.qmv)qmm_sm80)Every report is
production-mlxwithproduction_qualified=false, because IREE exposes no dispatch kernel identity. Kernel paths come fromMLXCEL_TRACE_ARCH=1runs with--only q4-qmvand--only q4-qmm. WithMLX_ENABLE_TF32=1the example exits before MLX starts.Greedy token comparison,
tests/fixtures/test_image.png, prompt "Describe this image.",-n 64 --temp 0, XLA withMLXCEL_BACKEND=xla MLXCEL_XLA_DEVICE=cuda MLXCEL_XLA_CONTEXT_CAPACITY=16512:785 2168 374 264 6437 18575 1894 13then stops at<|im_end|>. XLA emits the same 8 tokens, then 151645 and keeps going, because the checkpoint has nogeneration_config.jsonandmlxcel_xla::read_eosreads only that file (fix: read eos_token_id from config.json when the XLA backend has no generation_config.json #3292). Token-exact up to EOS.1986 2168 374 264 7377 39034 315 264); at generated index 8 MLX picks 48204 and XLA picks 6437. Two causes, neither an XLA operator defect. First, the eager image processor ignores the checkpoint's pixel bounds, so eager sees 49 image tokens where XLA and HF see 64 (fix: honour checkpoint pixel bounds in the eager Qwen3-VL image processor #3290). Second, with identical 64-token input the step is a near-tie: XLA top-2 margin 0.020, eager 0.125 (one bf16 step), and eager language fed the XLA vision features is an exact bf16 tie. XLA runs the vision tower in f32 and eager in bf16; matching the rounding boundaries is update: run the XLA Qwen3-VL vision tower at eager's bf16 rounding boundaries #3291. Every same-input per-block vision control and the same-input language control pass at the unchanged 0.08/0.08.xla_qwen3_vl_deepstack_checkgains--token-ids(teacher-forced replay of a real prompt), top-5 logits and top-2 margins for IREE, eager, and eager on IREE vision, report-only per-block same-input vision controls for blocks 2-23, and a same-input language control.Qwen3VLModel::get_input_embeddings_from_featuresshares the existing merge, DeepStack and MRoPE steps with the production path through one private helper.Two more pre-existing findings: the CLI sizes an XLA Qwen-VL image request from the worst-case floor at
DEFAULT_MAX_PIXELS(16410 positions for a 224x224 image that expands to 64 tokens), and the request-sized 32768 shape runs out of CUDA memory inprefill_embeddings. An explicit 16512 capacity works.Test plan
cargo test -p mlxcel-xla --lib --profile test-fast --features iree,micro-oraclefiltersnumeric_probe,production_probe_ops,gemma3n_audio,numeric_ops,operator_numeric_contract(all pass)cargo clippy -p mlxcel-xla --lib --tests --features iree,micro-oracle -- -D warnings, and--lib --features ireecargo clippy --features cuda,xla-diagnostics,xla-reference-diagnostics,xla-micro-oracle --examples -- -D warningsxla_numeric_probe local-task: all 9 canonical reports pass unchangedxla_mlx_micro_oracleon cuda: 11 of 11 passpython3 scripts/ci/check_env_var_docs.py,cargo fmt --checkcargo check --features cuda,xla-iree --all-targetsand--no-default-features --features xla-diagnostics --all-targetsspike/openxla/test_youtu_vl_reference_oracle.py(15 pass; the oracle now acceptsmlx_enable_tf32=0on the mlxcel capture only)Closes #3212