|
| 1 | +# ROCm mlx investigation — are there confirmed issues? |
| 2 | + |
| 3 | +**Date:** 2026-07-19 |
| 4 | +**Repo:** [NripeshN/mlx](https://github.com/NripeshN/mlx) branch **`rocm-support`** |
| 5 | +**Local:** `/home/antmi/mlx` |
| 6 | +**mlx SHA:** `0dadb703d77301af29405cf7e12627efb88a6d0f` |
| 7 | +**Consumer:** lemon-mlx-engine (FetchContent same SHA), model `LemonMLXE/Qwen3.6-35B-A3B-MTP-mlx-4bit`, **gfx1150** |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## Executive verdict |
| 12 | + |
| 13 | +## Upstream draft PR |
| 14 | + |
| 15 | +**Draft PR (docs only):** https://github.com/NripeshN/mlx/pull/13 |
| 16 | +**Head:** `antmikinka/mlx` → https://github.com/antmikinka/mlx-rocm branch `investigate/rocm-dual-load-segv` |
| 17 | +**Base:** `NripeshN/mlx` `rocm-support` |
| 18 | + |
| 19 | +Note: GitHub renames `antmikinka/mlx` → **`antmikinka/mlx-rocm`**. NripeshN/mlx has **issues disabled**; draft PR is the discussion vehicle. |
| 20 | +PR #12 (lemonade-sdk head) was **closed** as wrong head. |
| 21 | + |
| 22 | + |
| 23 | +| Question | Answer | |
| 24 | +|----------|--------| |
| 25 | +| Is there a **confirmed mlx ROCm failure mode** on this machine? | **YES — dual large-model process load → SIGSEGV (exit 139)** | |
| 26 | +| Is there a confirmed **single-process correctness** bug blocking eager decode? | **NO** (exclusive loads pass; engine product path green) | |
| 27 | +| Should we open a **code PR** that “fixes GDN/copy” without more isolation? | **NO** | |
| 28 | +| Should we open a **GitHub issue** (robustness / OOM→SEGV)? | **OPTIONAL / YES if documenting** — frame as dual-process overcommit SEGV, not “copy kernel math wrong” | |
| 29 | +| Must product wait on mlx tip? | **NO** for eager single-process; ops rule: one process | |
| 30 | + |
| 31 | +--- |
| 32 | + |
| 33 | +## Candidate inventory (from engine loops + this pack) |
| 34 | + |
| 35 | +| ID | Symptom | Where stack dies | Confirmed? | Ownership | |
| 36 | +|----|---------|------------------|------------|-----------| |
| 37 | +| **M1** | 2nd process load SIGSEGV after MTP-skip | `hipLaunchKernel` ← mlx `copy_contiguous` / bf16→f32 | **YES** (this pack dual A/B) | mlx ROCm **or** HIP driver OOM path + allocator; **triggered by ops dual-load** | |
| 38 | +| **M2** | Exclusive chat/server load | — | **PASS** 2/2 chat exclusive | — | |
| 39 | +| **M3** | MTP `There is no Stream(cpu, N)` | `mlx/backend/cpu/encoder.cpp` | **Reproduced earlier in engine with `--use-mtp`**; **not re-tested here** (MTP deferred) | mlx stream TLS / engine MTP thread hygiene — **open if MTP productized** | |
| 40 | +| **M4** | Pure-graph / capture desync | rocm `device.cpp` capture/arena | **Not exercised** (eager only) | deferred | |
| 41 | +| **M5** | Engine ChatSession / stop / thinking | — | Engine-owned; fixed elsewhere | **not mlx** | |
| 42 | + |
| 43 | +--- |
| 44 | + |
| 45 | +## Exclusive vs dual-load matrix (this run) |
| 46 | + |
| 47 | +**Harness:** engine binaries linked against this mlx SHA (same `0dadb703`). |
| 48 | +**Env:** `MLX_DECODE_GRAPH_PURE_OFF=1`, no `MLX_LOAD_MTP_HEAD`, no quant fuse. |
| 49 | + |
| 50 | +| Run | Result | Log | |
| 51 | +|-----|--------|-----| |
| 52 | +| exclusive chat #1 | **PASS** Model loaded | `logs/excl-chat-1.log` | |
| 53 | +| exclusive chat #2 | **PASS** Model loaded | `logs/excl-chat-2.log` | |
| 54 | +| server up (holds ~18 GB) | **PASS** health | `logs/dual-server.log` | |
| 55 | +| chat load **while server holds model** | **FAIL_SEGV rc=139** after MTP-skip line | `logs/dual-chat.log` | |
| 56 | + |
| 57 | +**Interpretation:** Failure correlates with **second ~18 GB model** on unified-memory APU (~8.5 GiB VRAM report), not with exclusive first-forward GDN. Stack class matches historical gdb (copy → HIP), but root is **resource overcommit / ungraceful failure**, not proven single-stream kernel logic bug. |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +## Code map (mlx tree) |
| 62 | + |
| 63 | +| Component | Path | |
| 64 | +|-----------|------| |
| 65 | +| Contiguous copy kernels | `mlx/backend/rocm/copy/copy_contiguous.hip` | |
| 66 | +| Copy dispatch | `mlx/backend/rocm/copy.hip` | |
| 67 | +| CPU stream missing | `mlx/backend/cpu/encoder.cpp` (“There is no Stream(cpu, {})…”) | |
| 68 | +| ROCm eval / graph decode | `mlx/backend/rocm/eval.cpp`, `device.cpp` | |
| 69 | + |
| 70 | +Historical engine gdb (not re-run here): |
| 71 | +`Qwen35MoEGatedDeltaNet` → `eval` → `copy_contiguous` → `hipLaunchKernel` in `libamdhip64`. |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## Decision matrix (for maintainers) |
| 76 | + |
| 77 | +| Action | Do it? | Condition | |
| 78 | +|--------|--------|-----------| |
| 79 | +| Document dual-load SEGV in **this repo** | **Yes** | This RESULTS.md | |
| 80 | +| Open **issue** on NripeshN/mlx | **Optional** | Title like: *ROCm gfx1150: SIGSEGV on second concurrent large model load (copy_contiguous / hipLaunchKernel)* — include dual A/B, pins, “exclusive OK” | |
| 81 | +| Open **fix PR** without repro isolation | **No** | No minimal pure-mlx unit repro yet; dual-load is multi-process | |
| 82 | +| Blame product “gibberish” on mlx FA kernels | **No** | Loop6 engine gate: stop/C1/thinking floor pass exclusive | |
| 83 | +| Pursue MTP Stream(cpu) | **Later** | Only when product enables MTP | |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +## Recommended issue body (if filing) |
| 88 | + |
| 89 | +```text |
| 90 | +Title: [ROCm] SIGSEGV (hipLaunchKernel) when loading a second large model while first process holds ~18GB (gfx1150) |
| 91 | +
|
| 92 | +mlx: 0dadb703 (rocm-support) |
| 93 | +GPU: gfx1150 AMD Radeon 890M |
| 94 | +Repro: |
| 95 | + 1) start process A: load Qwen3.6-35B-A3B-MTP-mlx-4bit (lemon-mlx-engine server) |
| 96 | + 2) while A healthy, process B: same model via chat CLI |
| 97 | + 3) B dies exit 139 after device bind / early load (copy_contiguous path) |
| 98 | +Control: exclusive single process loads succeed repeatedly. |
| 99 | +Ask: should allocator/HIP return OOM cleanly instead of SEGV? |
| 100 | +``` |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +## Product / ops (not mlx code) |
| 105 | + |
| 106 | +On this APU: **never** run two full 35B MLX processes. Engine docs (loop6) already state this. |
| 107 | + |
| 108 | +--- |
| 109 | + |
| 110 | +## Supervisors (quintuple) |
| 111 | + |
| 112 | +| Role | Verdict | |
| 113 | +|------|---------| |
| 114 | +| Decode/ROCm | Dual-load SEGV confirmed; exclusive path clean | |
| 115 | +| QA | A/B exclusive vs dual is required evidence | |
| 116 | +| Ownership | M1 = mlx/HIP robustness + ops; M5 = engine; M3 MTP deferred | |
| 117 | +| Product | Unblocked single-process; do not block on mlx PR | |
| 118 | +| Clear Thought | Falsified “exclusive chat always broken”; confirmed dual-load | |
| 119 | + |
| 120 | +*End of investigation pack. Next loop: optional issue draft PR or pure-mlx microbench for OOM handling.* |
| 121 | + |
| 122 | +## CI / lint (PR #13) |
| 123 | + |
| 124 | +CI runs `pre-commit` with **`--all-files`** (see `.github/workflows/build_and_test.yml` → pre-commit/action default). |
| 125 | +The investigation docs alone do not touch C++ sources, but **Check Lint** still formats the whole tree against clang-format v21 / cmake-format. |
| 126 | + |
| 127 | +This branch includes a **lint-only** commit so `Check Lint` is green for maintainer review. No intentional behavior change in ROCm kernels. |
| 128 | + |
| 129 | + |
0 commit comments