Repository navigation
perf(mlx): rebase MLX fork onto upstream 225e9c6e6 (#4953 fusion, #4802/#4781/#4682 NAX, #4893 D=256 SDPA, #4961 small-M GEMM) - #442
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
7c9a9eb to
d8590a8
Compare
…02/#4781/#4682 NAX, #4893 D=256 SDPA, #4961 small-M GEMM) Moves the `crates/mlx-sys/mlx` submodule from `76276123a` (base `bebd6422f`, 17 patches) to `84be893fe` (`mlx-node/rebase-2026-11-29`, base `225e9c6e6`, 15 linear commits): - Drops fork patches superseded upstream: custom-kernel source/hash cache (`#4568`), CUDA cuDNN `clear_streams` (`#4892`), and affine `qmv_wide` nv6-8 (`#4728`); squashes the CUDA `CustomKernel` ctor fix into patch 1. - Adapts remaining patches for upstream `#4953` (`mlx/compile/compile.cpp`), `#4885` (unlocked `cache_memory_locked` / `memory_limit_locked` inside `CudaAllocator`), `#4647` (`config::get`, `get_default_max_ops_mb_per_buffer`), `#4882` (`wait_for_capacity`), and `#4711`/`#4745`/`#4868`. - Adds fork patch 15 (`84be893fe`) hardening upstream `#4802` (`affine_quantize_rows`) with Splash's NaN/Inf bitmask propagation, `2^-100` subnormal floor, `precise::divide`, `clamp(-127, 127)`, and restricting `use_qmm_int_nax` to `bfloat16` (preventing `float16` `sum_hi` overflow above `65504`). - Updates `mlx-sys` bridge for `#4734` (`scaled_dot_product_attention` `window_size`, portable SDPA FC 304), `#4568` (`CustomKernel::state()` indices and `fast::CompileOptions`), `#4647` (`get_default_max_ops_mb_per_buffer`, live `get_env_int` in `mlx_segmented_sdpa.cpp`), `#4893` (D=256 SDPA `q >= 512` predicate), `#5003` (Windows `CMAKE_INSTALL_BINDIR="."`), C++20 bridge standard, and `metallib-select.ts` new-pin markers. - Fixes `kquant_qmv_t64` `load_vector` FP32 partial sum for `KQ_AFFINE` (`a4g64@t64` `M=1`) without touching any K-quant kernel bits, and updates upstream-affected tests, `gguf_planes` `ROUTE_SOURCES`, and docs.
…e (#4682, #4787, #4860, #4890)
Re-captures only `promoted` (MLX F32 `QuantizedMatmul` graph) digest lines
across all 14 `affine_mixed_{matmul,shapeless}.applegpu_*.txt` fixtures;
every `native` line and every dispatch counter is byte-identical.
Route-back proof (`MLX_QMM_SPLITK_MIN_M=34`, old `76276123a` vs new `48ddeaaee`,
verified bit-identical on `84be893fe` across all 7 GPU routes):
- 10,469 promoted cases / 80,628,416 elements across all 7 GPU routes: 0 mismatches.
Upstream attribution (1,861 moved promoted cases: 1,803 matmul + 58 shapeless):
- NAX routes (`g17s`/`g17d`/`g17g`, 599 cases): `#4682` (`bff10220c`) TF32
`qmm_splitk_nax`; `max|err|` unchanged (`29 -> 29`), `rel L2`
`1.665637e-03 -> 1.716309e-03`.
- Non-NAX routes (`g17p`/`g16s`/`g14s`/`g14d`, 1,262 cases): `#4787`
(`ba8c005c1`), `#4860` (`6d38ff93d`), `#4890` (`5cabdf509`)
`affine_qmv_mma`; `max|err|` unchanged (`15.99 == 15.99`), `rel L2`
unchanged to 7 digits (`1.657645e-03 -> 1.657645e-03`).
Host f64 reference summary across all 1,861 moved cases:
- elems moved: 2,460,749 / 33,779,712 (closer/farther: 1,823 / 2,458,926)
- max|e|: 29 -> 29
- rel L2: 1.662457e-03 -> 1.693176e-03
d8590a8 to
f427557
Compare
Summary
Rebases the
crates/mlx-sys/mlxsubmodule from76276123a(upstream basebebd6422f, 17 patches) to84be893fe(mlx-node/rebase-2026-11-29, upstream base225e9c6e6, +184 upstream commits, 15 linear patches).Key Upstream & Fork Changes
#4953compiled graph multi-consumer fusion,#4802default-on INT8 NAX affine prefill (M >= 32),#4781affine_qmv_nax,#4682TF32qmm_splitk_nax,#4893D=256q >= 512Metal SDPA,#4961small-M32×32Steel GEMM tiles,#5006float32hadamard_n,#5016Compiled::output_shapesbroadcast fix.84be893fe) —#4802INT8 NAX hardening: adds Splash's bit-level NaN/Inf quiet-NaN propagation,2^-100subnormal floor,precise::divide+[-127, 127]charclamp, finitesum_higuard inquantized_nax.h, and restrictsuse_qmm_int_naxtobfloat16(preventingfloat16group-sum overflow above65504).#4734scaled_dot_product_attentionwindow_size& portable SDPA FC 304;#4568CustomKernel::state()index shift &fast::CompileOptions;#4647get_default_max_ops_mb_per_buffer& liveget_env_intinmlx_segmented_sdpa.cpp;#4893q >= 512D=256 predicate;#5003WindowsCMAKE_INSTALL_BINDIR="."(build key4f58dd63); C++20 bridge standard;metallib-select.tsnew-pin markers (sdpa_split_reduce,affine_qmv_nax,affine_qmm_t_int_nax,affine_qmv_nax_).kquant_qmv_t64KQ_AFFINEfix: FP32 partial sum inload_vectorforKQ_AFFINEonly (a4g64@t64M=1error5.52e-3 -> 0.00e0, zero K-quant kernel bits changed).promoted(MLX F32QuantizedMatmulgraph) lines in all 14affine_mixed_{matmul,shapeless}.applegpu_*.txtfiles; 0nativelines changed.crates/mlx-sys/mlx-prebuilt.jsonpinned to published84be893fe6d6releases for macOS (mlx-prebuilt-84be893fe6d6-3d951e0b), Linux arm64 CUDA (mlx-prebuilt-84be893fe6d6-23ca1e3b), and Windows arm64 CUDA (mlx-prebuilt-84be893fe6d6-4f58dd63).ABBA Benchmarks (Apple M5 Max, 40-core GPU, 128 GiB, macOS 27.2.1)
Microbenchmarks & Operator Benchmarks
76276123a)48ddeaaee/84be893fe)#4953JITsilu_bwd(3+→1 kernel)#4953JITswiglu_bwd#4953JITgelu_approx_bwd/multi_out_gate_fwd17408×5120)M=8 / 16 / 51217408×5120)M=8 / 16 / 64 / 51217408×5120)M=8 / 16 / 512#4893qwen35_paged_prefill_operator_benchctx=16384, q=512#4893qwen35_paged_prefill_operator_benchctx=65536, q=1024End-to-End Models (ABBA)
76276123a)6k(6,219 in, 512 out) decodeacceptTotal=2.954exact)6kprefill6kdecode / warm prefillckpt=true,b=2×512)9.98818)Accuracy & Verification
--kv-format bf16 --activations bf16):qwen3.5-4b-nvfp4-mtp: vs BF16 teacher KL0.05119 -> 0.05081; vs self-OLD KL3.35e-3, top-197.46%qwen3.5-9B-unsloth: vs self-OLD KL1.47e-3, top-197.76%MLX_QMM_SPLITK_MIN_M=34): 10,469 promoted cases / 80,628,416 elements across all 7 GPU routes: 0 mismatches; hostf64across 1,861 moved cases:max|e|29 -> 29,rel L21.662457e-03 -> 1.693176e-03.84be893feafter rebasing ontoorigin/main(97fa4804c):./tests: 336/336 (6,043 assertions)mlx-sysbuild.rsprebuilt_tests: 11/11yarn build:native+vp test __test__/core/: 127/127kquant_suite: 87/87 (incl.#437split-K float32 regressions)affine_mixed_golden_gate: 16/16 across native + all 7 simulated GPU routessegmented_sdpa_golden_gate(3/3),qwen35_d256_sdpa(2/2),portable_d256_sdpa(2/2),bridge_metallib_names,kquant_metallib_names,mlx-paged-attn,mlx-core --lib(qwen4_exp,paged_int8_query_tests,gguf_planes,target_schedule_tests,kquant_tiled_tests,merged_draft_projections_match_separate_bits)cargo clippy --locked -p mlx-core -p mlx-sys -p mlx-paged-attn --all-targets -- -D warnings,cargo fmt --all -- --check,vp fmt --check,vp lint --type-aware,yarn typecheck— all pass.