Skip to content
Draft
10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ xla-backend = ["dep:mlxcel-xla"]
# StableHLO prefill / decode_step graphs. Needs IREE_DIST at build time (the
# extracted iree dist), so it is a local / opt-in build, not a CI default.
xla-iree = ["xla-backend", "mlxcel-xla/iree"]
# Device-neutral reference capture for native IREE diagnostics. This keeps the
# eager MLX side on its default CPU backend and qualifies IREE `local-task`
# without requiring an IREE CUDA source/build tree.
xla-reference-diagnostics = ["xla-iree", "mlxcel-xla/diagnostics"]
# Explicit test-only forwarding for Gemma3n intermediate oracle validation.
# Its pinned reference is the production CUDA runtime, so enabling diagnostics
# also enables the root MLX CUDA backend. This is not part of `xla-iree`; normal
Expand Down Expand Up @@ -344,3 +348,9 @@ required-features = ["xla-micro-oracle"]
[[example]]
name = "xla_phi4_audio_check"
required-features = ["xla-iree"]

# Pinned #869 eager MLX CUDA versus IREE local-task Gemma3 boundary gate.
# This is a standalone executable so running it does not link libtest.
[[example]]
name = "xla_gemma3_reference_check"
required-features = ["cuda", "xla-reference-diagnostics"]
58 changes: 58 additions & 0 deletions examples/xla_gemma3_reference_check.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2025-2026 Lablup Inc. and Jeongkyu Shin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! Standalone pinned Gemma3 eager-MLX-CUDA versus IREE-local-task boundary gate.
//!
//! This executable intentionally avoids the Rust libtest harness. It accepts
//! command-line arguments first and falls back to the historical environment
//! variables used by the ignored test.
//!
//! ```text
//! IREE_DIST=/path/to/iree-dist \
//! cargo run --example xla_gemma3_reference_check \
//! --features cuda,xla-reference-diagnostics -- \
//! --model /path/to/gemma-3-4b-it-4bit \
//! --image tests/fixtures/test_image.png \
//! --device local-task
//! ```

use std::path::PathBuf;

fn argument(flag: &str) -> Option<String> {
let args = std::env::args().collect::<Vec<_>>();
args.iter()
.position(|argument| argument == flag)
.and_then(|index| args.get(index + 1))
.cloned()
}

fn required_path(flag: &str, variable: &str) -> PathBuf {
argument(flag)
.or_else(|| std::env::var(variable).ok())
.map(PathBuf::from)
.unwrap_or_else(|| panic!("missing required {flag} or {variable}"))
}

fn main() {
let model = required_path("--model", "MLXCEL_GEMMA3_FIXTURE");
let image = argument("--image")
.or_else(|| std::env::var("MLXCEL_GEMMA3_IMAGE").ok())
.map(PathBuf::from)
.unwrap_or_else(|| PathBuf::from("tests/fixtures/test_image.png"));
let device = argument("--device")
.or_else(|| std::env::var("MLXCEL_XLA_DEVICE").ok())
.unwrap_or_else(|| "local-task".to_string());

mlxcel::run_gemma3_eager_mlx_iree_prepared_boundary(&model, &image, &device);
}
Loading