feat: Ideogram-4 precision config (config-only, no weights)
Browse files- README.md +95 -0
- precision-config/ideogram4_a4w4.json +16 -0
README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
- zh
|
| 5 |
+
tags:
|
| 6 |
+
- text-to-image
|
| 7 |
+
- quantization
|
| 8 |
+
- quantfunc
|
| 9 |
+
- precision-config
|
| 10 |
+
- ideogram
|
| 11 |
+
license: apache-2.0
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# QuantFunc
|
| 15 |
+
|
| 16 |
+
<div align="center" style="margin-top: 50px;">
|
| 17 |
+
<img src="https://raw.githubusercontent.com/RealJonathanYip/ComfyUI-QuantFunc/main/assets/logo.webp" width="300" alt="Logo">
|
| 18 |
+
</div>
|
| 19 |
+
|
| 20 |
+
<p align="center">
|
| 21 |
+
๐ค <a href="https://huggingface.co/QuantFunc">Hugging Face</a> |
|
| 22 |
+
๐ค <a href="https://www.modelscope.cn/profile/QuantFunc">ModelScope</a> |
|
| 23 |
+
๐ป <a href="https://github.com/RealJonathanYip/ComfyUI-QuantFunc">GitHub</a> |
|
| 24 |
+
๐ฌ <a href="#wechat">WeChat (ๅพฎไฟก)</a> |
|
| 25 |
+
๐ฎ <a href="https://discord.gg/jCp9TpFWcn">Discord</a>
|
| 26 |
+
</p>
|
| 27 |
+
|
| 28 |
+
# Ideogram-4-Series
|
| 29 |
+
|
| 30 |
+
> โ ๏ธ **Config-only repository โ no model weights.**
|
| 31 |
+
> This repo contains **only** a QuantFunc per-layer **precision config** (`precision-config/ideogram4_a4w4.json`).
|
| 32 |
+
> It does **not** contain, mirror, or redistribute any Ideogram model weights. **You bring your own** officially-obtained Ideogram 4 model; this config only tells the QuantFunc engine how to quantize it **at load time, on your own machine**.
|
| 33 |
+
|
| 34 |
+
**Powered by the [QuantFunc ComfyUI plugin](https://github.com/RealJonathanYip/ComfyUI-QuantFunc) โ the fastest diffusion inference engine:**
|
| 35 |
+
|
| 36 |
+
- ๐ **2xโ11x speedup** over standard BF16/FP16 Python pipelines.
|
| 37 |
+
- โ๏ธ **Native C++/CUDA** (`libquantfunc.so` / `quantfunc.dll`), **zero Python model dependencies**.
|
| 38 |
+
- ๐งฉ **Universal format adapter** โ loads **diffusers / BFL (Flux) / HF / nunchaku SVDQ** layouts directly, no manual conversion.
|
| 39 |
+
- ๐ข **Full GPU coverage** โ RTX 20/30/40/50 ยท A100/H100/H200/B100/B200/GB300 ยท RTX 6000 Ada / PRO Blackwell (CUDA 12 & 13); native **FP4** on Blackwell.
|
| 40 |
+
|
| 41 |
+
๐ **Install the plugin:** **https://github.com/RealJonathanYip/ComfyUI-QuantFunc**
|
| 42 |
+
|
| 43 |
+
## What this repository provides
|
| 44 |
+
|
| 45 |
+
A single file โ the precision config, nothing else:
|
| 46 |
+
|
| 47 |
+
```
|
| 48 |
+
Ideogram-4-Series/
|
| 49 |
+
โโโ precision-config/
|
| 50 |
+
โโโ ideogram4_a4w4.json # per-layer precision map for the Lighting backend (W4A4)
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
We deliberately **do not host Ideogram 4 weights**. The QuantFunc **Lighting** backend does **runtime** quantization: you load the *official* weights and they are quantized **in-memory at load**, so no pre-quantized checkpoint is ever distributed.
|
| 54 |
+
|
| 55 |
+
## How to use
|
| 56 |
+
|
| 57 |
+
1. **Obtain the official Ideogram 4 model yourself** in any QuantFunc-supported layout (**diffusers**, BFL/Flux-style, or HF). Follow Ideogram's official distribution channels and license terms.
|
| 58 |
+
2. **Install the QuantFunc ComfyUI plugin:** https://github.com/RealJonathanYip/ComfyUI-QuantFunc
|
| 59 |
+
3. **Load the official model** through the **Build Pipeline** node (universal format adapter).
|
| 60 |
+
4. **Precision config** โ leave the node on **`auto detect`** (it recognizes Ideogram 4 and applies `ideogram4_a4w4.json` automatically), or point it at this file manually. The Lighting engine then runtime-quantizes the transformer to **W4A4** (4-bit heavy GEMMs + 8-bit sensitive projections).
|
| 61 |
+
|
| 62 |
+
## Precision config โ `ideogram4_a4w4.json`
|
| 63 |
+
|
| 64 |
+
Per-layer precision map (mirrors the Klein-style configs). **Measured** on a dual-transformer **24 GB** card (`cuda_overhead` 399 MB) to fit and render a coherent, prompt-matching image โ with sharper detail than FP16-non-block.
|
| 65 |
+
|
| 66 |
+
| Layer group | Precision | Why |
|
| 67 |
+
|---|---|---|
|
| 68 |
+
| `layers.attention.qkv` ยท `layers.attention.o` | **4-bit** (AUTO_4 โ INT4 on SM89, FP4 on SM120) | self-attention projections; large K/N, quant-robust |
|
| 69 |
+
| `layers.feed_forward.w1/w2/w3` | **4-bit** | SwiGLU MLP โ largest matrices, primary memory target |
|
| 70 |
+
| `input_proj` ยท `llm_cond_proj` ยท `t_embedding.mlp_in/out` ยท `adaln_proj` ยท `final_layer.linear` | **8-bit** (AUTO_8 โ FP8 on SM89+, INT8 older; W8A8) | sensitive non-block projection GEMMs |
|
| 71 |
+
| `layers.adaln_modulation` ยท `final_layer.adaln_modulation` | **FP16** | M=1 modulation GEMVs โ per-token activation quant collapses conditioning; engine skips them |
|
| 72 |
+
|
| 73 |
+
**Net:** 170 block GEMMs @ 4-bit ยท 5 non-block projection GEMMs @ AUTO_8 (FP8 on SM89) ยท 2 adaLN-modulation GEMVs @ FP16.
|
| 74 |
+
|
| 75 |
+
Verified coherent on SM89 (INT8 dashboard-run + FP8 CLI-run, each `cuda_overhead` 399 MB). AUTO_8 picks **FP8** on SM89 for better dynamic range on these sensitive projections.
|
| 76 |
+
|
| 77 |
+
## Hardware
|
| 78 |
+
|
| 79 |
+
- NVIDIA **RTX 20-series and above** (CUDA 12 & 13). Native **FP4** on Blackwell (SM120); INT4 on SM89.
|
| 80 |
+
- Fits a **24 GB** card with the a4w4 map (measured `cuda_overhead` 399 MB).
|
| 81 |
+
|
| 82 |
+
## Legal / Attribution
|
| 83 |
+
|
| 84 |
+
- This repository distributes **only** the QuantFunc precision-config JSON โ our own work, Apache-2.0.
|
| 85 |
+
- It contains **no Ideogram weights** and is **not affiliated with, nor endorsed by, Ideogram**.
|
| 86 |
+
- "Ideogram" is a trademark of its respective owner. You are solely responsible for obtaining the official model and complying with its license and terms of use.
|
| 87 |
+
|
| 88 |
+
## Community
|
| 89 |
+
|
| 90 |
+
- ๐ฎ [Discord server](https://discord.gg/jCp9TpFWcn)
|
| 91 |
+
- ๐ฌ Scan the QR code below to join our WeChat group:
|
| 92 |
+
|
| 93 |
+
<div align="center" id="wechat">
|
| 94 |
+
<img src="https://raw.githubusercontent.com/RealJonathanYip/ComfyUI-QuantFunc/main/assets/WeChat.jpg" alt="WeChat Group" width="300">
|
| 95 |
+
</div>
|
precision-config/ideogram4_a4w4.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_comment": "Ideogram-4 per-layer precision map (mirrors klein-style configs/flux2-klein-*.json). Heavy block GEMMs (attention + FFN) are 4-bit (AUTO_4 โ INT4 on SM89, FP4 on SM120); the sensitive non-block PROJECTION GEMMs are 8-bit AUTO_8 ('8' โ FP8 on SM89+, INT8 on older; W8A8) โ MEASURED on the dual-transformer 24GB to fit (cuda_overhead 399 MB) and render a coherent prompt-matching image, with sharper detail than FP16-non-block. Both 8-bit variants verified coherent on SM89 (i8 dashboard-run + f8 CLI-run, each cuda_overhead 399 MB); AUTO_8 picks FP8 on SM89 (native FP8 tensor cores, better dynamic range than INT8 for these sensitive projections). Only the adaln_modulation GEMVs (block + final) stay FP16 (16): they are M=1 GEMVs whose per-token activation quantization is too lossy (conditioning collapse; mirrors ZImage's ZImageBlockPrecision.modulation=FP16 default), and the engine's quantizeWeights deliberately skips them. Keys match the layer-path prefixes used by Ideogram4TransformerLighting::quantizeBlockWeights + Ideogram4Block::quantizeWeights (the numeric block index is skipped by PrecisionMap::matchesPrefix, so 'layers.attention.qkv' matches layers.0..33). Per entry: (1) 'layers.attention.qkv/o' โ self-attention projections, large K/N, quant-robust โ 4; (2) 'layers.feed_forward.w1/w2/w3' โ SwiGLU MLP, largest matrices, primary memory target โ 4; (3) 'layers.adaln_modulation' โ adaLN modulation GEMV (M=1), NOT called by quantizeWeights โ 16; (4) 'input_proj'/(5)'llm_cond_proj'/(6)'t_embedding.*'/(7)'adaln_proj'/(8)'final_layer.linear' โ non-block projection GEMMs โ AUTO_8 ('8': FP8 on SM89+, INT8 older); (9) 'final_layer.adaln_modulation' โ final conditioning GEMV โ 16. Net: 170 block GEMMs at 4-bit, 5 non-block projection GEMMs at AUTO_8 (FP8 on SM89), 2 adaln-modulation GEMVs at FP16.",
|
| 3 |
+
"layers.attention.qkv": 4,
|
| 4 |
+
"layers.attention.o": 4,
|
| 5 |
+
"layers.feed_forward.w1": 4,
|
| 6 |
+
"layers.feed_forward.w2": 4,
|
| 7 |
+
"layers.feed_forward.w3": 4,
|
| 8 |
+
"layers.adaln_modulation": 16,
|
| 9 |
+
"input_proj": 8,
|
| 10 |
+
"llm_cond_proj": 8,
|
| 11 |
+
"t_embedding.mlp_in": 8,
|
| 12 |
+
"t_embedding.mlp_out": 8,
|
| 13 |
+
"adaln_proj": 8,
|
| 14 |
+
"final_layer.linear": 8,
|
| 15 |
+
"final_layer.adaln_modulation": 16
|
| 16 |
+
}
|