Repository navigation
Closed as not planned
Closed as not planned
Copy link
Labels
area:inferenceGeneration, sampling, decoding (incl. speculative, DRY)area:modelsModel architectures, weights, loading, metadataplatform:macosmacOS (Apple Silicon) specificpriority:highHigh prioritystatus:wontfixThis will not be worked ontype:bugBug fixes, error corrections, or issue resolutions
Milestone
Description
Problem / Background
The 2026-06-15 full M5 Max benchmark sweep (mlxcel 0.2.1, MLX pin a6ec7123) surfaced two models that regressed from working to FAIL:bench. Both were passing on the 2026-05-27 sweep and need a coordinated fix pass, so they are tracked here as one issue.
Source data:
benchmarks/metal_m5max_2026-06-15.csv(text decode)benchmarks/metal_m5max_vlm_2026-06-15.csv(VLM image decode)docs/benchmark_results/model_tests_m5max.md, Known Issues section, on branchdocs/m5max-benchmarks-0.2.1
Regression 1: hunyuan-moe-a13b-bf16
- Was 64.18 tok/s decode on the 2026-05-27 sweep (mlxcel 0.1.0). Now
FAIL:benchon 2026-06-15 (mlxcel 0.2.1). - Only the bf16 Hunyuan MoE path fails. The 4-bit Hunyuan MoE variants still pass at ~64 tok/s in the same sweep:
hunyuan-large-4bit(64.70),hunyuan-4bit(64.60),hunyuan-13b(64.75). - Suspected cause: interaction between bf16 expert weights and the now-default fused decode-MoE kernel.
MLXCEL_FUSED_MOEbecame default-on on 2026-06-14 (PR perf(moe): default-on MLXCEL_FUSED_MOE, validated on M5 (#282) #285, epic perf(models): general MoE decode gap vs mlx-lm (dots.llm1 0.51x, qwen3_moe 0.69x, nemotron MoE) #268). The fused-MoE decode kernel path may not handle the bf16 expert-weight case that the previousgather_qmmpath handled. First check: doesMLXCEL_FUSED_MOE=0restore it? If so, that confirms the interaction.
Regression 2: qwen2.5-vl-3b-4bit
- Was 165.50 tok/s decode on the 2026-05-27 sweep. Now
FAIL:benchon 2026-06-15 in both text mode and VLM image mode (confirmed in both CSVs). - Previously fixed by issue/PR fix: reset model-owned VLM fallback state #34 (EOS-terminate handling) and had been passing since. Something in the 06-11..06-15 changes broke it again.
- Additional signal: the non-quantized
qwen2.5-vl-3balso showsFAIL:benchin both modes, which points at a shared load/decode path rather than the 4-bit or image branch specifically.
Proposed Solution
Investigate and fix both regressions in one coordinated pass.
For hunyuan-moe-a13b-bf16:
- Run
mlxcel generatedirectly to capture the real error (the bench harness records onlyFAIL:bench). - Confirm whether
MLXCEL_FUSED_MOE=0restores generation. If yes, the fused decode-MoE kernel does not handle bf16 expert weights correctly. - Bisect across the 06-11..06-15 commits, focusing on the fused-MoE default (perf(moe): default-on MLXCEL_FUSED_MOE, validated on M5 (#282) #285) and the 06-15 quantized-bf16 change (perf: bf16->f16 quant-scale promotion (#260) regresses bf16-scale quantized model decode ~33-41% on M1 Ultra #289 / perf(models): keep quantized models bf16 to fix M1 Ultra decode regression (#289) #290).
- Fix the fused-MoE decode path to handle bf16 expert weights, or fall back to
gather_qmmfor that case.
For qwen2.5-vl-3b-4bit:
- Run
mlxcel generatedirectly (text and--vlm) to capture the real error. - Bisect across the same 06-11..06-15 window. Both text and VLM failing suggests a shared load/decode path, not the image branch.
- Re-validate that the fix: reset model-owned VLM fallback state #34 EOS-terminate behavior still holds after the fix.
Reproduction
M5 Max (or any Apple Silicon) with the checkpoints under models/:
./scripts/bench_decode.sh models/hunyuan-moe-a13b-bf16
./scripts/bench_decode.sh models/qwen2.5-vl-3b-4bit
./scripts/bench_decode.sh models/qwen2.5-vl-3b-4bit --vlmOr directly, to see the real error the harness hides behind FAIL:bench:
./target/release/mlxcel generate -m models/hunyuan-moe-a13b-bf16 -p "Hello" -n 50 --profile
./target/release/mlxcel generate -m models/qwen2.5-vl-3b-4bit -p "Hello" -n 50 --profileTo test the fused-MoE hypothesis for hunyuan:
MLXCEL_FUSED_MOE=0 ./target/release/mlxcel generate -m models/hunyuan-moe-a13b-bf16 -p "Hello" -n 50 --profileAcceptance Criteria
- Capture and record the actual error each model emits (run
mlxcel generatedirectly; the bench harness only reportsFAIL:bench). - Root-cause
hunyuan-moe-a13b-bf16: identify the breaking change via bisect across 06-11..06-15 (perf(moe): default-on MLXCEL_FUSED_MOE, validated on M5 (#282) #285 default-on fused MoE, perf: bf16->f16 quant-scale promotion (#260) regresses bf16-scale quantized model decode ~33-41% on M1 Ultra #289 / perf(models): keep quantized models bf16 to fix M1 Ultra decode regression (#289) #290 quantized-bf16), and confirm whetherMLXCEL_FUSED_MOE=0restores it. - Root-cause
qwen2.5-vl-3b-4bit: identify the breaking change via bisect across the same window; both text and VLM failing points at a shared load/decode path, not the image branch. -
hunyuan-moe-a13b-bf16loads and generates again on M5 Max, decode tok/s back near its prior value (~64). -
qwen2.5-vl-3b-4bitloads and generates again on M5 Max in both text and--vlmmodes, decode tok/s back near its prior value (~165). - Validated with a real checkpoint per CLAUDE.md (not build-only or synthetic-only).
- Add a regression guard if practical.
Technical Considerations
- Hunyuan MoE lives in
src/models/hunyuan_moe.rs(usesmlxcel_core::gather_qmmfor the quantized expert path). The fused decode-MoE machinery is insrc/models/switch_layers.rsand is gated byMLXCEL_FUSED_MOE(default-on since perf(moe): default-on MLXCEL_FUSED_MOE, validated on M5 (#282) #285). - bf16 vs f16 / quantized weight handling: non-quantized weights are converted in
load_and_sanitize_weights()(text) andload_vlm_weights()(VLM); quantized scales and biases stay bf16 (see perf: bf16->f16 quant-scale promotion (#260) regresses bf16-scale quantized model decode ~33-41% on M1 Ultra #289 / perf(models): keep quantized models bf16 to fix M1 Ultra decode regression (#289) #290). The bf16 MoE failure may sit at this boundary. - These are two distinct regressions but one coordinated fix pass. Keep each fix scoped, and land with real-checkpoint validation before merging.
Metadata
Metadata
Assignees
Labels
area:inferenceGeneration, sampling, decoding (incl. speculative, DRY)area:modelsModel architectures, weights, loading, metadataplatform:macosmacOS (Apple Silicon) specificpriority:highHigh prioritystatus:wontfixThis will not be worked ontype:bugBug fixes, error corrections, or issue resolutions
Activity
inureyes commentedon Jun 15, 2026
M1 Ultra investigation (cannot reproduce here; both look M5 Max-specific)
Tried to reproduce both regressions on M1 Ultra (128GB, mlxcel main post #289/#291). Neither reproduces on this hardware, so both appear to be M5 Max-specific. Details and a refined direction for the M5 follow-up:
Regression 2: qwen2.5-vl-3b-4bit -> healthy on M1 Ultra
Downloaded
mlx-community/Qwen2.5-VL-3B-Instruct-4bitand ran the same-process warmup+measure harness:mlxcel-bench-decode -m models/qwen2.5-vl-3b-4bit -p "Hello, how are you today?" -n 100 --warmup-tokens 20-> 103.20 tok/s decode, no abort.So the FAIL is not in the shared/model code; it is in the M5 Max path. The
vlm_concurrency.rsguard (#38) already notes the original abort was "during warmup on M5 Max", which points at an M5 neural-accelerator code path (the kind gated onhw.has_neural_accelerator && hw.macos_supports_na), not the generic transformer path that M1 Ultra exercises.M5 follow-up:
mainfirst (the 06-15 M5 sweep predates perf: bf16->f16 quant-scale promotion (#260) regresses bf16-scale quantized model decode ~33-41% on M1 Ultra #289/fix(models): infer per-tensor bits for quantized embeddings (mixed-precision exports like diffusiongemma fail to load) #291; confirm it still fails after those merges).FAIL:benchabort on M5 (the CSV only recordsFAIL:bench). That message will pin it.cargo test --release --test vlm_concurrency -- --ignored qwen2_5_vl_single_row_bench_prefill_succeeds_with_m5_warmup.Regression 1: hunyuan-moe-a13b-bf16 -> a memory limit, not the fused-MoE kernel
Hunyuan-A13B is 80B total (64 experts x 32 layers), so the bf16 export is ~160GB and cannot fit 128GB unified memory on either M5 Max or M1 Ultra. The
~64 tok/s at 0.1.0reading was almost certainly mmap/paging-assisted and at the edge of the limit; a small memory-behavior change in 0.2.x most likely tips it into OOM ->FAIL:bench.The issue's leading hypothesis (fused decode-MoE default-on does not handle bf16 experts) is ruled out by code: for non-quantized experts
SwitchLinearis theRegularvariant,quantized_parts()returnsNone, andforward_fused_kernelreturnsNone-> it falls back to the existinggather_mmpath. SoMLXCEL_FUSED_MOEnever touches the bf16 MoE path.MLXCEL_FUSED_MOE=0is expected to make no difference for this model.The 4-bit variant is fine and is the practical path:
mlx-community/Hunyuan-A13B-Instruct-4bit(~42GB) runs on M1 Ultra at 44.62 tok/s and passes on M5 Max (~64 tok/s in this same sweep:hunyuan-large-4bit64.70,hunyuan-4bit64.60,hunyuan-13b64.75 are all this same 4-bit checkpoint).Recommendation for regression 1: resolve as "bf16 Hunyuan-A13B (~160GB) exceeds 128GB; use the 4-bit variant" and, if desired, add a graceful pre-load memory check so it reports an OOM instead of aborting mid-load (validate on M5 Max). This is not a functional gap, since the 4-bit path works.
Summary
docs(benchmarks): correct M5 Max #294 entries; both failures were env…
inureyes commentedon Jun 15, 2026
Closing as not a code regression. Re-tested both models on mlxcel 0.2.1 (HEAD
891b9ef, rebuilt after thelayers.rspull); both failures were environmental:hunyuan-a13b-instruct-4bit, which runs fine at 64.92 tok/s and is now the canonical Hunyuan MoE reference (the redundant Hunyuan checkpoints were deduped).Docs corrected in #296: qwen2.5-vl restored to pass in both tables, the Hunyuan MoE rows consolidated onto the 4-bit checkpoint, and the two High Known-Issues entries cleared.
One minor harness gap noted (not blocking, captured as a Low note in the M5 Max doc): the oversized bf16 passed the size estimate and then OOM'd at load, so the bench logged
FAIL:benchinstead of a cleanSKIP:oom. Worth a small separate issue if we want the size estimator to account for bf16 expansion.docs(benchmarks): correct M5 Max lablup#294 entries; both failures we…