← ALL TAGS

Tag: diffusion

Engineering

From Python + CUDA to Pure Rust + Metal 4: How zml-flow-rs Stops Us Writing a Kernel Per Model

Every new diffusion model ships as PyTorch with CUDA assumptions baked in, and every port to Apple Silicon has meant hand-writing its kernels again. zml-flow-rs reads only the weights, discovers the semantics from one reference trace, synthesizes its fused kernels from data, and compiles the result into a standalone Rust binary. Two different architectures, zero model-specific code, and a Krea-2 PNG that is bit-identical to the reference.

September 25, 2026 23 min read
Read Story →
Engineering

Porting ERNIE-Image-Turbo to Zig and Metal: An 8B Diffusion Transformer From Scratch on Apple Silicon

I rewrote the hot path of Baidu's 8B-parameter ERNIE-Image-Turbo (DiT + scheduler) from scratch in Zig with hand-written Metal kernels. 13.06s/step at 1024×1024 on M2 Max. The bug archaeology behind getting 36 layers numerically correct, plus the honest accounting of what still has Python in it.

April 23, 2026 18 min read
Read Story →