Skip to content

chore(rocm): mlxcelverse ROCm fork sync script, MLX pin-bump procedure, and upstreaming local fixes #1813

Closed

Description

@inureyes

Part of #1801. Phase 3. Depends on #1802 (closed, landed in PR #1818).

Status (2026-09-29, origin/main d8d34e2b)

Context

The ROCm part of mlxcelverse has two moving upstreams:

  1. ml-explore/mlx, which mlxcel bumps regularly. Each bump can change the 15 core overlay files and the APIs the 106 backend files compile against (108 on d8d34e2b: hadamard.hip and fft.hip were added locally; patches-rocm/README.md:9 still says 106). The retarget in epic: AMD GPU (ROCm) backend on Linux via mlxcelverse #1801 needed six fixes after 360 upstream commits (a host-only isnan template hiding device overloads, a changed return tuple, constructor argument changes, a new force_fused parameter, new primitives needing NO_GPU stubs, and Event::error). Because libmlx is static in mlxcel, a missing eval_gpu shows up at link time.
  2. 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.

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

  1. scripts/mlxcelverse/sync_from_fork.sh <fork-commit>: fetch the fork, copy mlx/backend/rocm/ into patches-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. Update patches-rocm/UPSTREAM. Not started. The local fix list now covers LOCAL_FIXES.md items 2 to 18, including two files the fork does not have (hadamard.hip, fft.hip), which the script must carry rather than delete.
  2. scripts/mlxcelverse/check_api_drift.sh: build the ROCm tree at a candidate pin and list undefined mlx::core symbols and compile errors, so a bump PR sees the ROCm breakage immediately. Not started.
  3. Extend the MLX pin-bump procedure in CONTRIBUTING.md (lines 127-153 now CONTRIBUTING.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) and patches-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_GPU stubs and recording fixes in LOCAL_FIXES.md and UPSTREAM. Still missing: running make 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 on origin/main references no report template; the precedent to extend is TECHNICAL_REPORTS/1772-mlx-pin-mxfp8-round-up-20260911.en.md section 3 (lines 61-82).
  4. Keep a patches-rocm/LOCAL_FIXES.md listing 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.
  5. Open PRs against NripeshN/mlx (rocm-support) for the fixes that apply to the fork itself: the E8M0 uint8_t scale 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 (the isnan qualification, API drift) go upstream when the fork itself merges newer MLX. Not started: no PR from this project exists on NripeshN/mlx. The candidate set is now LOCAL_FIXES.md items 8 and 10 to 18 (item 9 only after a root cause), per the inventory above.

Acceptance criteria

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

Activity

  1. added
    status:backlogIn the backlog, not yet ready
    type:choreMaintenance tasks (build, CI, etc.)
    area:coremlxcel-core: MLX FFI, primitives, KV cache, layers
    platform:linuxLinux (CUDA / packaging) specific
    on Sep 11, 2026
  2. changed the title [-]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[/+] on Sep 11, 2026
  3. inureyes commented on Sep 29, 2026

    @inureyes
    MemberAuthor

    Upstreaming candidate from #1874 (PR #2046, merged as 784e35b): patches-rocm/LOCAL_FIXES.md item 19.

    The fork's get_launch_args in mlx/backend/rocm/kernel_utils.hpp clamped 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 at 75915908, 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_gpu in indexing.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.

  4. added and removed
    status:backlogIn the backlog, not yet ready
    on Sep 30, 2026
  5. 13 remaining items

  6. inureyes commented on Sep 30, 2026

    @inureyes
    MemberAuthor

    PR #2078 (merged as 7a28f29) delivered the in-repo part of this issue: scripts/mlxcelverse/ (fork sync, drift check, API drift report), the make verify-rocm-overlay gate in make verify and make verify-rocm, the pin-bump and fork-sync procedure in docs/mlxcelverse/rocm-overlay.md, and eleven prepared upstream packages in docs/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-support and 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, running scripts/mlxcelverse/check_api_drift.sh --rocm-from fork:75915908dfe5028335d318b10340313744fd3a8d end to end, running each reproduction on a fork build, and pre-commit. ml-explore/mlx's AI usage policy (#4331) forbids AI-written PR descriptions, so each pr.md is notes to rewrite rather than text to paste.

  7. added
    status:blockedBlocked by dependencies or other issues
    and removed on Sep 30, 2026
  8. inureyes commented on Oct 6, 2026

    @inureyes
    MemberAuthor

    Policy change (2026-10-06): fixes to the vendored ROCm fork stay in mlxcelverse, and no PRs to NripeshN/mlx rocm-support are prepared or submitted. The remaining acceptance item here (submitting the packages in docs/mlxcelverse/upstream/ and recording the links) is therefore dropped.

    #2144 updates the docs and LOCAL_FIXES.md to match, keeping the packages as historical reference. This issue is closed when #2144 lands.

  9. added and removed
    status:blockedBlocked by dependencies or other issues
    on Oct 7, 2026
  10. added a commit that references this issue on Oct 12, 2026
    b052dd9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:coremlxcel-core: MLX FFI, primitives, KV cache, layersplatform:linuxLinux (CUDA / packaging) specificpriority:mediumMedium prioritystatus:doneCompletedtype:choreMaintenance tasks (build, CI, etc.)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions