Diffusion Compiler Speeds Up Krea 2 Turbo on Consumer GPUs

ComfyUI Wikinews

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.

alexone released Diffusion Compiler, an independent C++20 compiler and native runtime for diffusion inference and training. On an RTX 3090 Ti, a compiled Krea 2 Turbo run completes the full prompt-to-PNG chain in 26.58 s versus 59.14 s in ComfyUI/PyTorch, a measured 2.2x speedup with bit-level numerical gates. Source: project README.
Krea 2 sample outputs showcase

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.

MeasurementNative compiledComfyUI/PyTorch BF16
Cold first denoise step3.57 s28.29 s
Hot denoise step median2.25 s2.00 s
Complete 8-step denoise19.36 s42.32 s
Tokenizer + text encoder2.28 s9.05 s
VAE decode + PNG3.43 s8.31 s
Prompt to PNG, total26.58 s59.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.

Loading comments…
Diffusion Compiler Speeds Up Krea 2 Turbo on Consumer GPUs | ComfyUI Wiki