AI/TLDR

Cohere Megakernel

A single-H100 serving engine that runs North Mini Code's whole decode step in one persistent CUDA kernel

GPU Kernels & CompilersOpen source
Latest
Research release
Updated
8 Sep 2026
Language
C++
License
Apache-2.0
Coverage
1 story

What's new

Research release8 Sep 2026

Cohere open-sourced the decode megakernel and its serving engine for North Mini Code: 292 tokens/second at batch size 1 on one H100 (1.58x vLLM v0.24 decode) and 1.25x-1.41x faster end to end across five benchmarks.

Latest news

Overview

Cohere Megakernel is a research release of a single-H100 inference engine that serves Cohere's North Mini Code model behind an OpenAI-compatible API. Its defining idea is the decode megakernel: instead of launching one CUDA kernel per operation (RMSNorm, QKV, attention, MoE, output projection) and paying a full-grid synchronization at every boundary, the engine launches one thread block per streaming multiprocessor and keeps it resident for the entire decode step.

Each resident block walks a host-built task list where every task is a single GEMM tile or a single split of attention, and dependencies are explicit counters in global memory. Work therefore starts the moment its own inputs are ready rather than at a kernel boundary. Cohere reports three concrete wins from that finer schedule: ready mixture-of-experts tiles backfill the SMs left idle by the tail of attention, consumers stop waiting on false whole-grid dependencies, and immutable weights are prefetched from HBM while other work runs.

The project is explicitly an early research release rather than a general-purpose inference engine. Cohere tested it on a single NVIDIA H100 (sm_90a) with CUDA 13 or newer, CPython 3.12 or newer, Linux, and batch sizes up to eight; other configurations are not built or tuned. Within that envelope it is a complete server, with OpenAI-compatible completions and chat-completions endpoints, streaming, tool calling, continuous batching, ragged sequence lengths, a paged KV cache, sliding-window attention, prefix caching and preemption.

What it does

  • One persistent CUDA kernel executes the complete decode forward pass, removing per-op launch overhead and full-grid barriers
  • 292 tokens/second at batch size 1 on an H100 — 62% of theoretical speed-of-light, and 1.58x vLLM v0.24 decode
  • 1.25x-1.41x faster end to end than vLLM across AIME 2025, SciCode, MMLU-Pro (CS), LiveCodeBench v6 and GPQA
  • OpenAI-compatible /v1/completions, /v1/chat/completions and /v1/models endpoints with streaming and tool calling
  • Continuous batching, ragged sequence lengths, paged KV cache, sliding-window attention, prefix caching and preemption
  • Speedup holds out to 256K context at batch size 1, with no measurable accuracy loss versus vLLM

Getting started

You need one NVIDIA H100, CUDA 13+, Python 3.12+, Linux, and a local North Mini Code checkpoint. The repository's BUILD_AND_RUN.md covers detailed install, server flags, benchmarking and profiling.

Clone with submodules

Submodules are required — a plain clone will not build.

bashbash
git clone --recurse-submodules https://github.com/cohere-ai/cohere-megakernel.git
cd cohere-megakernel

Install dependencies

Create a virtual environment, install the Python requirements and FlashAttention-3, plus the OpenSSL dev headers CMake needs.

bashbash
uv venv && source .venv/bin/activate
uv pip install -r requirements.txt
uv pip install flash-attn-3 --index-url https://download.pytorch.org/whl/cu130
sudo apt install -y libssl-dev ninja-build

Build the kernel

Build with the same interpreter you intend to run with — pass it explicitly via -DPython_EXECUTABLE or CMake may pick a system Python.

bashbash
cmake -S . -B build -G Ninja \
  -DPython_EXECUTABLE="$(which python)" -DCMAKE_BUILD_TYPE=Release
cmake --build build

Start the OpenAI-compatible server

Point --ckpt at your local North Mini Code checkpoint and --lib at the library the build produced.

bashbash
python src/serving/server.py \
  --host 127.0.0.1 --port 8000 \
  --lib "$PWD/build/libmk_release.so" \
  --ckpt <checkpoint-path> \
  --device cuda:0 --bs 8 --frac-vram-utilization 0.7

Send a chat completion

The server speaks the OpenAI chat-completions shape, so existing clients work unchanged.

bashbash
curl http://127.0.0.1:8000/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "North-Mini-Code-1.0",
    "messages": [{"role": "user", "content": "Write a Python Fibonacci function."}],
    "max_tokens": 128,
    "temperature": 0
  }'

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Serving North Mini Code on a single H100 at low batch sizes, where per-kernel launch overhead dominates decode time
  • Dropping a faster backend behind an existing OpenAI-compatible client without changing application code
  • Studying a worked, single-file example of a persistent megakernel before writing your own
  • Benchmarking decode-bound mixture-of-experts serving against vLLM on identical hardware

How Cohere Megakernel compares

Cohere Megakernel alongside other open-source gpu kernels & compilers tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
Liger-Kernel★ 6.6kA set of fused Triton kernels for common LLM layers that raises training throughput and lowers memory use as a drop-in replacement.
cuTile Rust★ 777A tile-based GPU kernel DSL for Rust from NVIDIA Labs that extends Rust's ownership model across the launch boundary, so kernels are data-race free by construction.
Cohere MegakernelA single-H100 serving engine that runs North Mini Code's whole decode step in one persistent CUDA kernel