You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(path-c): demote oversized CUDA backward shared scratch to global (fused-CUDA unblock)
The backward direct-chain kernel (row-phased Mamba3 bwd, chain_12_13) staged
4 reverse-scan state buffers (h_prev/h_next/dh/dh_prev, each
num_heads*head_dim*state_dim = 458752 f32) in shared.dyn = 0x764080 (7.39 MB),
overflowing the CUDA 99 KiB / Blackwell ~228 KiB opt-in cap. The existing
_spill_large_shared_scratch_to_abi pass is bounded by the Metal portable
31-buffer limit (consumed by gradient outputs), so the oversized buffers
survived in shared on the direct-chain backward path -> ptxas overflow.
Add a post-spill pass _demote_residual_shared_scratch_to_global: on CUDA it
rewrites residual oversized T.alloc_shared -> T.alloc_global (kernel-internal
cudaMalloc device scratch; no ABI param, no 31-buffer-limit interaction),
largest-first, until residual shared fits a 48 KiB budget (clamped to the
queried MaxSharedMemoryPerBlockOptin). Runs AFTER the ABI-spill so the
ABI-spill-dependent test stays green.
gb10 (sm_121): chain_12_13 residual shared 7,749,760 -> 38,272 bytes (37 KiB);
COMPILE OK, native_compile_ok=true, chain ready, 7 segments, zero ptxas overflow.
Metal: _cuda_shared_memory_optin_cap_bytes() returns None on non-CUDA -> demotion
is a no-op (byte-for-byte identical source verified). Paths B/D/E untouched.
Also set MLX_CUDA_GRAPH_CACHE_SIZE=8192 default (before mlx import) for CUDA
hosts: the Path C step compiles many distinct kernels and MLX's default cache
(400) thrashes/aborts on CUDA. No-op on Metal; setdefault honors explicit env.
0 commit comments