Skip to content

feat(xla): fail fast when MLXCEL_XLA_PRECISION=bf16 targets a Metal device #612

Closed

Description

@inureyes

Summary

On the OpenXLA/IREE Metal target, MLXCEL_XLA_PRECISION=bf16 cannot lower: the metal-spirv GPU target advertises no bf16 compute (compute = fp32|fp16|int64|int32|int16|int8), so the emitter's f32 to bf16 vector.bitcast fails to legalize inside iree-compile. Today this surfaces mid-run as a raw multi-line iree-compile legalization dump (failed to legalize operation 'vector.bitcast'), after model load, which is a confusing failure for an operator who just set the env var. Discovered in #575.

Ask

Detect the bf16 + Metal combination up front (at emit/load time, before iree-compile) and fail fast with a single clear, actionable error that points the operator at f16 (the portable low-precision entry on Metal). f16 and f32 on Metal, and bf16 on CUDA/CPU, must be unaffected.

Acceptance

  • Setting MLXCEL_XLA_PRECISION=bf16 with MLXCEL_XLA_DEVICE=metal errors early with a clear message naming the cause (no bf16 compute on the Metal target) and the fix (use f16), not the raw iree-compile legalization dump.
  • f16 (the metal default) and explicit f32 on Metal still work and stay token-exact; bf16 still works on CUDA and the CPU (local-task) targets.
  • Unit test for the guard (device + precision resolution), wired into the normal load/serve path, not a standalone helper.

References

#575, #611, ADR 0004, src/lib/mlxcel-xla/src/emitter/builder.rs.

Activity

  1. added
    area:inference
    type:enhancement
    priority:low
    status:ready
    on Jul 2, 2026
  2. added a commit that references this issue on Jul 2, 2026
    e096ac8
  3. self-assigned this
    on Jul 4, 2026
  4. added
    status:done
    and removed
    status:ready
    on Sep 6, 2026
  5. added a commit that references this issue on Oct 27, 2026
    b0f50cb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:inferencepriority:lowstatus:donetype:enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions