Repository navigation
Closed
Labels
platform:macosmacOS (Apple Silicon) specificpriority:mediumMedium prioritystatus:doneCompletedtype:testTest related changes
Milestone
Description
Problem
On M1 Ultra (release build, --features metal,accelerate, main as of 2026-10-26), the bf16 addmm rounding oracles fail deterministically.
cargo test --release --features metal,accelerate --lib dinov2_layers::policyfails 5 of 5 insrc/vision/encoders/dinov2_policy_tests.rs:objects_dino_linear_matches_authentic_bf16_addmm_oracle,objects_dino_attention_routes_qkv_through_addmm,objects_dino_attention_routes_proj_through_addmm,objects_dino_mlp_routes_fc1_through_addmm,objects_dino_mlp_routes_fc2_through_addmm. fc2 expects[1.0078125, 0, 0, 0](fused-bias rounding of the halfway case 1+1/256) and gets[1.0, 0, 0, 0](separate rounding).--lib vision::densefails 5 of about 192 with default threads and with--test-threads=1. Four fail in both:sam3::linear::tests::biased_bf16_projection_matches_mlx_addmm_rounding(expects 1.9296875, gets 1.9375),sam3d_body::layers::tests::sam3d_body_linear_preserves_bf16_and_authentic_addmm_rounding,sam3d_body::mhr_body::tests::sam3d_body_mhr_authentic_cpu_geometry_oracle,sapiens2::backbone::tests::sapiens2_bf16_rope_matches_upstream_compiled_graph. The fifth varies:sam3d_objects::layers::tests::compiled_objects_gelu_tanh_matches_authentic_power_oracle(parallel) versussapiens2::weights::tests::sapiens2_bf16_linear_uses_fused_bias_epilogue(serial).
Earlier full-workspace runs reported 11 and then 5 failures, so this was first logged as flaky; the serial run shows most failures are deterministic.
Hypothesis (unverified)
The oracles hard-code the rounding of a fused-bias addmm epilogue (linear_with_policy in src/vision/encoders/dinov2_policy.rs:19 calls mlxcel_core::addmm), while the MLX kernel selected on M1 Ultra for these shapes rounds the bias separately. The expected values may hold on the hardware where the tests were written (#2551, #2578). The varying fifth test suggests a kernel or compile-cache choice is also order-dependent.
Acceptance Criteria
- Determine on M1 Ultra why
addmmdoes not produce the fused rounding (kernel selection, MLX pin, or dtype path), with evidence. - Either fix the production path so the authentic rounding holds on all supported Apple Silicon, or make each oracle assert the rounding the selected kernel actually produces, keyed by a detectable property rather than skipped. Do not weaken assertions to a tolerance that would hide a routing regression; these tests prove the layer routes through addmm.
-
--lib vision::denseand--lib dinov2_layers::policypass on M1 Ultra over three repeated runs, in default and--test-threads=1modes. - The closing comment states the hardware verified and what was not verified.
Metadata
Metadata
Assignees
Labels
platform:macosmacOS (Apple Silicon) specificpriority:mediumMedium prioritystatus:doneCompletedtype:testTest related changes
Activity
inureyes commentedon Oct 26, 2026
Root cause and fix are in #2631. Short version: MLX's Metal addmm sends a single-row product to
gemv_axbpy, whose epilogue rounds the product to bf16 before adding the bias. The oracles were captured on ROCm and on x86_64 Linux CPU, where addmm rounds once. Upstreammlx0.32.4 on this M1 Ultra reproduces the split: GPU addmm at 1 row gives the separate value, and at 2 or more rows it gives the fused value. The #2614 pin bump did not change this code path. The varying fifth failure was a default-device race with the MHR CPU guard.Verified on Apple M1 Ultra (release,
--features metal,accelerate):--lib vision::dense: 192 passed, 3 of 3 runs in default mode and 3 of 3 with--test-threads=1, plus 40 of 40 default-mode runs of the built binary.--lib dinov2_layers::policy: 5 passed, 3 of 3 runs in each mode.Not verified on hardware: ROCm gfx1151, CUDA, Metal M3 or newer (the
gemv_widepath), and Linux CPU on architectures other than x86_64. For those, the expectations come from reading the MLX and overlay sources.test(vision): key bf16 oracles on the kernel each backend selects (la…