Repository navigation
update: advance MLX pin to 9f806b36 and refresh backend overlays - #2876
Merged
Merged
Conversation
Move the CMake pin from 7ca40033 (2026-10-26) to 9f806b36 (2026-11-05), a reproducible main snapshot 46 commits newer and 81 past stable v0.32.4, which the previous pin already postdated. Rebase the 14 drifted CPU, Metal and CUDA whole-file overlays with a three-way merge. Upstream #4803 now accumulates the CPU affine quantized matmul in float, so only fp_qmm and fp_qmm_t stay local. The new Metal affine qmv_mma (#4787) is placed behind the MLXCEL_QMV_WIDE off-switch so the speculative exactness retry still restores byte-equality between a verify block and the single-token chain. Metal device.cpp keeps the input-budget override across upstream's env rework, and quantized.metal re-appends mlxcel_affine_qmm_t_rows after the restructured instantiation macros. Two upstream API moves needed code changes: env::get_var is now config::get (#4647), used by the cxx bridge and the CUDA SDPA switches, and gpu_core_count() (#4781) needs IOKit on the macOS link line because upstream links it PRIVATE. Retarget the ROCm core files with the fork unchanged, resolve the fast.h and gpu/primitives.cpp conflicts, and regenerate CORE_RESIDUAL.diff. See docs/mlxcelverse/mlx-pin-2026-11-06.md.
… copy Upstream 4ca8d5d5a (ml-explore/mlx#4568) declares fast::template_arguments_hash in mlx/backend/common/custom_kernel.h, which mlx/fast.h includes. The fork keeps a private copy in mlx/backend/rocm/custom_kernel.cpp, so the unqualified call there matches both declarations and MSVC rejects it as ambiguous (C2668) when the ROCm backend and the common library are built together. Remove the fork copy; the upstream one also maps '-' to '_' in integer arguments so a negative template argument cannot produce an invalid kernel name. Recorded as LOCAL_FIXES item 73.
…gnatures Upstream 4ca8d5d5a (ml-explore/mlx#4568) added a generated-source hash to fast::CustomKernel's constructor, and the fork's mlx/backend/rocm/custom_kernel.cpp still passed grid as the fourth argument. Pass std::hash<std::string>{}(kernel_source), as the CUDA backend does; the ROCm JIT module keeps keying on the source itself (LOCAL_FIXES item 33). Upstream 5ee1e8edf (ml-explore/mlx#4711) added add_out_to_temporary_on_allocation to reshape_gpu, which the shared gpu/primitives.cpp overlay now calls with four arguments. The fork's definition in mlx/backend/rocm/copy.hip takes the flag and registers the output as a temporary when it is set, matching CUDA. The first was a compile error on MSVC; the second would have been a link error on any ROCm build. Recorded as LOCAL_FIXES items 73 and 74.
inureyes
pushed a commit
that referenced
this pull request
Nov 9, 2026
Document the deterministic temperature 0 argmax flip between plain and block-built KV history, with the two comparison scripts used to trace it. Measurements are reported with their environment (Qwen3-0.6B on M1 Pro, before the #2876 MLX pin), and the root cause stays open, matching the decision recorded on #2778. Refs #2778
This was referenced Nov 9, 2026
inureyes
added a commit
that referenced
this pull request
Nov 10, 2026
## Summary Four BF16 `addmm` oracle tests failed on Metal because they expected a single-row product to round twice. That expectation came from the old `gemv.h` epilogue, which cast the F32 accumulator to BF16 before adding the bias. Upstream ml-explore/mlx#4769 ("[Metal] Fix precision loss in addmm", commit `49366677`, 2026-10-29) adds the bias to the accumulator first in both `GEMVKernel` and `GEMVTKernel`. That commit has been in our MLX pin since #2876 (`9f806b36`), so `gemv_axbpy` now rounds once like every other route. The kernel change is intended upstream and no vision layer diverges from upstream `mlx.nn.Linear`, so no routing change is needed. ## Evidence (Mac Studio, Apple M3 Ultra) 1x4 @ 4x3 BF16 `addmm` with bias, expected fused `[1.296875, -0.50390625, 1.9296875]`, separate add `[..., 1.9375]`: | MLX | GPU, 1 row | GPU, 2 rows | CPU, 1 and 2 rows | |---|---|---|---| | released `mlx` 0.32.4 (PyPI) | separate | fused | fused | | upstream `mlx` built at `9f806b36` | fused | fused | fused | | mlxcel at `main` | fused | fused | fused | Released 0.32.4 shows the old split on M3 Ultra too, so the change comes from the pin, not from the GPU generation. ## Changes - `src/vision/addmm_oracle_test_support.rs`: remove `single_row_addmm_rounds_twice`, and rewrite the module doc around the pinned kernels and #4769. - The four oracles (sam3, sam3d_body, sapiens2, dinov2) assert the fused value at one row on every backend and keep the `ROUTING_ROWS` assertions. If a pin change brings the double rounding back, the one-row assertion fails. - The Sapiens2 oracle also asserts that plain `matmul + add` still gives the separate value at one row. ## Verification - The four tests pass on M3 Ultra: `cargo test -p mlxcel --lib --profile test-fast --features metal,accelerate -- --test-threads=1` filtered to them, 4 passed. - `cargo clippy -p mlxcel --lib --tests --features metal,accelerate -- -D warnings` is clean. - Hosts checked: M3 Ultra only. M1 Ultra, CUDA and ROCm were not run. CPU, ROCm and CUDA already expected the fused value, and the one-row assertion now expects the same value everywhere. Fixes #2916
This was referenced Nov 12, 2026
Closed
inureyes
pushed a commit
that referenced
this pull request
Nov 15, 2026
## Summary `native_env_tests::the_cuda_cache_defaults_reach_mlx` is the one test that fails in `make verify-test-cuda` on a host with a CUDA device. It reads a setting that MLX has memoized since the pin moved to `9f806b36` (#2876), and in the gate's order the CUDA device has resolved that setting first. This moves the check into a test binary of its own, where nothing has touched MLX before the appliers run. With it the gate passes every test binary. ## Related issues Closes #2987. ## Type of change - [x] `test` — tests only ## Cause The test removes `MLX_CUDA_GRAPH_CACHE_SIZE`, calls `apply_cuda_graph_cache_default()` and reads the setting back through `mlx_env_int`. Since #2876 that read is `mlx::core::config::get`, which stores the first value it returns for a name, the caller's default included, and answers from the store from then on (`mlx/config.cpp` at `9f806b36`). The CUDA backend makes that first read itself, with its own default of 400, when a command encoder is constructed (`graph_cache_` in the `device.cpp` overlay). The gate runs the `mlxcel-core` lib suite single threaded in name order, so `ffi_tests::*` have built the device long before `native_env_tests::*` run. Before #2876 the same read was `mlx::core::env::get_var`, a plain `getenv` on every call. Measured on this host, the `mlxcel-core` lib suite with `--features cuda -- --test-threads=1`: | Commit | MLX pin | Lib suite | The test alone | After one GPU test | |---|---|---|---|---| | `912858435`, the parent of #2876 | `7ca40033` | 2214 passed, 0 failed | ok | ok | | `f45a92cc9`, #2876 | `9f806b36` | 2213 passed, 1 failed | ok | FAILED, 400 | | `ce6855bc8`, `main` | `9f806b36` | 2260 passed, 1 failed | ok | FAILED, 400 | | this PR | `9f806b36` | 2260 passed, 0 failed | moved | moved | Production is not affected: the binaries call the appliers once at the top of `main`, before any MLX op. ## Change - `tests/cuda_cache_defaults_env.rs`: the same check, both names through the real appliers and read back through `mlx_env_int`, as the only test of its binary. It asserts the value in the C runtime first (`native_getenv`), so a failure tells an applier that did not write from a setting MLX had already resolved. - `src/lib/mlxcel-core/src/native_env_tests.rs`: the test is removed, with a comment where it was that says why it cannot live there. The other tests in that file use `NATIVE_ENV_TEST_*` names that nothing else reads, so they are not exposed. - No production code changes. ## Test plan Run on this PR's commit (`62b6010c7`, one commit on `ce6855bc8`) on a DGX Spark (GB10). - [x] `cargo fmt --all -- --check` - [x] `cargo clippy --workspace --all-targets --features cuda -- -D warnings` (the Linux spelling of the template's line) - [x] `make verify-test-cuda` (`cargo test --workspace --profile test-fast --features cuda --no-fail-fast -- --test-threads=1`): all 188 test binaries pass, 15487 tests passed, 0 failed, 496 ignored. On `main` it is 186 of 187 with this test as the one failure - [x] `cargo test --profile test-fast --features cuda -p mlxcel-core --lib --no-fail-fast -- --test-threads=1`: 2260 passed, 0 failed (`main`: 2260 passed, 1 failed) - [x] `cargo test --profile test-fast --features cuda --test cuda_cache_defaults_env`: 1 passed, also on a second run in a row - [x] The new test fails for the two things it guards. With a GPU eval placed in front of the appliers, which is what the lib suite did: `MLX_CUDA_GRAPH_CACHE_SIZE as MLX reads it`, `left: 400`, `right: 2000`. With the write removed from `apply_cuda_graph_cache_default`: `MLX_CUDA_GRAPH_CACHE_SIZE in the C runtime`, `left: None` - [x] The self-hosted `ci.yml` jobs a pull request from a fork does not get, run by hand: `clippy` (`cargo clippy -p mlxcel --lib --tests -- -D warnings`, default features), `cpu-link` (both commands; its `native_env` filter still runs 13 tests, since the moved one was CUDA only), `xla-compile` (`cargo check --features cuda,xla-iree --all-targets`, `cargo check --no-default-features --features xla-diagnostics --all-targets`): all pass - [x] `scripts/ci/check_env_var_docs.py`, `scripts/ci/check_native_env_writes.py`, `scripts/insert_apache_header.py --check`, `scripts/ci/check_cross_repo_refs.py`, and `python3 -m unittest discover -s tests -p 'test_*.py'` (219 tests): all OK - [ ] Validated with a real checkpoint: not applicable, no inference code changes. `cargo build --release` compiles neither file - [ ] `cargo deny check`: not run and not applicable (no manifest, lockfile or `deny.toml` change) - [ ] Metal and Windows: not built or run here ## Notes for reviewers - **Why a binary of its own, and not an assertion on the environment alone.** Asserting `native_getenv(name) == "2000"` in place would be independent of the order too, but it would no longer show that the value reaches MLX, which is what #2803 was about. `tests/rocm_fft_cache_env.rs` and `tests/cpu_device_custom_kernel_gates.rs` are the precedents for giving a process-global read a process of its own. - **The binary has to stay a single test.** A second test that evaluates an array, or reads either name, brings the order dependence back. Its header says so. - **`MLX_CUDA_SDPA_CACHE_SIZE` has the same exposure and was never reached.** The old loop asserted the graph cache first and stopped there. Its cache is built at the first cuDNN attention call. The new test checks both names, in a process where neither has been read. - **Not run:** Windows, where #2803 lived, and the reason the check exists. The test's content is unchanged apart from the extra C-runtime assertion, and it uses the same `mlxcel_core::native_env` functions as before. On a build without the `cuda` feature the file is an empty test binary (`#![cfg(feature = "cuda")]`). ## Checklist - [x] PR title uses a Conventional Commits prefix - [x] One logical change per PR - [ ] Updated `docs/`: no user-facing behavior or supported-model change - [x] Updated `// Used by: ...` comments: no shared function is modified - [x] No secrets, credentials, or `.env` files committed
This was referenced Nov 16, 2026
inureyes
added a commit
that referenced
this pull request
Nov 16, 2026
Advance the MLX pin from `9f806b36` to `fc344c98`, the head of upstream `main` on 2026-11-16 and one commit newer. Nothing else has merged upstream since the last bump (#2876). See `docs/mlxcelverse/mlx-pin-2026-11-16.md`. The new commit, ml-explore/mlx#4839, passes `MLX_CUDA_ARCH_LIST` to the compiler as one quoted macro and splits it at runtime, so MSVC with the Visual Studio generator accepts a multi-architecture CUDA list. It changes only `mlx/backend/cuda/CMakeLists.txt` and `mlx/backend/cuda/device_info.cpp`. mlxcel sets `MLX_CUDA_ARCHITECTURES` from `build.rs` and never reads the macro or `get_arch_list()`, so no mlxcel code changes. ## Overlays - None of the 175 overlay files is one of the two changed upstream files, so every CPU, Metal, CUDA and core overlay applies unchanged and keeps the base it was last merged from. - ROCm: `rocm_overlay.py retarget` moved the core files to the new pin with no conflicts, and `drift` reports the same residual as before. Only the `UPSTREAM` pin line and the `CORE_RESIDUAL.diff` header change. The fork stays `75915908`. ## Validation (Apple M3 Ultra) - Pin parsers: `cargo test -p mlxcel-mlx-pin` (52 + 1 passed), `scripts/ci/mlx_pinned_commit_test.sh` passed, and the CMake file resolves to `fc344c98`. - `make verify-rocm-overlay` and `rocm_overlay.py drift` pass. - Release build with `metal,accelerate` fetched and compiled MLX at `fc344c98`; the binary reports that commit. - Metal, serial: `layers::tests` 47, `sdpa`/`attention` 146, `qmm`/`qmv` 28, mlxcel-core `qmm`/`qmv`/`cpu_qmm_accum`/`mamba1_scan`/`nemotron_registry` 27, `models::{jamba,mamba,ssd_scan,nemotron_h}` 92, all passed. - Greedy generation with `gemma-3n-e2b-it-4bit` and `qwen3.5-4b-4bit` runs and is coherent. - fmt and env-var docs check pass. PR CI passed, including the Windows compile-only build, the CUDA architecture-list check and the MLX pin extraction. No CUDA compile ran (on this host or in PR CI), and the only functional change is in the CUDA build, so the next GB10 build is its first compile.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Advance the reproducible MLX pin from
7ca40033to9f806b36, a main snapshot 46 commits newer. Stable v0.32.4 (2026-10-14) predates the previous pin by 35 commits and the new one by 81, so selecting the release would downgrade the pin.Rebase every CPU, Metal and CUDA whole-file overlay onto the new pin while preserving local behavior, and retarget the ROCm core files with the fork unchanged. Two upstream API moves needed code changes:
env::get_varbecameconfig::get(#4647), andgpu_core_count()(#4781) needs IOKit on the macOS link line because upstream links it PRIVATE. Seedocs/mlxcelverse/mlx-pin-2026-11-06.mdfor the comparison and overlay audit.Overlay summary
_qmm/_qmm_tin float, so the fix(core): accumulate CPU quantized matmul in f32 for bf16 activations #2248 overlay keeps onlyfp_qmm/fp_qmm_t.qmv_mmafrom #4787 sits behindMLXCEL_QMV_WIDEso the exactness retry still restores byte-equality;device.cpp,quantized.metaland theload_safebounds were re-applied.gather_gemm, BF16 promotion and the gemv diagnostic are unchanged.75915908; thefast.handgpu/primitives.cppconflicts were resolved, andCORE_RESIDUAL.diffwas regenerated.Validation
cargo test -p mlxcel-mlx-pin: 52 unit tests and the cross-parser test;scripts/ci/mlx_pinned_commit_test.sh: 13 cases.make verify-rocm-overlay: passed.cargo build --features metal,accelerate: passed.layers::tests104,sdpa/attention77,qmm/qmv22, the three fused-launcher parity tests, andcpu_qmm_accum_tests4. Under the default parallel harness theqmm/qmvfilter fails two tests through the process-wideMLXCEL_QMV_WIDEpin; both pass serially.tomllib.