Skip to content

update: reconcile Metal nightly fix with the current MLX pin - #2138

Merged
inureyes merged 14 commits into
mainfrom
fix/issue-1599-metal-gather-qmm-rhs-rows
Oct 14, 2026
Merged

inureyes merged 14 commits into
mainfrom
fix/issue-1599-metal-gather-qmm-rhs-rows

Conversation

@inureyes

@inureyes inureyes commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Reconcile the Metal nightly fix with main 9bfabbab after #2304. Main already contains the gather_qmm_rhs broadcast-row correction (B * M) and the two split-MTP portability fixes. Retain those implementations, and remove the obsolete Xcode 27 NAX overlay because pinned upstream MLX 243bdf09 supplies the correction from ml-explore/mlx#4594.

The remaining diff from main contains only MLX attribution and bilingual technical reports. Preserve the full MIT terms and expm1f attribution while removing references to the deleted overlay. Rustls 0.23.46 is already included through #2304.

Validation:

  • Production source is identical to main, whose exact pre-squash source 4befdbc7 passed Metal nightly 38583586205: fmt, Clippy, 12,315 workspace tests (390 ignored), and 51 FFmpeg video tests.
  • After reconciliation: six focused CUDA mxfp tests, 160 surgery tests, formatting, license-header and diff checks pass.
  • Historical M1 Ultra release A/B at 44045522: a 96-token prompt and 64 greedy output tokens, two runs per arm with fused MoE disabled, produced identical outputs (cbf1670d0b554a35c029ec4104ae3ecfc8a46e07296d7e33a5f3b2c214a5fa8f). The baseline retained Xcode compatibility and reverted only the row-count fix. This is not a fresh model run on the new pin. Reports preserve the artifact hashes.

Review found no remaining blocking implementation, security, or performance issue. M5 execution remains unverified. Keep #1599 open until the final post-merge main Metal nightly passes.

Refs #1599

@inureyes inureyes added status:review Under review type:bug Bug fixes, error corrections, or issue resolutions priority:high High priority platform:macos macOS (Apple Silicon) specific area:core mlxcel-core: MLX FFI, primitives, KV cache, layers labels Oct 6, 2026
inureyes added a commit that referenced this pull request Oct 6, 2026
`GatherQMM::eval_gpu` passes `x.size() / K` to `gather_qmm_rhs` as its row count. That is the row count of x before `gather_qmm_rhs` broadcasts it against the indices, so when one activation row is gathered against B sorted slots (M == 1, B >= 16, B / E >= 4) the grid and the kernel row bound cover one row and rows 1..B-1 of the freshly allocated output are never written. That is the nightly failure on the M1 Ultra runner since 2026-09-30: the `SortedSharedActivation` case of `mxfp4/mxfp8_gather_qmm_matches_host_reference` reads uninitialized memory (relative L2 7.4e32, non-finite values), while the same case passes on MLX's CPU backend in the same run.

The overlay now passes `B * M`, which equals the old value whenever x is already expanded (every `gather_sort` caller, so production MoE paths are unchanged) and covers the NAX variant too. Upstream ml-explore/mlx main carries the same line.

Not verified on Metal: this host is CUDA, where the overlay is not compiled.

Refs #1599
@inureyes
inureyes force-pushed the fix/issue-1599-metal-gather-qmm-rhs-rows branch from 838936a to 2520219 Compare October 7, 2026 14:34
@inureyes

inureyes commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

