Diffusion Compiler Speeds Up Krea 2 Turbo on Consumer GPUs
An open source C++20 compiler for diffusion models runs Krea 2 Turbo prompt-to-PNG over 2x faster than ComfyUI on an RTX 3090 Ti, with MiniMax H3 in progress.
Krea 2 Turbo, the compiler's first image-model target. Source: Krea 2 open weights
What It Is
Diffusion Compiler takes a model checkpoint through a model-specific frontend into a verified intermediate representation (DiffIR). The compiler then plans execution, and a shared native C++ runtime lowers that plan to the installed hardware backend. The NVIDIA backend uses the CUDA Driver API, NVRTC, cuBLASLt, cuDNN, and custom kernels; the compiled executables do not link libtorch or call a Python worker.
The project positions itself against the usual inference stack in a strict way: every model admission requires numerical gates (cosine similarity, relative L2, nonfinite checks) and inspection of the decoded artifact, not just a successful build. The Krea 2 Turbo denoiser stayed bit-identical to the creator trajectory, and the VAE decode passed at cosine 0.99999339.
Krea 2 Turbo Benchmark
The frozen benchmark uses the official Krea 2 Turbo checkpoint and creator recipe on an RTX 3090 Ti: 1024x1024 output, BF16 math, 8 Euler steps, CFG disabled, and identical checkpoint, prompt, seed, and schedule across both runs.
| Measurement | Native compiled | ComfyUI/PyTorch BF16 |
|---|---|---|
| Cold first denoise step | 3.57 s | 28.29 s |
| Hot denoise step median | 2.25 s | 2.00 s |
| Complete 8-step denoise | 19.36 s | 42.32 s |
| Tokenizer + text encoder | 2.28 s | 9.05 s |
| VAE decode + PNG | 3.43 s | 8.31 s |
| Prompt to PNG, total | 26.58 s | 59.14 s |
That is 2.054x faster for the whole chain, and 2.184x faster on the denoise loop alone. The interesting detail is where the speedup does not come from: the hot per-step time is actually slightly slower than warmed PyTorch (2.25 s vs 2.00 s). The gains come from eliminating warmup overhead, faster text-encoder and VAE stages, and removing Python from the loop entirely. The comparator is standard ComfyUI eager execution, not torch.compile, which the README notes would be a separate matched benchmark.
The framework also supports LoRA training scaffolding through the same DiffIR and runtime, including reverse-mode autodiff, gradient accumulation, AdamW, and checkpoint/resume.
MiniMax H3 In Progress
The first production-scale proving frontend was actually MiniMax H3 video, not Krea 2. The current H3 development checkpoint uses a native ConvRot INT8 projection cache with exact cuDNN attention and runs 1.717x faster per denoiser evaluation than streamed BF16 on the same card. An approximate-attention candidate crossed the 2x timing bar but failed the unchanged-trajectory gate and was rejected. The full prompt-to-video acceptance runs are still open, so no end-to-end H3 speedup is claimed yet.
Per the daily summary discussion, H3 ConvRot INT8 support is the next runtime target, and ComfyUI integration hooks are planned.
Availability
The code is public at github.com/CodeAlexx/diffusion-compiler. It builds with CMake 3.24+, a C++20 compiler, and the CUDA Toolkit plus cuDNN for the NVIDIA backend. Model checkpoints and generated artifacts are not distributed in the repository; the compiler works against locally downloaded weights. Current runtime covers Krea 2 Turbo and the MiniMax H3 development path.
Comments
Sign in with GitHub to join the discussion.