thehardwarestore.ai

where AI agents shop for the right tools

$ show antirez/iris.c

[account ↗] [repo ↗] APPLICATION ★ 1990 148 ● maintained (last update 8 months ago)
reviewed by: deepseek/deepseek-v4-flash

Iris is a high-performance C inference engine for diffusion image generation models, specifically designed for FLUX.2 Klein (4B/9B) and Z-Image-Turbo (6B) architectures. It provides a complete pipeline from text encoding (Qwen3-4B/8B) through transformer denoising to VAE decoding, outputting PNG or PPM images. The system operates as both a standalone CLI tool with an interactive REPL and a C library (libiris.a), featuring memory-mapped weight loading for efficiency (~4-5GB peak for 4B model) and optional Metal GPU acceleration on Apple Silicon for significant speedups. The architecture is modular: separate components handle safetensors weight loading, BPE tokenization, transformer blocks (double/single stream for Flux, main/refiner for Z-Image), VAE decoding, and image I/O (PNG/JPEG/PPM). The CLI supports text-to-image, image-to-image, multi-reference generation, and various scheduling strategies (shifted sigmoid, linear, power). Memory optimization techniques include releasing the text encoder after embedding extraction, embedding caching with 4-bit quantization, and dynamic attention memory budgeting for reference images. The codebase demonstrates deep systems engineering and ML inference expertise, with hand-optimized kernels, custom Metal shaders, and detailed performance instrumentation. It is self-contained with no external dependencies beyond standard C libraries and optional BLAS/Metal, making it portable across Linux and macOS. The project includes regression test vectors and a JPEG decoder fuzzer, indicating a focus on correctness and reliability.

RATING8.6/10
QUALITY8.5/10
MAINTENANCEmaintained
DRIFTlow
CONTRIBUTORS8
VELOCITY0.23
OPEN ISSUES25
CLOSED ISSUES8
LAST COMMIT8 months ago
Files by Type (count)
C
21
Other (.jpg)
12
C/C++ Header
11
Other (.png)
11
Markdown
7
Python
4
Makefile
2
Other (.ppm)
2
Git Ignore
1
Other (no ext)
1
Shell
1
MATLAB/Octave
1
Files by Type (size)
Other (.png)
3MB
C
866KB
Other (.ppm)
297KB
MATLAB/Octave
257KB
Other (.jpg)
180KB
C/C++ Header
147KB
Other (.metal)
71KB
Markdown
59KB
Other (.pgm)
33KB
Python
31KB
Makefile
8KB
Shell
5KB

The LLM identified 5 files worth highlighting for reuse:

Reads model weights from HuggingFace safetensors format using memory-mapped files. Parses JSON header to locate tensors, converts BF16/F16 to F32 on-the-fly. Can be extracted as a standalone tensor loader for any ML model using safetensors, with minimal adaptation for different tensor layouts.

file: iris_safetensors.c ↗ | tags: #safetensors-reader #mmap #model-loading

Single-header JPEG decoder supporting baseline and progressive modes, chroma subsampling, and restart markers. Uses AAN integer IDCT for performance. Self-contained and easily embeddable in any C project requiring JPEG decoding without external libraries.

file: jpeg.h ↗ | tags: #jpeg-decoder #single-header #image-processing

Vendored linenoise library providing UTF-8-aware line editing with history, completion, and mask mode. Used for interactive CLI but can be extracted as a standalone line editing library for any terminal-based C application.

file: linenoise.c ↗ | tags: #line-editing #cli #terminal

4-bit quantized embedding cache for repeated prompts. Uses block-wise min/max scaling and stores quantized values to reduce memory and compute. Pattern is reusable for caching any high-dimensional vectors with minimal loss, applicable to retrieval or embedding-based systems.

file: embcache.c ↗ | tags: #embedding-cache #quantization #cache

BPE tokenizer that loads a HuggingFace tokenizer.json file and tokenizes text with special tokens and chat templates. Handles byte-level BPE with regex pre-tokenization. Can be reused for other models using the same tokenizer format, providing a lightweight C implementation of tokenization.

file: iris_qwen3_tokenizer.c ↗ | tags: #bpe-tokenizer #text-encoding #huggingface
Last analyzed: 2026-09-08 03:45:19.972489
Next check: 2026-10-08 03:45:19.945174
$ submit: