Skip to content

[CUDA] gather_mm - #3414

Merged
zcbenz merged 1 commit into
ml-explore:mainfrom
zcbenz:cuda-gather-mm
Apr 17, 2026
Merged

zcbenz merged 1 commit into
ml-explore:mainfrom
zcbenz:cuda-gather-mm

Conversation

@zcbenz

@zcbenz zcbenz commented Apr 15, 2026 •

Copy link
Copy Markdown
Member

Implement gather_mm by fusing CUTLASS GEMM with a custom prologue.

Note that this implementation is completely unoptimized (e.g. no tensor core, no vectorized read) and only performs 0.3x of cuBLAS, we would need to write our own heuristics to dispatch to proper main loops and alignments, which I'm postponing a bit until we have more CUTLASS kernels that I can make a general design.

@zcbenz zcbenz changed the title [CUDA] gather_matmul [CUDA] gather_mm Apr 17, 2026

@angeloskath angeloskath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Should be fairly easy to extend to at least Ampere tensor cores.

@zcbenz
zcbenz merged commit d142de6 into ml-explore:main Apr 17, 2026
16 checks passed
@zcbenz
zcbenz deleted the cuda-gather-mm branch April 17, 2026 07:53
@BrewTestBot BrewTestBot mentioned this pull request Apr 22, 2026
1 task done
ekryski added a commit to ekryski/mlx that referenced this pull request May 6, 2026
…dLocalStream, linalg.det)

Highlights:
- ThreadLocalStream in C++ (ml-explore#3405) — joins StreamOrDevice variant
- Segmented mm NAX kernel (ml-explore#3419) — new steel/gemm/kernels/steel_gemm_segmented{,_nax}
- mlx.core.linalg additions: determinant, sign-log-determinant (ml-explore#3416)
- NAX split-K tuning + addmm fix (ml-explore#3422)
- gather_mm CUDA + qmm CUDA fixes (ml-explore#3414, ml-explore#3417, ml-explore#3445)
- Scheduler::enqueue thread safety (ml-explore#3423)
- Random kernel bytes_per_key truncation fix (ml-explore#3432)
- Many smaller bug + CI fixes; nanobind 2.12.0 pin

Conflict resolution (5 files; all auto-merged cleanly, no manual edits):
- mlx/utils.h — `ThreadLocalStream` joins StreamOrDevice; our
  metal_retain_bound_buffers() helper preserved.
- mlx/backend/metal/device.cpp — upstream's "no Metal device available"
  error message coexists with our signpost/MLX_METAL_PROFILE perf
  diagnostic + hazard-mode retain logic.
- mlx/backend/metal/CMakeLists.txt — upstream's steel_gemm_segmented{,_nax}
  joins our kernel registrations.
- mlx/backend/metal/kernels/CMakeLists.txt — same: upstream segmented +
  our fused_gate_activation kernel.
- tests/scheduler_tests.cpp — upstream's "test thread local stream"
  joins our scheduler-test alignment for lazy command-encoder init.

No disputed conflicts; the auto-merge produced a coherent result with both
sides' work intact.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants