Repository files navigation

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

@misc{mao2026mkernel,
title = {mKernel: Fast Multi-GPU, Multi-Node Fused Kernels},
author = {Mao, Ziming and Raiciu, Costin and Zhou, Yang and Shenker, Scott and Stoica, Ion},
year = {2026},
month = may,
url = {https://uccl-project.github.io/posts/mkernel/},
}

License

MIT — see LICENSE.

About

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

Resources

Stars

270 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Repository files navigation

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

@misc{mao2026mkernel,
title = {mKernel: Fast Multi-GPU, Multi-Node Fused Kernels},
author = {Mao, Ziming and Raiciu, Costin and Zhou, Yang and Shenker, Scott and Stoica, Ion},
year = {2026},
month = may,
url = {https://uccl-project.github.io/posts/mkernel/},
}

License

MIT — see LICENSE.

About

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

Resources

Stars

270 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

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

@misc{mao2026mkernel,
title = {mKernel: Fast Multi-GPU, Multi-Node Fused Kernels},
author = {Mao, Ziming and Raiciu, Costin and Zhou, Yang and Shenker, Scott and Stoica, Ion},
year = {2026},
month = may,
url = {https://uccl-project.github.io/posts/mkernel/},
}

License

MIT — see LICENSE.

About

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

Resources

Stars

270 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

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

@misc{mao2026mkernel,
title = {mKernel: Fast Multi-GPU, Multi-Node Fused Kernels},
author = {Mao, Ziming and Raiciu, Costin and Zhou, Yang and Shenker, Scott and Stoica, Ion},
year = {2026},
month = may,
url = {https://uccl-project.github.io/posts/mkernel/},
}

License

MIT — see LICENSE.

About

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

Resources

Stars

270 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Repository files navigation

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

@misc{mao2026mkernel,
title = {mKernel: Fast Multi-GPU, Multi-Node Fused Kernels},
author = {Mao, Ziming and Raiciu, Costin and Zhou, Yang and Shenker, Scott and Stoica, Ion},
year = {2026},
month = may,
url = {https://uccl-project.github.io/posts/mkernel/},
}

License

MIT — see LICENSE.

About

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

Resources

Stars

270 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

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

@misc{mao2026mkernel,
title = {mKernel: Fast Multi-GPU, Multi-Node Fused Kernels},
author = {Mao, Ziming and Raiciu, Costin and Zhou, Yang and Shenker, Scott and Stoica, Ion},
year = {2026},
month = may,
url = {https://uccl-project.github.io/posts/mkernel/},
}

License

MIT — see LICENSE.

About

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

Resources

Stars

270 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

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

@misc{mao2026mkernel,
title = {mKernel: Fast Multi-GPU, Multi-Node Fused Kernels},
author = {Mao, Ziming and Raiciu, Costin and Zhou, Yang and Shenker, Scott and Stoica, Ion},
year = {2026},
month = may,
url = {https://uccl-project.github.io/posts/mkernel/},
}

License

MIT — see LICENSE.

About

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

Resources

Stars

270 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

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

@misc{mao2026mkernel,
title = {mKernel: Fast Multi-GPU, Multi-Node Fused Kernels},
author = {Mao, Ziming and Raiciu, Costin and Zhou, Yang and Shenker, Scott and Stoica, Ion},
year = {2026},
month = may,
url = {https://uccl-project.github.io/posts/mkernel/},
}

License

MIT — see LICENSE.

About

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

Resources

Stars

270 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages