Repository navigation
refactor(mlxcelverse): organize MLX-side overlays and custom kernels under src/lib/mlxcelverse - #2305
Conversation
…under src/lib/mlxcelverse
Reorganize `src/lib/mlx-cpp/` into `src/lib/mlxcelverse/` so that mlxcel's C++ MLX layer has a clean, self-documenting two-tier boundary between backend source overlays (`overlays/{cpu,metal,cuda,rocm}/mlx/...`) and mlxcel-owned fused custom kernels (`kernels/`).
- Move `src/lib/mlx-cpp/CMakeLists.txt` to `src/lib/mlxcelverse/CMakeLists.txt` and update `mlx_apply_source_overlays` to apply `overlays/cpu` and `overlays/metal` unconditionally, `overlays/cuda` when `MLX_BUILD_CUDA` is enabled (consolidating the previously split `patches/mlx/backend/cuda/` and `patches-cuda/` directories into a single `overlays/cuda/mlx/` root), and `overlays/rocm` when `MLX_BUILD_ROCM` is enabled.
- Move `src/lib/mlx-cpp/turbo/` to `src/lib/mlxcelverse/kernels/` and update `src/lib/mlxcel-core/build.rs`, `src/lib/mlxcel-core/Cargo.toml`, and `src/lib/mlxcel-core/cpp/*.{cpp,h}` include paths (`"../../mlxcelverse/kernels/..."`).
- Add `README.md` files for `src/lib/mlxcelverse/` and `src/lib/mlxcelverse/overlays/{cpu,metal,cuda}/` explaining the layer split, overlay mechanics, base-commit provenance headers, and per-backend scope.
- Update CI workflows, pin and lint gates (`mlx_pinned_commit.sh`, `check_cuda_arch_lists.py`, `check_kernel_dtype_keys.py`, `check_kernel_port_dispatch.py`), ROCm overlay tooling (`scripts/mlxcelverse/rocm_overlay.py`, `sync_from_fork.sh`), documentation (`CONTRIBUTING.md`, `NOTICE`, `docs/*`), and test fixtures (`mlxcel-mlx-pin`, `paged_pool_offset_tests`, `memory_estimate_inflight_tests`) to reference `src/lib/mlxcelverse/`.
Closes #1816
Implementation Review SummaryIntent
Findings Addressed
Remaining ItemsNone Verification
|
Security and Performance Review SummaryThreat Boundaries & ScopeThis review evaluates the architectural re-organization of mlxcel's MLX-side C++ layer from Security Assessment
Performance Assessment
Findings
Verification
|
PR Finalization CompleteSummary
All narrow gates pass cleanly. Ready for merge. |
…2318) ## Summary Classify the #1712 failure as far as the evidence allows, make the next recurrence self-classifying, and fix a coverage gap found on the way: the "steel envelope" test has not exercised the steel kernel since May. ## Findings **The test never reached the steel kernel.** `update_and_turbo4_delegated_attention` tries the dequant-first SDPA route first, and that route has been default-on since f77e98b (2026-05-08, two days after the test landed in 09d9cc6). Under the default env the wrapper returns before `attention_turbo4_delegated_steel`, and nothing else calls it. So the test, and the launcher CONTRIBUTING.md names for post-pin-bump re-validation, compared dequant-first SDPA against the cold-only composition. The `4.6824e-1` came from that pairing, not from `turbo4_delegated_steel_sdpa`. **The wrong value is "cold V contribution dropped".** I rebuilt step 0 (cold_offset=8, hot_offset=1, same seeds) on CUDA and measured candidate wrong outputs against the graph reference. Attention with the cold V rows zeroed sits at RMS 4.6820e-1, 4e-5 from the reported 4.6824e-1 (the two correct paths differ by about 1.4e-4). The next closest candidates are far off: K read at full buffer capacity 4.03e-1, all-zero output 5.12e-1, hot V dropped 5.15e-2, missing inverse rotation 7.85e-1. So on one side the cold contribution was all zeros: either the bulk rotated-dequant output (dequant-SDPA route), the cold weighted-sum output (cold-only route), or a zero `v_rescale`. A never-written fresh Metal buffer reads as zeros, which explains why the value repeated to five digits while the failure itself was rare. The value alone cannot tell which side or which of these. **It has not recurred.** Nightly verify since 2026-09-08: 48 runs. 44 ran the test and all 44 passed (0accedd through 537ebe1, four Mac minis). One run failed before the test step (38430123889) and one was cancelled. Six of the passes ran on MLX 243bdf09 (PR #2304 branch and main after the merge). Every nightly passes `--test-threads=1`, while both failures came from multi-threaded workspace gates. That fits the shared-device hazard of #163/#1008 but does not prove it. In this window the delegated kernel source changed only by #2029 (dispatch through `select_kernel_port`, kernel bodies untouched), the #2305 move, and the #1796 header update. A code read of the three launchers found no unwritten output region, out-of-bounds index, or missing barrier. ## Changes - New test-only `cache/delegated_parity_diag.rs`. On failure it reports the route gates, a comparison of the two caches' K, packed V, rescale and hot V, each observed output against the graph reference (with the max-abs location), the dropped-contribution signatures, and an in-process re-run of every route on both caches. Thresholds are unchanged. - Both steel tests now also call `attention_turbo4_delegated_steel` directly, and still check the wrapper's output, so the pairing that failed keeps its coverage. ## Test plan - [x] CUDA (GB10): new `cache::delegated_parity_diag_tests` (2 tests) pass and run the full report path. The step-0 candidate table above comes from a throwaway test on the same binary. - [x] The two macOS-gated tests compile on Linux with their gate lifted (clippy `-D warnings`, `--lib --tests`). Gate restored before commit. - [ ] Metal: Nightly verify dispatched on this branch, run [38777513435](https://github.com/lablup/mlxcel/actions/runs/38777513435), pending. The steel kernel has not been tested since May, so a red result here is a real finding, not noise. Refs #1712
Refreshes parts of the ROCm documentation that later work made stale. No code change. - `docs/installation.md`, Linux with AMD ROCm: the decode throughput paragraph quoted Qwen3-30B-A3B-4bit at about 55 tok/s (fused MoE off) and gpt-oss-20b-MXFP4-Q4 at about 8 tok/s (generic gather kernel), both from the 2026-09-30 baseline. Current figures are about 62 tok/s with the fused MoE HIP port and 63.62 tok/s with the mxfp4 warp-shared gather kernel (`LOCAL_FIXES.md` item 41), and the paragraph now links both benchmark pages. - Same section, limits table: "Windows, multiple GPUs, distributed inference: Not supported" contradicted the page's own Windows with AMD ROCm section. Windows now links there; multi-GPU and distributed stay unsupported. - Wave64 row: "Not run" while the same row cites a gfx942 run (item 52). Now "Not validated", pointing at #2699. - `tests/rocm_hip_grid_clamp.rs`: a doc comment cited the pre-#2305 `patches-rocm/` path. Historical technical reports, benchmark pages and logit-trace metadata keep the paths and numbers of their time and are not edited. Validation: `make verify-env-var-docs` passes; every number traces to the linked benchmark pages.
Summary
Reorganize
src/lib/mlx-cpp/intosrc/lib/mlxcelverse/so that mlxcel's C++ MLX layer has a clear, self-documenting two-tier boundary between backend source overlays (overlays/{cpu,metal,cuda,rocm}/mlx/...) and mlxcel-owned fused custom kernels (kernels/).Changes
src/lib/mlxcelverse/):src/lib/mlx-cpp/CMakeLists.txttosrc/lib/mlxcelverse/CMakeLists.txtand addedsrc/lib/mlxcelverse/README.md.patches/mlx/backend/cpuintooverlays/cpu/mlx/backend/cpu,patches/mlx/backend/metalintooverlays/metal/mlx/backend/metal,patches/mlx/backend/cuda+patches-cuda/*.cppintooverlays/cuda/mlx/, andpatches-rocmintooverlays/rocm.src/lib/mlx-cpp/turbo/tosrc/lib/mlxcelverse/kernels/.README.mdfiles underoverlays/{cpu,metal,cuda}/explaining each overlay's purpose, mechanics, and base-commit provenance.src/lib/mlxcel-core/):build.rs,Cargo.toml, andbuild_support/mlx_pin.rsto point tosrc/lib/mlxcelverse/(overlays/{cpu,metal,cuda,rocm}andkernels).src/lib/mlxcel-core/cpp/*.{cpp,h}include paths from"../../mlx-cpp/turbo/..."to"../../mlxcelverse/kernels/..."..github/workflows/{ci.yml,release.yml},Makefile,scripts/ci/{mlx_pinned_commit.sh,check_cuda_arch_lists.py,check_kernel_dtype_keys.py,check_kernel_port_dispatch.py},scripts/mlxcelverse/{rocm_overlay.py,sync_from_fork.sh}, andscripts/bench_decode.sh.CONTRIBUTING.md,NOTICE,docs/*,src/lib/mlxcel-mlx-pin/tests/cross_parser.rs,src/lib/mlxcel-core/src/cache/paged_pool_offset_tests.rs, andsrc/execution/memory_estimate_inflight_tests.rs.Verification
mlx_apply_source_overlaysbefore vs. after across Metal/CPU (29 files), CUDA (32 files), and ROCm (153 files).bash scripts/ci/mlx_pinned_commit_test.shandcargo test -p mlxcel-mlx-pin(27/27 passed).make verify-versions verify-kernel-dtype-keys verify-kernel-port-dispatch verify-llama-compat verify-rocm-overlay verify-python-tooling verify-fmt(123/123 Python tooling tests passed).bash scripts/mlxcelverse/rocm_overlay_test.sh(29/29 passed) andpython3 scripts/mlxcelverse/rocm_overlay.py drift --no-fetch.python3 scripts/insert_apache_header.py --checkandpython3 scripts/check_cross_repo_refs.py.scripts/ci/rocm_smoke.shonQwen3-0.6B-4bit,gfx1151):32 tokens in 0.13s = 255.73 tok/s.Closes #1816