Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

megakernels

Decode megakernels generated by MegaBake. Each one is a whole decode step, compiled from torch.compile's FX graph into a single persistent CUDA kernel (CuTe DSL).

Results

Model Hardware MegaBake (µs) torch.compile + CUDA graph (µs) Speedup Launches Kernel Measured
HuggingFaceTB/SmolLM-135M NVIDIA H200 MIG 3g.71gb 1,097 2,292 2.09× 842 → 1 decode 2026-10-24
Qwen/Qwen2-0.5B NVIDIA H200 MIG 3g.71gb 1,318 2,368 1.80× 674 → 1 decode 2026-10-24
jukofyork/DeepSeek-V3-DRAFT-0.6B-v3.0 NVIDIA H200 MIG 3g.71gb 1,339 2,354 1.76× 674 → 1 decode 2026-10-24
HuggingFaceTB/SmolLM-1.7B NVIDIA H200 MIG 3g.71gb 2,386 3,099 1.30× 626 → 1 decode 2026-10-24
google/gemma-2b NVIDIA H200 MIG 3g.71gb 3,351 3,697 1.10× 524 → 1 decode 2026-10-24
reflection/Beam-1.0-501B-A23B-DFlash2 NVIDIA H200 MIG 3g.71gb 2,508 2,709 1.08× 157 → 1 decode 2026-10-24

How to read it. Decode, batch 1, bf16, one token per call into a static 128-token KV cache. Each time is the median complete call (host and GPU, CUDA events around the call). Speedup is torch.compile + CUDA graph time ÷ MegaBake time, so values above 1× mean MegaBake is faster. MIG 3g.71gb is a 3/7 slice of one H200.

  • torch.compile + CUDA graph: torch.compile(model, fullgraph=True) with the whole decode step captured into one torch.cuda.CUDAGraph, or Inductor's mode="reduce-overhead" where that was faster.
  • Launches: kernel launches per call, torch.compile + CUDA graph → MegaBake.

Decode speedup by context length

Speedup over torch.compile + CUDA graph as the KV cache fills. Both sides allocate the same KV cache, sized for the longest context, so these runs are not comparable with the 128-token cache in the table above. "—" marks a context where MegaBake was not faster.

Model Hardware KV cache 128 tokens 1,024 tokens 2,048 tokens 4,000 tokens 4,096 tokens 8,000 tokens
HuggingFaceTB/SmolLM-135M NVIDIA H200 MIG 3g.71gb 8,088 3.45× 3.06× — — 1.98× 1.33×
Qwen/Qwen2-0.5B NVIDIA H200 MIG 3g.71gb 8,088 3.39× 2.85× — — 1.83× 1.26×
jukofyork/DeepSeek-V3-DRAFT-0.6B-v3.0 NVIDIA H200 MIG 3g.71gb 8,088 3.32× 2.79× — — 1.78× 1.22×
google/gemma-2b NVIDIA H200 MIG 3g.71gb 8,088 1.83× 1.71× — — 1.29× —
HuggingFaceTB/SmolLM-1.7B NVIDIA H200 MIG 3g.71gb 8,088 1.64× 1.21× — — — —
reflection/Beam-1.0-501B-A23B-DFlash2 NVIDIA H200 MIG 3g.71gb 4,088 1.52× 1.37× 1.25× 1.07× — —

Layout

kernels/<org>--<model>/<gpu>/<mode>/
    module.py          the generated kernel (CuTe DSL Python)
    source_map.json    kernel source → FX node mapping
    report.json        the benchmark it came from
archive/<run>/...      every benchmark run so far: report.json and module.py per mode

The archive holds 51 kernels from 49 benchmark runs. Each published report.json records its source artifact, measurement time and megabake_commit: the newest MegaBake commit at that time. The working tree may have had changes on top of it.

Using a kernel

Kernels import megabake.runtime and MegaBake's CuTe bodies, so they run against the MegaBake revision that generated them (8b94b7c for the table above). To regenerate one on your own GPU:

git clone https://github.com/megabake/megabake && cd megabake
python benchmarks/full_model.py --model Qwen/Qwen2-0.5B --modes decode --out out/

Generated by tools/publish_megakernels.py. Do not edit this README by hand.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages