Skip to content

Commit 4cce5ca

Browse files
committed
docs(megatron-vs-mlx): record 1.8B MLX-CUDA gridDim.y overflow fix + OOM ceiling
The 1.8B local_gb10_quarter backward was blocked on gb10 by a CUDA gridDim.y>65535 overflow in MLX generic/quantized kernels (binary_g, copy_g*, fp_qmv, gemv_gather), not the hypothesized qmm_sm90 shared-memory opt-in. Fixed in MLX 0f54b940d (y/z grid fold + >48KB dynamic-smem opt-in). Backward now launches; full bs=4xseq=4096 step then hits a separate genuine memory-capacity OOM (MLX eager-AD allocator high-water mark for a 1.8B model exceeds the 118 GB box, even with grad checkpointing) - documented memory limitation, not the kernel bug. No 1.8B steady-state tok/s measurable at this config.
1 parent 11b6588 commit 4cce5ca

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

docs/MEGATRON-VS-MLX-PATHS.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,31 @@ Sources: `reports/cppmega_1b_speed_matrix_gb10_fastfused_20260601_b2s512.md`,
148148
> ~65 GiB peak is the MLX-CUDA **allocator high-water mark**, not the live working set (3 GiB); driving it to the
149149
> 30–40 GiB target needs allocator-limit pinning / Relax whole-step liveness (roadmap §4), not more grad-accum.
150150
151+
> **1.8B update (2026-06-02, MLX-CUDA kernel fix, MLX commit `0f54b940d` DatasunriseOU/mlx@upstream-integration):**
152+
> The **1.8B** `local_gb10_quarter` backward (efficient MoE, Adam8bit, bs=4×seq=4096, grad-accum=4) was blocked on
153+
> gb10 by a **kernel-launch** failure — `cudaLaunchKernelExC` / `cudaGraphAddKernelNode … invalid argument` at the
154+
> first microbatch. Root cause (found by resolving the failing kernel pointer to a symbol — `binary_g<Multiply,bf16>`
155+
> with `grid=(1,458640,1)`): a **CUDA `gridDim.y` overflow**. CUDA caps `gridDim.y`/`gridDim.z` at **65535**, but
156+
> MLX-CUDA's generic elementwise/copy kernels (`binary_g`, `copy_g*`) and the quantized matvec/gather kernels
157+
> (`fp_qmv`, `gemv_gather`/`gemv_batched`) map a large *rest*/batch/index count straight onto `gridDim.y`. For the
158+
> 1.8B model's flattened MoE tensors that count reaches **~458 640**, so the launch is rejected. (The earlier
159+
> hypothesis that this was a `qmm_sm90` >48 KB shared-memory opt-in bug was **wrong**`qmm_sm90` is `sm_90`-only and
160+
> never runs on sm_121; the failing kernels use `smem=0`.) **Fix:** split the row-block count across `gridDim.y` and
161+
> `gridDim.z`, reconstructing the row as `blockIdx.y + blockIdx.z*gridDim.y` (identity when `gridDim.z==1`; numerics
162+
> unchanged); plus a central fail-loud `cudaFuncSetAttribute` >48 KB dynamic-smem opt-in at the launch chokepoint for
163+
> the CUTLASS quantized kernels that genuinely need it on sm_121.
164+
>
165+
> **Result:** the 1.8B backward now **launches successfully** on gb10 — the `invalid argument` failure is gone (a
166+
> 1-step diagnostic confirms every kernel grid is within CUDA limits and no launch fails). **However**, the full
167+
> bs=4×seq=4096 step then hits a *separate* genuine **memory-capacity OOM**`cudaMallocAsync … out of memory` at
168+
> the backward `mx.eval`, even with `--grad-checkpoint`. This is the **MLX eager-AD allocator high-water mark**: the
169+
> 542.5M dense model already peaks at ~65 GiB for this config (row above), and the 1.8B model is ~3.4× larger, so its
170+
> eager backward exceeds the 118 GB unified-memory box. This is the documented memory-architecture limitation (roadmap
171+
> §4: allocator-limit pinning / Relax whole-step liveness) — **not** the kernel bug. **No 1.8B steady-state tok/s could
172+
> be measured** because the step cannot complete within the box at this config; the kernel blocker, however, is fixed.
173+
> The apples-to-apples Megatron baseline remains **3399 tok/s @ ~26 GB** (Megatron fits 1.8B-shape via selective
174+
> recompute + distributed optimizer; MLX eager AD does not, yet).
175+
151176
---
152177

153178
## 3. Apples-to-apples normalization

0 commit comments

Comments
 (0)