Metal validation passed on Apple M1 Ultra (128 GB), macOS 27.0 (26A428), full Xcode 27 RC, after rebasing this PR onto main b34d517bc422dd0465a6c404cbb2b84d4181124d. Tested head: 25202198c3ea7444cf9aa6b14c059f79683b75ab.

  • Main reproduces both SortedSharedActivation non-finite failures: mxfp4 and mxfp8 gather, 3 passed / 2 failed. This is the existing [nightly-verify] main is red #1599 defect.
  • PR: all five models::switch_layers::mxfp_tests pass with --profile test-fast --features metal,accelerate -- --test-threads=1. The Metal quantized.cpp object was rebuilt.
  • Release build passes. A transient sccache file-descriptor exhaustion was bypassed with RUSTC_WRAPPER=; no source change was needed.
  • Qwen3-30B-A3B-4bit, greedy 64 tokens, rainbow explanation prompt: main, main-repeat, and PR generated text are byte-identical via scripts/ab_output_equality.sh; SHA-256 d2f40b2d5831c3d7790d467fb51123f0d1f615fb7300aa2f92d86a9d8831a0de.

This satisfies #2158 item 4's local gate. Keep #1599 open until a post-merge Metal nightly make verify-test passes. M5 was not tested.

@inureyes
inureyes marked this pull request as ready for review October 7, 2026 14:39
Bring PR #2138 onto current main so its Metal kernel correction and the macOS nightly portability repairs are reviewed and validated against the complete post-October integration surface.

Refs #1599
Keep the broadcast-row Metal gather fix and make split-MTP staging tests follow canonical macOS paths and the host filesystem's invalid-byte filename support. Filesystems that reject the name must now return the same I/O error without leaving staging residue.

Update the bilingual report with the exact historical M1 evidence and current Linux build, focused-test, contract, and independent-review results. A fresh Metal nightly remains required before #1599 closes.

Refs #1599
Integrate the completed Kimi Linear chunked-prefill correction before publishing the refreshed #1599 candidate. The change is disjoint from the reviewed Metal overlay and split-MTP portability tests and will be covered by PR CI and the final integrated gate.

Refs #1599
Clarify that the #1599 Linux build, focused tests, contracts, and independent review preceded the disjoint merge of main's Kimi Linear correction. PR CI and the final integrated gate cover that last sync while the historical M1 evidence remains tied to its exact head.

Refs #1599
Record the successful candidate nightly at source head 2dbffe6, including the 12,283 core/workspace tests and 51 video tests. Keep historical checkpoint smoke evidence separate and retain the post-merge main nightly requirement for #1599.
Include the merged Qwen3 Next prefill contract update before validating the Metal correction against the current default branch. The tested Metal kernel and portability test sources remain unchanged.
…gather-qmm-rhs-rows

# Conflicts:
#	src/lib/mlx-cpp/patches/mlx/backend/metal/quantized.cpp
Normalize local cooperative-tensor operand types before passing them to the MPP destination factory. Register the pinned-source overlay so the new MLX gated-delta kernel compiles under Xcode 27.
Carry the upstream Apple copyright in the whole-file overlay so the repository license contract recognizes its source provenance.
Integrate the mlxcelverse overlay migration and subsequent main fixes into PR #2138. Resolve the sole location conflict by relocating the Xcode 27 gated-delta overlay under mlxcelverse while preserving the Metal B * M gather correction and split-MTP portability fixes.

Validation: focused Metal MXFP tests pass 5/5; focused split-MTP portability tests pass 2/2; license, shell and Rust MLX pin parsers, formatting, and diff checks pass. The full candidate Metal nightly remains required.

Refs #1599
Attribute the whole-file MLX NAX overlay in its preserved header, NOTICE, and README, including the upstream MIT terms and web-accessible source links.

Refresh the bilingual technical report with the current-main integration, exact-source green Metal nightly, and fresh compatibility-matched Qwen3-30B release A/B evidence.

Validation: license-header check, formatting, diff check, focused Metal and split-MTP tests, candidate nightly 38582194425, and byte-identical real-model A/B output.

Refs #1599
inureyes added a commit that referenced this pull request Oct 14, 2026
## Summary

Advance MLX from `59d600b5` to captured upstream main `243bdf09` (111 commits, 312 files). Reconcile whole-file overlays to retain mlxcel's numerical behavior and runtime controls without overwriting upstream fixes.

