Repository navigation
feat(xla): bind operator numeric contracts into production artifacts - #3242
Merged
Merged
Conversation
Every production auxiliary artifact (LLaVA/SigLIP/Gemma3 vision, Qwen2-VL and Qwen2.5-VL main and diagnostics, Qwen3-VL, Molmo, Molmo2, Youtu-VL main and diagnostics, Gemma3n audio encode and merge, Phi4MM audio) now writes the v3 manifest instead of the v1 legacy one, so a cached VMFB whose stored numeric identity differs is rejected by verify_auxiliary_manifest and recompiled before IreeAuxiliaryModule::load runs it. operator_numeric_contract gains one shared builder (production.rs) that turns a family's declared operator list (families.rs), the Precision value its emitter used, the checkpoint dtype classes its loader observed, and the IREE backend identity into an OperatorNumericContractSet. Fixed-precision vision emitters now take their precision from a named constant the runtime also binds, and Gemma3n audio does the same, so the contract cannot drift from the graph. The kernel IREE picks per dispatch stays recorded as unobserved; this binds identity and claims no oracle qualification. compiler_version and runtime_archive_identity move from numeric_probe.rs to iree_identity.rs, shared by the probes and production. build.rs bakes the SHA-256 of the linked libiree_runtime_unified.a for the dist, CUDA, ROCm, and macOS layouts, since the CUDA source build has no dist archive to read at run time. Tests pin each family's operator set at its default CUDA and CPU precision, reject a stale cache for one mutation per field class (operator dtype, accumulator, association, precision, compiler, runtime, device), and cover the one-time v1 to v3 replacement. Text-only token/decode bundles, their goldens, and all tolerances are unchanged. Closes #3211
4 of 5 tasks
Gemma3n audio dequantizes affine weights on the host with BF16 rounding after the multiply and after the add, while Qwen2-VL and Qwen3-VL dequantize in F32. Both resolved to the same affine contract (host-affine-dequantized, separate-multiply-then-add), so switching Gemma3n's dequantizer would leave the manifest digest unchanged and a stale cached artifact would be reused. Add AffineEvaluationOrder::SeparateMultiplyThenAddBf16Rounded and AffineExecution::HostBf16Sequential, which resolves to it. Gemma3n now selects its dequantizer from one GEMMA3N_AUDIO_AFFINE constant and binds the same value into both audio contracts, so the rounding and the digest cannot drift apart. Existing identities for the other families and the micro-oracle probes are unchanged. A new test asserts the BF16-rounded and F32 host dequantization produce different contract identities. Contract and Gemma3n lib tests pass with and without the iree feature; clippy with iree is clean. Refs #3211
Member
Author
Implementation Review SummaryIntent
Findings Addressed
Remaining Items
Verification
|
Member
Author
Security and performance reviewNo CRITICAL or HIGH findings in this diff, so nothing was auto-fixed. Checked: the v3 manifest read/verify/replace path, the
Remaining items (not fixed here)
Verified: |
3 of 4 tasks
This PR is the first to write v3 auxiliary manifests in production. An older binary sharing the fixed temp_dir() caches (mlxcel-xla-vision-vmfb and the other auxiliary cache dirs) would hit reject_manifest_downgrade on the v3 manifest and fail its vision and audio loads instead of recompiling. aux_manifest gains schema_scoped_vmfb_path and qualify_auxiliary_artifact. A v1 contract keeps its caller path; every numeric schema lives in a sibling directory named after its manifest schema. All production call sites (and the micro-oracle probes) qualify through qualify_auxiliary_artifact and load the path it returns, so old and new binaries keep separate entries and the downgrade refusal still guards each schema's own directory. iree_identity::compiler_version_output memoizes the trimmed iree-compile --version stdout per compiler path, size and mtime. The six generation-identity helpers and compiler_version share it, so one artifact build spawns the compiler at most once; the generation identity strings are unchanged. Validated with the mlxcel-xla lib tests (435 without features, 105 with iree,micro-oracle over the manifest, contract, runtime and probe modules), clippy -D warnings with iree and with iree,micro-oracle,diagnostics, and fmt. A new test publishes v1 at the legacy path, qualifies v3 into the schema directory, and alternates both without a refusal or a third compile. On GB10, qwen3-vl-2b-instruct-4bit alternated between the main binary and this branch (main, branch, main, branch): main kept its v1 entry, the branch compiled once into the v3 directory, neither recompiled afterwards, and all four greedy outputs matched the earlier run. Refs #3211
Rewrap the paragraph describing the operator-numeric v3 manifest and its schema-named cache subdirectory to the file's 80-column style, which had a few overlong lines and a missing comma. No content change. The repository has no Korean counterpart of this document, and the mlxcel-xla README does not describe the artifact cache layout or manifest schema, so neither needed edits. Validation: cargo fmt --all -- --check and cargo clippy -p mlxcel-xla --lib --tests --features iree -- -D warnings pass. Refs #3211
The env-var-docs gate flagged MLXCEL_XLA_IREE_RUNTIME_SHA256, which the mlxcel-xla build script sets through cargo:rustc-env and iree_identity.rs reads with option_env!. Operators never set it, so it joins MLXCEL_XLA_IREE_DIST in the build-internal allowlist instead of the user-facing docs. Refs #3211
inureyes
marked this pull request as ready for review
November 22, 2026 19:45
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
Every production auxiliary artifact now writes the v3 manifest with an operator numeric contract instead of the unqualified v1 one. A cached VMFB whose stored contract differs is rejected by
verify_auxiliary_manifest(the checkIreeAuxiliaryModule::loadruns) and recompiled byensure_qualified_auxiliary_artifact. The kernel IREE picks per dispatch stays recorded as unobserved, so this binds identity and does not claim production qualification.operator_numeric_contract/production.rs) maps a family's declared operators (families.rs), thePrecisionits emitter used, the checkpoint dtype classes its loader observed, and the backend identity onto anOperatorNumericContractSet. All 11 formernew_legacy_unqualifiedcall sites use it. LLaVA/Qwen3-VL/Molmo/Molmo2/Youtu-VL emitters and Gemma3n audio now take their fixed precision from a named constant the runtime also binds; Qwen2-VL and Phi4MM pass the resolved value they emit with.compiler_version/runtime_archive_identitymove toiree_identity.rs(pub(crate), shared withnumeric_probe.rsand feat(xla): run the operator micro-oracles against MLX on CUDA #3212).build.rsbakes the SHA-256 of the linkedlibiree_runtime_unified.afor the dist, CUDA, ROCm and macOS layouts, because the CUDA source build has no dist archive to read at run time.dead_codeallows onnew_with_operator_numeric_contractand theoperator_numeric_contractmodule are gone; variants no production entry constructs keep item-level allows with reasons.new_legacy_unqualifiedstays foraux_smokeand the downgrade tests.Text-only token/decode emitters and goldens are untouched; no tolerance changed.
Changes during review
AffineEvaluationOrder::SeparateMultiplyThenAddBf16Rounded(withAffineExecution::HostBf16Sequential) is now selected by one constant that drives both the dequantizer and the contract, with a test that the two rounding modes give different identities.mlxcel-xla-aux-artifact-v3-operator-numeric/) chosen in one shared helper,qualify_auxiliary_artifact, so v1 and v3 entries coexist. Verified on GB10 by alternating main and branch binaries on qwen3-vl-2b-instruct-4bit: each reused its own entry, no refusal, identical greedy output.iree-compile --versionis memoized per compiler path, size and mtime, so building one artifact spawns the compiler at most once; generation identity strings are unchanged.cargo test -p mlxcel-xla --lib --profile test-fast435 passed;--features iree,micro-oracleover the runtime, manifest, contract and probe modules 105 passed.cargo check --features cuda,xla-iree --all-targetsandcargo check --no-default-features --features xla-diagnostics --all-targetspass.Test plan
cargo test -p mlxcel-xla --lib --profile test-fast: 433 passed (baseline 422 plus 11 new: per-family pins at default CUDA and CPU precision, one stale-cache rejection plus recompile per field class (operator dtype, accumulator, association, precision, compiler, runtime, device), v1 to v3 one-time replacement, observer and backend identity)cargo test -p mlxcel-xla --lib --features iree,micro-oracle --profile test-fastover the runtime, manifest and probe modules: 103 passedcargo clippy -p mlxcel-xla --lib --tests -D warningswith no features,iree, andiree,micro-oracle,diagnostics;cargo fmt --checkMLXCEL_BACKEND=xla,gpu-lock,-n 24 --temp 0), baseline binary from main vs this branch, each branch load run twice. Pass 1 replaced the v1 manifest with v3, pass 2 reused it (VMFB and manifest mtimes unchanged), and greedy output was byte-identical across all three runs for: llava-interleave-qwen-0.5b-bf16 (vision_runtime), qwen2-vl-2b-instruct-4bit (qwen2_vl_runtime, host-dequantized Q4 vision), qwen3-vl-2b-instruct-4bit, molmo-7b-d-0924-4bit (in-graph Q4 dequant,MLXCEL_XLA_CONTEXT_CAPACITY=512), molmo2-4b, youtu-vl-4b-instruct, all oncuda; gemma-3n-e4b-it-4bit audio onlocal-taskNot covered: no Phi4MM checkpoint on this host (unit pins only). Pre-existing failures on main block some planned runs: Gemma3n's text decode graph fails
iree-compileon CUDA (failed to distribute, e2b and e4b), hence CPU for its audio runtime; qwen2.5-vl-3b OOMs in text prefill at a 16410-token prompt; llava-1.5-7b-4bit rejects its config for IREE vision; gemma-3-4b hits the request-sized context capacity. Youtu-VL emits repeatedDbefore and after.Closes #3211