uccl-project/mKernel

mKernel: fast multi-node, multi-GPU fused kernels

Cuda

296

107 commits

updated Oct 17, 2026

See the code

README

mKernel
mKernel: multi-GPU, multi-node fused kernels

Blog | Join Slack | Twitter/X | Roadmap | Quick Start | Open Letter

Highlights

  • Multi-GPU + multi-node, in one kernel. Handling both intra-node and inter-node GPU-driven communication inside the same kernel.
  • Fine-grained intra-kernel overlapping. Compute and communication overlap at tile/chunk granularity.
  • Persistent kernel with SM specialization. CTAs are assigned roles, such as compute / intra-comm / inter-send / inter-reduce.
  • GPU-driven networking, built from scratch. Directly implement communication over Libibverbs (without NCCL/NVSHMEM) for maximal performance.

mKernel is under active development, including optimizing for larger scale, different GPUs, and network topologies. The goal is to have a library for commonly used multi-node/GPU distributed kernels.

Roadmap

  • ✅ Fused, GPU-driven multi-node kernels
  • ✅ Add CX7 and EFA backend
  • 🚧 Full support for heterogeneous accelerators and NICs
    • 🚧 Topology-aware accelerator and NIC discovery, placement, and routing
  • 🚧 Internode megakernels
  • 🚧 Support for Blackwell GPUs

Kernels

KernelWhat it fusesDescription
AllGather + GEMMAllGather → GEMMEach rank holds a shard of the activation A. While ranks gather peers' shards over NVLink/RDMA, the local GEMM consumes tiles as soon as they arrive — overlapping the gather with (A_full @ B) so the matmul starts before the collective finishes.
GEMM + AllReduceGEMM → AllReduceComputes C = A @ B and reduces partial outputs across all 16 ranks in one launch. Output tiles are pushed into the reduction tree the instant they're produced, hiding the AllReduce inside the GEMM tail.
MoE Dispatch + GEMMAll-to-All dispatch → grouped GEMMRoutes MoE tokens to their expert ranks (intra-node NVLink + inter-node all-to-all) and runs the per-expert grouped GEMM in the same kernel. Tokens are matmul'd as soon as they land, no staging buffer round-trip.
MoE Dispatch + FFN + CombineAll-to-All dispatch → grouped FFN → All-to-All combineA full expert-parallel MoE layer in one kernel: routes tokens to their expert ranks, runs the per-expert FFN (gemm1 → SwiGLU → gemm2), then combines the weighted expert outputs back to each token's source rank. Dispatch, both GEMMs, and the combine overlap across intra-node NVLink and inter-node RDMA without leaving the kernel.
Ring AttentionRing KV exchange → FlashAttentionSequence-parallel attention across 16 ranks: each step rotates a KV chunk around the ring while the local FlashAttention consumes the previously-received chunk. Compute and the ring send/recv run concurrently inside a single persistent kernel.
GEMM + ReduceScatterGEMM → ReduceScatterComputes C = A @ B and reduce-scatters the output across ranks. Each output tile is reduced and forwarded to its owning rank as soon as it's produced, so the scatter overlaps the GEMM rather than following it.

Quick start

# Pick BACKEND=efa for AWS EFA, or BACKEND=cx7 for ConnectX-7 / InfiniBand.
make BACKEND=cx7 PYTHON=python3 all

# Two-node benchmark example. Run from node 0; node 1 is launched over SSH.
NODE0_IP=<node0-data-ip> \
NODE1_IP=<node1-data-ip> \
NODE1_SSH=<node1-ssh-target> \
bash bench/run.sh all bench 2

make plots

Requirements

  • NVIDIA Hopper GPUs; the default build targets sm_90a.
  • CUDA 12.9 by default (CUDA_HOME=/usr/local/cuda-12.9), override with CUDA_HOME=....
  • Python with PyTorch installed; pass it to the build with PYTHON=/path/to/python.
  • CX7 backend: libibverbs development headers and libraries.
  • EFA backend: AWS EFA installation with libfabric, libibverbs, efadv, and EFA headers/libraries under EFA_HOME=/opt/amazon/efa by default.
  • Benchmarks assume homogeneous multi-GPU nodes, torchrun, passwordless SSH from node 0 to peer nodes, and routable data-plane IPs in NODE*_IP.

