Repository navigation
chore(rocm): mlxcelverse ROCm fork sync script, MLX pin-bump procedure, and upstreaming local fixes #1813
Description
Part of #1801. Phase 3. Depends on #1802 (closed, landed in PR #1818).
Status (2026-09-29, origin/main d8d34e2b)
- Exists:
src/lib/mlx-cpp/patches-rocm/UPSTREAMandLOCAL_FIXES.md(PR feat(rocm): vendor the ROCm backend into mlxcelverse, add rocm feature #1818, kept current by every overlay change since), a short pin-bump procedure insrc/lib/mlx-cpp/patches-rocm/README.md:18-24(PR feat(rocm): vendor the ROCm backend into mlxcelverse, add rocm feature #1818) and a ROCm paragraph inCONTRIBUTING.md:150(PR docs(rocm): document the experimental AMD ROCm build and mlxcelverse #1819). - Does not exist:
scripts/mlxcelverse/(neither the sync script nor the drift check), any upstream PR againstNripeshN/mlx, and any upstream link inLOCAL_FIXES.md. Nothing underscripts/,Makefileordocs/automates the fork sync;docs/installation.mdanddocs/architecture.mdonly describe the overlay. - The overlay's recorded source is still
NripeshN/mlx@rocm-supportcommit75915908dfe5028335d318b10340313744fd3a8d, fork merge base39886de4, retargeted to the MLX pin81ba1c6a, which is still the current pin (UPSTREAM;scripts/ci/mlx_pinned_commit.sh).
Context
The ROCm part of mlxcelverse has two moving upstreams:
ml-explore/mlx, which mlxcel bumps regularly. Each bump can change the 15 core overlay files and the APIs the106backend files compile against (108 ond8d34e2b:hadamard.hipandfft.hipwere added locally;patches-rocm/README.md:9still says 106). The retarget in epic: AMD GPU (ROCm) backend on Linux via mlxcelverse #1801 needed six fixes after 360 upstream commits (a host-onlyisnantemplate hiding device overloads, a changed return tuple, constructor argument changes, a newforce_fusedparameter, new primitives needingNO_GPUstubs, andEvent::error). Becauselibmlxis static in mlxcel, a missingeval_gpushows up at link time.NripeshN/mlx@rocm-support, where ROCm kernels improve quickly (dozens of commits in July 2026 alone: WMMA flash attention, MoE, allocator).
Whole-file overlays carry a known review risk: the existing bump check (the overlay's +/- line counts against the new upstream base must equal those against the old base) does not catch an overlay that was already wrong before the bump. A Metal overlay once carried only half of an upstream fix for months until a reviewer compared it line by line.
Local fixes made while vendoring should flow back to the fork so the overlay does not drift from its source.
Inventory: overlay changes since PR #1818
git log origin/main -- src/lib/mlx-cpp/patches-rocm/ shows five commits after the vendoring commit bec64748 (PR #1818). All of them touch only mlx/backend/rocm/ (plus LOCAL_FIXES.md), none of the 15 core files, and each is recorded in LOCAL_FIXES.md as "Applies to the fork; to be proposed there". These, with items 8 to 11 that arrived with PR #1818 itself, are the upstreaming backlog and the fix list the sync script must re-apply.
b3a2226ePR perf(rocm): route f16 gather_qmm to the warp-shared kernel #1822: f16 activations routed to the warp-sharedgather_qmmkernel (quantized/qmm.hip;LOCAL_FIXES.mditem 12).20cf77cePR fix(rocm): stop the tiled qmv path from skipping f32 activations #1823: f32 activations no longer skip every launch in the tiled qmv path (quantized/qmm.hip; item 13).39c597b0PR fix(rocm): make scatter apply every update, check kernel arg sizes #1824:Scatterpassesupd_post_idx_sizeasint64_t, andadd_kernel_nodestatically checks argument sizes (indexing.hip,device.h; item 14).9ead2b7dPR feat(rocm): implement Hadamard and SearchSorted, fix narrow index dtypes #1856:SearchSortedandHadamardimplemented, narrowGather/Scatterindex dtypes widened to int32 (sort.hip, newhadamard.hip,indexing.hip,primitives.cpp,CMakeLists.txt; items 15 to 17; closed fix(rocm): Gather reads narrow index dtypes as int64 and faults the GPU queue #1853).4641dc7aPR feat(rocm): implement FFT through hipFFT #1861:FFTimplemented through hipFFT with an 8-entry plan cache (newfft.hip,primitives.cpp,CMakeLists.txt; item 18). The cap works around a hipFFT hang whose root cause is unknown, tracked in fix(rocm): hipFFT blocks when too many plans are alive, root cause unknown #1876; say so in the upstream proposal.
Items 1 to 7 of LOCAL_FIXES.md are retarget-only and follow the fork when it merges newer MLX.
Scope
Tooling and written procedure so that both kinds of update are routine, plus sending the local fixes upstream.
Implementation plan
scripts/mlxcelverse/sync_from_fork.sh <fork-commit>: fetch the fork, copymlx/backend/rocm/intopatches-rocm/, re-apply the local fix list, and for each of the 15 core files produce the fork's diff against its own merge base so it can be 3-way merged (git merge-file) into the current overlay. Updatepatches-rocm/UPSTREAM. Not started. The local fix list now coversLOCAL_FIXES.mditems 2 to 18, including two files the fork does not have (hadamard.hip,fft.hip), which the script must carry rather than delete.scripts/mlxcelverse/check_api_drift.sh: build the ROCm tree at a candidate pin and list undefinedmlx::coresymbols and compile errors, so a bump PR sees the ROCm breakage immediately. Not started.- Extend the MLX pin-bump procedure in
CONTRIBUTING.md(lines 127-153nowCONTRIBUTING.md:127-150) and the technical report template referenced there with a ROCm section: 3-way merge each core overlay, compare each overlay line by line with upstream (not only line counts), re-run the ROCm op checks and the smoke from ci(rocm): self-hosted gfx1151 runner that builds, links and smoke-tests ROCm changes #1811, and record the drift fixes in the PR body. Partly done:CONTRIBUTING.md:150(PR docs(rocm): document the experimental AMD ROCm build and mlxcelverse #1819) andpatches-rocm/README.md:18-22(PR feat(rocm): vendor the ROCm backend into mlxcelverse, add rocm feature #1818) cover the 3-way merge, the line-by-line comparison, the ROCm build and link,NO_GPUstubs and recording fixes inLOCAL_FIXES.mdandUPSTREAM. Still missing: runningmake verify-rocm(which includes the ci(rocm): self-hosted gfx1151 runner that builds, links and smoke-tests ROCm changes #1811 smoke,Makefile:804), recording drift fixes in the PR body, and the report section. The pin-bump section onorigin/mainreferences no report template; the precedent to extend isTECHNICAL_REPORTS/1772-mlx-pin-mxfp8-round-up-20260911.en.mdsection 3 (lines 61-82). - Keep a
patches-rocm/LOCAL_FIXES.mdlisting every change relative to the fork commit, with the reason and an upstream link once sent. Done for the listing (PR feat(rocm): vendor the ROCm backend into mlxcelverse, add rocm feature #1818, 18 items as of PR feat(rocm): implement FFT through hipFFT #1861); no upstream links yet because nothing has been sent. - Open PRs against
NripeshN/mlx(rocm-support) for the fixes that apply to the fork itself: the E8M0uint8_tscale dispatch for mxfp4/mxfp8 qmv, and any kernel fixes from fix(rocm): surface ROCm GPU failures through Event::error instead of NaN or hangs #1804 and fix(rocm/quant): mxfp4 qmm hang and GPU quantize launch failure, with an affine 4-bit fallback #1808. Retarget-only fixes (theisnanqualification, API drift) go upstream when the fork itself merges newer MLX. Not started: no PR from this project exists onNripeshN/mlx. The candidate set is nowLOCAL_FIXES.mditems 8 and 10 to 18 (item 9 only after a root cause), per the inventory above.
Acceptance criteria
- Running the sync script against the current fork commit reproduces the committed
patches-rocm/byte for byte. - The drift check lists the six known breaks when run against the fork's original merge base plus current upstream.
-
CONTRIBUTING.mddocuments the ROCm part of a pin bump. (CONTRIBUTING.md:150, PR docs(rocm): document the experimental AMD ROCm build and mlxcelverse #1819, pointing topatches-rocm/README.md:18-22; themake verify-rocmstep and PR-body record from plan item 3 are still to add.) -
LOCAL_FIXES.mdexists; the scale-dispatch fix is proposed upstream with a link recorded. (The file exists, PR feat(rocm): vendor the ROCm backend into mlxcelverse, add rocm feature #1818; the upstream proposal and link do not.)
References
CONTRIBUTING.md:127-150,TECHNICAL_REPORTS/1772-mlx-pin-mxfp8-round-up-20260911.en.md(lines 61-82)src/lib/mlx-cpp/patches-rocm/UPSTREAM,src/lib/mlx-cpp/patches-rocm/LOCAL_FIXES.md,src/lib/mlx-cpp/patches-rocm/README.md- Fork: https://github.com/NripeshN/mlx/tree/rocm-support
Refresh log
2026-09-29
- Recorded what exists:
UPSTREAM(fork commit75915908, pin81ba1c6a),LOCAL_FIXES.mdand the overlay README procedure from PR feat(rocm): vendor the ROCm backend into mlxcelverse, add rocm feature #1818, and theCONTRIBUTING.md:150paragraph from PR docs(rocm): document the experimental AMD ROCm build and mlxcelverse #1819; checked off theCONTRIBUTING.mdcriterion and marked plan items 3 and 4 partly or fully done. - Recorded what does not: no
scripts/mlxcelverse/sync or drift script, no upstream PR, no upstream link. - Added the inventory of the five overlay commits since PR feat(rocm): vendor the ROCm backend into mlxcelverse, add rocm feature #1818 (PRs perf(rocm): route f16 gather_qmm to the warp-shared kernel #1822, fix(rocm): stop the tiled qmv path from skipping f32 activations #1823, fix(rocm): make scatter apply every update, check kernel arg sizes #1824, feat(rocm): implement Hadamard and SearchSorted, fix narrow index dtypes #1856, feat(rocm): implement FFT through hipFFT #1861), all backend-only, which enlarges both the sync script's fix list and the upstreaming set.
- Corrected
CONTRIBUTING.md:127-153to:127-150, the report section to lines 61-82, and the backend file count (108, not 106); noted that the pin-bump section references no report template.
Activity
[-]chore(rocm): xcelverse fork sync script, MLX pin-bump procedure, and upstreaming local fixes[/-][+]chore(rocm): mlxcelverse ROCm fork sync script, MLX pin-bump procedure, and upstreaming local fixes[/+]fix(rocm): remove get_launch_args, which capped the grid silently (#2046
inureyes commentedon Sep 29, 2026
Upstreaming candidate from #1874 (PR #2046, merged as 784e35b):
patches-rocm/LOCAL_FIXES.mditem 19.The fork's
get_launch_argsinmlx/backend/rocm/kernel_utils.hppclamped the x grid dimension at 65535 blocks while the kernels it would launch are not grid-stride, so any caller would silently skip the tail of its work. It had no callers in the overlay or in the fork at75915908, so PR #2046 replaced both overloads with a deleted template that fails to compile with an explanation. Upstream MLX CUDA's helper of the same name does not clamp x, which is why a kernel ported from CUDA would have compiled against the fork's version and been truncated.This defect is fork-side (NripeshN/mlx
rocm-support), not upstream MLX, so it belongs in the list of fixes to propose to the fork. A related live call site with the same clamp-without-grid-stride shape,SliceUpdate::eval_gpuinindexing.hip, is tracked in #2050 and will be a second candidate once fixed.Per the maintainer's direction, upstream PRs to the fork are prepared under this issue but submitted manually, not by automation.
fix(rocm): make slice_update_op_kernel grid-stride (#2053)
fix(rocm): validate MLX_ROCM_FFT_CACHE_SIZE (0 is UB, junk throws) (#…
fix(rocm): stop SliceUpdate donating a still-referenced source (#2070)
fix(build/rocm): rebuild HIP objects when an included header changes (#…
13 remaining items
update(rocm): add mlxcelverse sync, drift checks and fork PR packages (…
inureyes commentedon Sep 30, 2026
PR #2078 (merged as 7a28f29) delivered the in-repo part of this issue:
scripts/mlxcelverse/(fork sync, drift check, API drift report), themake verify-rocm-overlaygate inmake verifyandmake verify-rocm, the pin-bump and fork-sync procedure indocs/mlxcelverse/rocm-overlay.md, and eleven prepared upstream packages indocs/mlxcelverse/upstream/covering LOCAL_FIXES items 8, 10 to 14 and 16 to 27.This issue stays open, marked blocked, for the one remaining acceptance item: proposing the fixes to NripeshN/mlx
rocm-supportand recording the links. By the maintainer's decision those PRs are submitted by hand, not by automation. Before submitting, the index lists steps that could not run here: building the packages against the fork, runningscripts/mlxcelverse/check_api_drift.sh --rocm-from fork:75915908dfe5028335d318b10340313744fd3a8dend to end, running each reproduction on a fork build, andpre-commit. ml-explore/mlx's AI usage policy (#4331) forbids AI-written PR descriptions, so eachpr.mdis notes to rewrite rather than text to paste.fix(rocm): bound in-flight batch memory and enforce the cache limit (#…
fix(rocm): pass custom-kernel input shapes and strides by value
update(rocm): port the Gumbel-max and rejection samplers to HIP (#2100)
update(rocm): port the float32-state Mamba1 scan kernel to HIP
update(rocm): port the float32-state Mamba1 scan kernel to HIP
fix(rocm): fix and enable the expert-batched gather_qmm prefill kernel (
inureyes commentedon Oct 6, 2026
Policy change (2026-10-06): fixes to the vendored ROCm fork stay in mlxcelverse, and no PRs to NripeshN/mlx
rocm-supportare prepared or submitted. The remaining acceptance item here (submitting the packages indocs/mlxcelverse/upstream/and recording the links) is therefore dropped.#2144 updates the docs and
LOCAL_FIXES.mdto match, keeping the packages as historical reference. This issue is closed when #2144 lands.chore(rocm): retire the NripeshN/mlx fork-PR plan in the docs (lablup…