mirage  by mirage-project

Tool for fast GPU kernel generation via superoptimization

created 1 year ago
1,637 stars

Top 26.3% on sourcepulse

GitHubView on GitHub
Project Summary

Mirage is a tool that automatically generates highly-optimized GPU kernels for PyTorch programs using superoptimization, targeting researchers and engineers seeking to accelerate deep learning workloads without manual kernel programming. It enables users to describe computations in Python, which Mirage then transforms into fast, custom GPU kernels that can outperform expert-written ones.

How It Works

Mirage employs a multi-level superoptimization approach. It first translates a PyTorch program into an intermediate representation (IR) and then searches a vast space of functionally equivalent GPU kernels. By exploring various optimization strategies and low-level code generation techniques, it discovers kernels that achieve significant speedups, such as fusing operations like RMSNorm and Linear layers for Transformer models.

Quick Start & Requirements

  • Installation: pip install mirage-project or install from pre-built wheels (e.g., pip install https://github.com/mirage-project/mirage/releases/download/v0.2.2/mirage_project-0.2.2+cu122-cp310-cp310-linux_x86_64.whl). Source installation requires git clone --recursive https://www.github.com/mirage-project/mirage and pip install -e . -v.
  • Prerequisites: CUDA (version specified in wheel, e.g., 12.2), Python 3.10+.
  • Resources: Requires GPU for kernel generation and execution.
  • Documentation: Tutorials are available for examples.

Highlighted Details

  • Achieves 1.5–1.7x speedup for fused RMSNorm and Linear operations compared to separate PyTorch operators.
  • Automatically searches for and discovers optimized kernel candidates.
  • Integrates generated kernels into PyTorch programs with minimal code changes.
  • Supports arbitrary PyTorch programs for kernel generation.

Maintenance & Community

  • The project welcomes contributions and bug reports via GitHub issues.
  • A paper detailing Mirage's techniques is available on arXiv.

Licensing & Compatibility

  • Mirage uses the Apache License 2.0.
  • This license is permissive and generally compatible with commercial and closed-source use.

Limitations & Caveats

The project is associated with a 2025 OSDI publication, suggesting it may still be under active development or research. Specific CUDA and Python version compatibility might be tied to pre-built wheels or source compilation requirements.

Health Check
Last commit

1 day ago

Responsiveness

1 day

Pull Requests (30d)
35
Issues (30d)
23
Star History
846 stars in the last 90 days

Explore Similar Projects

Starred by Andrej Karpathy Andrej Karpathy(Founder of Eureka Labs; Formerly at Tesla, OpenAI; Author of CS 231n), Georgios Konstantopoulos Georgios Konstantopoulos(CTO, General Partner at Paradigm), and
7 more.

ThunderKittens by HazyResearch

0.6%
3k
CUDA kernel framework for fast deep learning primitives
created 1 year ago
updated 3 days ago
Feedback? Help us improve.