Backends

BackendMacroTransportWhere it runs
CX7-DINTERNODE_BACKEND_IBVERBSlibibverbs RCConnectX-7 / InfiniBand / RoCE
EFA-DINTERNODE_BACKEND_EFAlibibverbs + efadv (SRD)AWS p5/p5e (H200, EFA)

Both backends share the same host-side API and the same on-GPU kernel; only the proxy / session implementation differs (include/comm/internode/session.h for CX7, session_efa.h for EFA).

Comparison results — AWS EFA

KernelPlot
AllGather + GEMMag_gemm
GEMM + AllReducegemm_ar
MoE Dispatch + GEMMdispatch_gemm
MoE Dispatch + FFN + Combinedispatch_gemm_glu_combine
Ring Attentionring_attention
GEMM + ReduceScattergemm_rs

Comparison results — ConnectX-7

KernelPlot
AllGather + GEMMag_gemm_cx7
GEMM + AllReducegemm_ar_cx7
Ring Attentionring_attention_cx7
GEMM + ReduceScattergemm_rs_cx7

Acknowledgements

The MMA code is adapted from ThunderKittens (HazyResearch). Many thanks to the TK authors.

Citation

@article{mao2026mkernel,
  title={mKernel: Fast Multi-GPU, Multi-Node Fused Kernels},
  author={Mao, Ziming and Zhang, Yihan and Chew, Shawn Wei and Ma, Shuang and Raiciu, Costin and Zhou, Yang and Shenker, Scott and Stoica, Ion},
  journal={arXiv preprint arXiv:2609.13585},
  year={2026}
}

License

MIT — see LICENSE.

uccl-project/mKernel

mKernel: fast multi-node, multi-GPU fused kernels

Cuda

296

107 commits

updated Oct 17, 2026

See the code

README

mKernel
mKernel: multi-GPU, multi-node fused kernels

Blog | Join Slack | Twitter/X | Roadmap | Quick Start | Open Letter

Highlights

  • Multi-GPU + multi-node, in one kernel. Handling both intra-node and inter-node GPU-driven communication inside the same kernel.
  • Fine-grained intra-kernel overlapping. Compute and communication overlap at tile/chunk granularity.
  • Persistent kernel with SM specialization. CTAs are assigned roles, such as compute / intra-comm / inter-send / inter-reduce.
  • GPU-driven networking, built from scratch. Directly implement communication over Libibverbs (without NCCL/NVSHMEM) for maximal performance.

mKernel is under active development, including optimizing for larger scale, different GPUs, and network topologies. The goal is to have a library for commonly used multi-node/GPU distributed kernels.

Roadmap

  • ✅ Fused, GPU-driven multi-node kernels
  • ✅ Add CX7 and EFA backend
  • 🚧 Full support for heterogeneous accelerators and NICs
    • 🚧 Topology-aware accelerator and NIC discovery, placement, and routing
  • 🚧 Internode megakernels
  • 🚧 Support for Blackwell GPUs

Kernels