- Rebase 11 CPU/CUDA/Metal overlays, retain 17 unchanged upstream-backed files and two helpers, and retire two overlays covered by upstream #4514 and #4554. Preserve CUDA chunking, gathered GEMM, dtype controls, and the #1599 Metal `B * M` correction; use upstream #4594 for Xcode 27.
- Retarget ROCm while preserving fork `75915908`. Adapt move-only allocation ownership, borrowed-storage donation safety, compiled callbacks, SDPA sinks, gated-delta fallback, floor division, and odd inverse FFT. Add actual-header host ownership regressions; these do not prove HIP completion ordering.
- Fix the new CUDA RHS route's device argument and add aligned MXFP4/MXFP8 reference coverage. Retain reviewed macOS filesystem test portability fixes from #2138.

## Validation

- Pin/parser (27), overlay tooling (29), ownership, provenance, contract gates, Python tooling (123), and formatting pass.
- Earlier CUDA compilation and 94 focused numerical executions pass. After the final overlay retirement, 45 numerical executions and two forced RHS runs pass; fresh PTX proves f16/bf16 × MXFP4/MXFP8 route execution.
- [Earlier Metal CI on production source `3aeccc2b`](https://github.com/lablup/mlxcel/actions/runs/38492190049): fmt/Clippy pass; 12,285 tests pass, 390 ignored; 51 FFmpeg video tests pass.
- Actual GB10 Kimi 48B-A3B 4-bit inference passes three focused tests, five exact short/long controls, and a coherent 58-token explanation. This uses combined source `53473340` = production `3aeccc2b` + independent #2296 mask fix `1fec677b`; that model fix is not included here. CLI SHA-256: `b52d70388e0420582c4f60f3341d570c2afd736685b37e2c0c6e50ed9eaf5fae`.

ROCm compilation/runtime and M5-specific execution remain unavailable. Ordinary PR CI is tracked separately; queued checks are not passes. The requested whole-batch CUDA/Clippy and fresh main Metal integration gate remains deferred until the expanded follow-ups are ready. This PR does not independently close #1599, #2158, or #1986. English/Korean technical reports record provenance and remaining limits.

Latest main `59974283` is integrated, including the mlxcelverse layout migration. Resolve three rename/delete or relocation conflicts, update ownership-test paths and ROCm record numbering, and preserve main's ROCm/MoE improvements. Post-merge CUDA compilation, contract/ownership/provenance gates, Python tests, and 112 focused test executions pass, including directly forced RHS kernels. CUDA library suites on the merged production source pass 11,247 tests (170 ignored); full CUDA workspace/all-targets Clippy and CPU-only linking pass on final `4befdbc7`. The CUDA block-float archive audit and six quantization tests pass. Upgrade rustls from 0.23.45 to 0.23.46 to resolve RUSTSEC-2026-0346 through 0349; local and hosted cargo-deny pass. [Final Metal CI at `4befdbc7`](https://github.com/lablup/mlxcel/actions/runs/38583586205) passes fmt, Clippy, 12,315 workspace tests (390 ignored), and 51 FFmpeg video tests. Earlier actual Kimi results retain their original source attribution.

Closes #2303
Merge main after #2304 while retaining its gathered-row correction and portable tests. Remove the obsolete NAX compatibility overlay now supplied by upstream, and preserve MLX license terms with updated source attribution. The remaining diff from main is documentation only.

Production source matches the successful final Metal nightly and CUDA library validation recorded in the reports.

Refs #1599
@inureyes inureyes changed the title fix(metal): size gather_qmm_rhs by the broadcast x rows update: reconcile Metal nightly fix with the current MLX pin Oct 14, 2026
@inureyes
inureyes merged commit adf0e58 into main Oct 14, 2026
11 checks passed
@inureyes inureyes added status:done Completed and removed status:review Under review labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core mlxcel-core: MLX FFI, primitives, KV cache, layers platform:macos macOS (Apple Silicon) specific priority:high High priority status:done Completed type:bug Bug fixes, error corrections, or issue resolutions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant