test(xla): validate Phase 3 hybrids on IREE-Metal

オープン
#3,351 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
8/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
docker, macos, python, pytorch, rust

調査の方向性

Start from spike/openxla/FINDINGS_ssm.md and the validation entry point scripts/xla/validate_arch.sh --device metal, then read the hybrid contract in src/lib/mlxcel-xla/src/emitter/model.rs (emit_transformer_layer) and builder.rs:166 for the bf16 restriction. Done means each listed family exits 0 at f32 and f16 on Metal with divergences recorded as near-ties. This depends on Phase 3 issues #3344 to #3349 and needs an Apple Silicon host, so it is not a first contribution.

索引モデルが issue の本文から書いたものです。

説明

area:architecture area:inference platform:macos priority:low status:ready type:test

Part of #564

Problem / Background

Epic #564 brings SSM / hybrid / recurrent architectures to the OpenXLA/IREE backend. Design record: spike/openxla/SSM_HYBRID_DESIGN.md (written 2026-07-01; most symbol locations it cites have moved, use the ones in this issue, which were re-located on main at 56bfb92a, and re-verify them before editing). The Stage 2a spike-first pattern this follows is in spike/openxla/STAGE2_DESIGN.md and spike/openxla/FINDINGS_phase2a.md.

Phase 3 (Nemotron-H #3344, sigmoid MoE #3345, Falcon-H1 #3346, Plamo2 #3347, Mamba1 / Falcon-Mamba #3348, Jamba #3349) is validated on ROCm. IREE-Metal is a separate lowering target with no bf16.

Goal

Every Phase 3 family except the 30B Nemotron-3-Nano passes its gates on metal at f32 and f16.

Scope

  • scripts/xla/validate_arch.sh --device metal for Nemotron-H-4B, Falcon-H1, Plamo2, mamba-130m-hf, Jamba-3B, and the synthetic Nemotron-H-MoE, at MLXCEL_XLA_PRECISION=f32 and =f16, using the checkpoints and oracles recorded in their issues.
  • Lowering fixes land here and must keep the ROCm gates green.
  • Metal section in spike/openxla/FINDINGS_ssm.md.

Acceptance Criteria

  • f32: each family's validate_arch.sh ... --device metal --batch 4 --requests 8 --maxcap 24 exits 0.
  • f16: the same; every divergence is a near-tie (top-2 gap below 0.01), listed in FINDINGS_ssm.md.
  • Server spot check on one hybrid (Nemotron-H-4B): 4 concurrent completions equal their CLI outputs.

Host and environment

Host: macOS on Apple Silicon only. bf16 cannot lower on IREE-Metal (src/lib/mlxcel-xla/src/emitter/builder.rs:166), so every gate runs twice, once with MLXCEL_XLA_PRECISION=f32 and once with MLXCEL_XLA_PRECISION=f16. The recurrent scan accumulation stays f32 on the f16 path; f16 runs pass when every divergence from the oracle is a near-tie (top-2 logit gap below 0.01, the epic's tolerance) and f32 runs are exact.

eval "$(scripts/iree/setup-macos.sh --env)"
export MLXCEL_XLA_DEVICE=metal
PY=spike/openxla/.venv/bin/python   # or $MLXCEL_ORACLE_PYTHON
cargo build --release --features xla-iree --bin mlxcel --bin mlxcel-server

Dependencies

Blocked by #3344 to #3349. The hybrid contract under test:

Hybrid contract from #3344 (restated so this issue stands alone): Config::layer_mixers: Vec<MixerKind> (Attention, Mamba2, None for an FFN-only layer, plus variants added by later units) selects the mixer per layer in emit_transformer_layer (src/lib/mlxcel-xla/src/emitter/model.rs:2938); Config::layer_has_ffn(li) selects whether the dense / MoE FFN runs; the KV cache is sized [B, L_attn, S, nkv, d] over attention layers only, and Config::attn_layer_index(li) -> Option<usize> maps a layer to its KV row (used by AttnLayout::write_read_kv and the shim's rg_dims); Config::state_layer_index(li) maps a recurrent layer to its row in each state tensor. The threaded-state ABI is the generic list from Config::state_tensors() (StateTensorSpec { name, dims, elem }), appended after the KV inputs/results in every graph flavor, with the KV region omitted when Config::has_kv_cache() is false.

Risks

  • Memory on the Mac used; skip a family that does not fit and report it rather than swapping.

User decisions that apply

  • Metal is a validation unit for macOS only; lowering fixes land in this PR.
  • Downloads are allowed. If spike/openxla/.venv is missing, create it with uv venv --python 3.12 spike/openxla/.venv and install CPU torch and transformers as pinned in spike/openxla/requirements.lock (torch==2.12.1+cpu from the PyTorch CPU wheel index, transformers==5.12.1). Small HF-format checkpoints go into models/hf/<name>; confirm the exact HF repo id on the model page before downloading. Gated-licence models are skipped and reported unless the licence is already accepted on this account.
  • Families whose HF modeling code cannot run on CPU (Kimi-Linear, RWKV7, and Plamo2 if its remote code needs mamba_ssm / causal_conv1d) use mlxcel's own MLX eager model as the oracle, following the pattern of the xla-reference-diagnostics feature examples (Cargo.toml:125, :570-575): run the MLX model greedily at temperature 0 on the same prompt and record its token ids in the oracle_continuation.py JSON format so xla_oracle_check and xla_batch_bench consume it unchanged.
主要言語
Rust
スター
505
フォーク
81
平均マージ
14時間 2分
マージ済み PR(30日)
448

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

lablup/mlxcel のほかの issue

lablup/mlxcel の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。