KernelWhat it fusesDescription
AllGather + GEMMAllGather → GEMMEach rank holds a shard of the activation A. While ranks gather peers' shards over NVLink/RDMA, the local GEMM consumes tiles as soon as they arrive — overlapping the gather with (A_full @ B) so the matmul starts before the collective finishes.
GEMM + AllReduceGEMM → AllReduceComputes C = A @ B and reduces partial outputs across all 16 ranks in one launch. Output tiles are pushed into the reduction tree the instant they're produced, hiding the AllReduce inside the GEMM tail.
MoE Dispatch + GEMMAll-to-All dispatch → grouped GEMMRoutes MoE tokens to their expert ranks (intra-node NVLink + inter-node all-to-all) and runs the per-expert grouped GEMM in the same kernel. Tokens are matmul'd as soon as they land, no staging buffer round-trip.
MoE Dispatch + FFN + CombineAll-to-All dispatch → grouped FFN → All-to-All combineA full expert-parallel MoE layer in one kernel: routes tokens to their expert ranks, runs the per-expert FFN (gemm1 → SwiGLU → gemm2), then combines the weighted expert outputs back to each token's source rank. Dispatch, both GEMMs, and the combine overlap across intra-node NVLink and inter-node RDMA without leaving the kernel.
Ring AttentionRing KV exchange → FlashAttentionSequence-parallel attention across 16 ranks: each step rotates a KV chunk around the ring while the local FlashAttention consumes the previously-received chunk. Compute and the ring send/recv run concurrently inside a single persistent kernel.
GEMM + ReduceScatterGEMM → ReduceScatterComputes C = A @ B and reduce-scatters the output across ranks. Each output tile is reduced and forwarded to its owning rank as soon as it's produced, so the scatter overlaps the GEMM rather than following it.

Quick start

# Pick BACKEND=efa for AWS EFA, or BACKEND=cx7 for ConnectX-7 / InfiniBand.
make BACKEND=cx7 PYTHON=python3 all

# Two-node benchmark example. Run from node 0; node 1 is launched over SSH.
NODE0_IP=<node0-data-ip> \
NODE1_IP=<node1-data-ip> \
NODE1_SSH=<node1-ssh-target> \
bash bench/run.sh all bench 2

make plots

Requirements

  • NVIDIA Hopper GPUs; the default build targets sm_90a.
  • CUDA 12.9 by default (CUDA_HOME=/usr/local/cuda-12.9), override with CUDA_HOME=....
  • Python with PyTorch installed; pass it to the build with PYTHON=/path/to/python.
  • CX7 backend: libibverbs development headers and libraries.
  • EFA backend: AWS EFA installation with libfabric, libibverbs, efadv, and EFA headers/libraries under EFA_HOME=/opt/amazon/efa by default.
  • Benchmarks assume homogeneous multi-GPU nodes, torchrun, passwordless SSH from node 0 to peer nodes, and routable data-plane IPs in NODE*_IP.

Backends

BackendMacroTransportWhere it runs
CX7-DINTERNODE_BACKEND_IBVERBSlibibverbs RCConnectX-7 / InfiniBand / RoCE
EFA-DINTERNODE_BACKEND_EFAlibibverbs + efadv (SRD)AWS p5/p5e (H200, EFA)

Both backends share the same host-side API and the same on-GPU kernel; only the proxy / session implementation differs (include/comm/internode/session.h for CX7, session_efa.h for EFA).

Comparison results — AWS EFA

KernelPlot
AllGather + GEMMag_gemm
GEMM + AllReducegemm_ar
MoE Dispatch + GEMMdispatch_gemm
MoE Dispatch + FFN + Combinedispatch_gemm_glu_combine
Ring Attentionring_attention
GEMM + ReduceScattergemm_rs

Comparison results — ConnectX-7

KernelPlot
AllGather + GEMMag_gemm_cx7
GEMM + AllReducegemm_ar_cx7
Ring Attentionring_attention_cx7
GEMM + ReduceScattergemm_rs_cx7

Acknowledgements

The MMA code is adapted from ThunderKittens (HazyResearch). Many thanks to the TK authors.

Citation

@article{mao2026mkernel,
  title={mKernel: Fast Multi-GPU, Multi-Node Fused Kernels},
  author={Mao, Ziming and Zhang, Yihan and Chew, Shawn Wei and Ma, Shuang and Raiciu, Costin and Zhou, Yang and Shenker, Scott and Stoica, Ion},
  journal={arXiv preprint arXiv:2609.13585},
  year={2026}
}

License

MIT — see LICENSE.

Significant stargazers

Kashif Rasul

1,264 followers · starred May 2026

Isotr0py

352 followers · starred May 2026

DefTruth

2,136 followers · starred May 2026

Aaron Pham

541 followers · starred May 2026