tonera commited on
Commit
756dcd5
·
verified ·
1 Parent(s): ee3dc2c

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. README.md +53 -155
  2. README_CN.md +81 -0
README.md CHANGED
@@ -1,181 +1,79 @@
1
  ---
2
- license: apache-2.0
3
  pipeline_tag: text-to-image
 
 
 
 
 
 
 
 
 
 
 
4
  ---
5
- # Chroma1-HD
6
 
7
- Chroma1-HD is an **8.9B** parameter text-to-image foundational model based on **FLUX.1-schnell**. It is fully **Apache 2.0 licensed**, ensuring that anyone can use, modify, and build upon it.
8
 
9
- As a **base model**, Chroma1 is intentionally designed to be an excellent starting point for **finetuning**. It provides a strong, neutral foundation for developers, researchers, and artists to create specialized models.
10
 
11
- for the fast CFG "baked" version please go to [Chroma1-Flash](https://huggingface.co/lodestones/Chroma1-Flash).
12
 
13
- ### Key Features
14
- * **High-Performance Base:** 8.9B parameters, built on the powerful FLUX.1 architecture.
15
- * **Easily Finetunable:** Designed as an ideal checkpoint for creating custom, specialized models.
16
- * **Community-Driven & Open-Source:** Fully transparent with an Apache 2.0 license, and training history.
17
- * **Flexible by Design:** Provides a flexible foundation for a wide range of generative tasks.
18
 
19
- ## Special Thanks
20
- A massive thank you to our supporters who make this project possible.
21
- * **Anonymous donor** whose incredible generosity funded the pretraining run and data collections. Your support has been transformative for open-source AI.
22
- * **Fictional.ai** for their fantastic support and for helping push the boundaries of open-source AI. You can try Chroma on their platform:
23
 
24
- [![FictionalChromaBanner_1.png](./images/FictionalChromaBanner_1.png)](https://fictional.ai/?ref=chroma_hf)
25
 
26
- ## How to Use
27
 
28
- ### `diffusers` Library
29
 
30
- install the requirements
31
 
32
- `pip install transformers diffusers sentencepiece accelerate`
33
 
34
- ```python
35
- import torch
36
- from diffusers import ChromaPipeline
37
 
38
- pipe = ChromaPipeline.from_pretrained("lodestones/Chroma1-HD", torch_dtype=torch.bfloat16)
39
- pipe.enable_model_cpu_offload()
40
-
41
- prompt = [
42
- "A high-fashion close-up portrait of a blonde woman in clear sunglasses. The image uses a bold teal and red color split for dramatic lighting. The background is a simple teal-green. The photo is sharp and well-composed, and is designed for viewing with anaglyph 3D glasses for optimal effect. It looks professionally done."
43
- ]
44
- negative_prompt = ["low quality, ugly, unfinished, out of focus, deformed, disfigure, blurry, smudged, restricted palette, flat colors"]
45
-
46
- image = pipe(
47
- prompt=prompt,
48
- negative_prompt=negative_prompt,
49
- generator=torch.Generator("cpu").manual_seed(433),
50
- num_inference_steps=40,
51
- guidance_scale=3.0,
52
- num_images_per_prompt=1,
53
- ).images[0]
54
- image.save("chroma.png")
55
- ```
56
-
57
- Quantized inference using gemlite
58
-
59
- ```py
60
- import torch
61
- from diffusers import ChromaPipeline
62
 
63
- pipe = ChromaPipeline.from_pretrained("lodestones/Chroma1-HD", torch_dtype=torch.float16)
64
- #pipe.enable_model_cpu_offload()
65
-
66
- #######################################################
67
- import gemlite
68
- device = 'cuda:0'
69
- processor = gemlite.helper.A8W8_int8_dynamic
70
- #processor = gemlite.helper.A8W8_fp8_dynamic
71
- #processor = gemlite.helper.A16W4_MXFP
72
-
73
- for name, module in pipe.transformer.named_modules():
74
- module.name = name
75
-
76
- def patch_linearlayers(model, fct):
77
- for name, layer in model.named_children():
78
- if isinstance(layer, torch.nn.Linear):
79
- setattr(model, name, fct(layer, name))
80
- else:
81
- patch_linearlayers(layer, fct)
82
-
83
- def patch_linear_to_gemlite(layer, name):
84
- layer = layer.to(device, non_blocking=True)
85
- try:
86
- return processor(device=device).from_linear(layer)
87
- except Exception as exception:
88
- print('Skipping gemlite conversion for: ' + str(layer.name), exception)
89
- return layer
90
-
91
- patch_linearlayers(pipe.transformer, patch_linear_to_gemlite)
92
- torch.cuda.synchronize()
93
- torch.cuda.empty_cache()
94
-
95
- pipe.to(device)
96
- pipe.transformer.forward = torch.compile(pipe.transformer.forward, fullgraph=True)
97
- pipe.vae.forward = torch.compile(pipe.vae.forward, fullgraph=True)
98
- #pipe.set_progress_bar_config(disable=True)
99
- #######################################################
100
-
101
- prompt = [
102
- "A high-fashion close-up portrait of a blonde woman in clear sunglasses. The image uses a bold teal and red color split for dramatic lighting. The background is a simple teal-green. The photo is sharp and well-composed, and is designed for viewing with anaglyph 3D glasses for optimal effect. It looks professionally done."
103
- ]
104
- negative_prompt = ["low quality, ugly, unfinished, out of focus, deformed, disfigure, blurry, smudged, restricted palette, flat colors"]
105
-
106
- import time
107
- for _ in range(3):
108
- t_start = time.time()
109
- image = pipe(
110
- prompt=prompt,
111
- negative_prompt=negative_prompt,
112
- generator=torch.Generator("cpu").manual_seed(433),
113
- num_inference_steps=40,
114
- guidance_scale=3.0,
115
- num_images_per_prompt=1,
116
- ).images[0]
117
- t_end = time.time()
118
- print(f"Took: {t_end - t_start} secs.") #66.1242527961731 -> 27.72 sec
119
-
120
- image.save("chroma.png")
121
  ```
122
 
123
- ComfyUI
124
- For advanced users and customized workflows, you can use Chroma with ComfyUI.
125
-
126
- **Requirements:**
127
- * A working ComfyUI installation.
128
- * [Chroma checkpoint](https://huggingface.co/lodestones/Chroma) (latest version).
129
- * [T5 XXL Text Encoder](https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp16.safetensors).
130
- * [FLUX VAE](https://huggingface.co/lodestones/Chroma/resolve/main/ae.safetensors).
131
- * [Chroma Workflow JSON](https://huggingface.co/lodestones/Chroma1-HD/resolve/main/ComfyUI_Chroma1-HD_T2I-workflow.json).
132
-
133
- ![Chroma Workflow](./ComfyUI_Chroma1-HD_T2I-sample.png)
134
- ![Workflow Overview](./ComfyUI_Chroma1-HD_T2I-overview.png)
135
-
136
- **Setup:**
137
- 1. Place the `T5_xxl` model in your `ComfyUI/models/clip` folder.
138
- 2. Place the `FLUX VAE` in your `ComfyUI/models/vae` folder.
139
- 3. Place the `Chroma checkpoint` in your `ComfyUI/models/diffusion_models` folder.
140
- 4. Load the Chroma workflow file into ComfyUI and run.
141
-
142
- ## Model Details
143
- * **Architecture:** Based on the 8.9B parameter FLUX.1-schnell model.
144
- * **Training Data:** Trained on a 5M sample dataset curated from a 20M pool, including artistic, photographic, and niche styles.
145
- * **Technical Report:** A comprehensive technical paper detailing the architectural modifications and training process is forthcoming.
146
 
147
- ## Intended Use
148
- Chroma is intended to be used as a **base model** for researchers and developers to build upon. It is ideal for:
149
- * Finetuning on specific styles, concepts, or characters.
150
- * Research into generative model behavior, alignment, and safety.
151
- * As a foundational component in larger AI systems.
152
 
153
- ## Limitations and Bias Statement
154
- Chroma is trained on a broad, filtered dataset from the internet. As such, it may reflect the biases and stereotypes present in its training data. The model is released in a state as is and has not been aligned with a specific safety filter.
 
155
 
156
- Users are responsible for their own use of this model. It has the potential to generate content that may be considered harmful, explicit, or offensive. I encourage developers to implement appropriate safeguards and ethical considerations in their downstream applications.
 
157
 
158
- ## Summary of Architectural Modifications
159
- *(For a full breakdown, tech report soon-ish.)*
160
 
161
- * **12B 8.9B Parameters:**
162
- * **TL;DR:** I replaced a 3.3B parameter timestep-encoding layer with a more efficient 250M parameter FFN, as the original was vastly oversized for its task.
163
- * **MMDiT Masking:**
164
- * **TL;DR:** Masking T5 padding tokens enhanced fidelity and increased training stability by preventing the model from focusing on irrelevant `<pad>` tokens.
165
- * **Custom Timestep Distributions:**
166
- * **TL;DR:** I implemented a custom timestep sampling distribution (`-x^2`) to prevent loss spikes and ensure the model trains effectively on both high-noise and low-noise regions.
167
 
168
- ## P.S
169
- Chroma1-HD is not the old Chroma-v.50 it has been retrained from v.48
 
 
 
 
170
 
171
- ## Citation
 
 
172
  ```
173
- @misc{rock2025chroma,
174
- author = {Lodestone Rock},
175
- title = {Chroma1-HD},
176
- year = {2025},
177
- publisher = {Hugging Face},
178
- journal = {Hugging Face repository},
179
- howpublished = {\url{https://huggingface.co/lodestones/Chroma1-HD}},
180
- }
181
- ```
 
1
  ---
 
2
  pipeline_tag: text-to-image
3
+ library_name: diffusers
4
+ tags:
5
+ - Chroma
6
+ - quantization
7
+ - svdquant
8
+ - nunchaku
9
+ - fp4
10
+ - int4
11
+ base_model: tonera/Chroma1-HD-SVDQ
12
+ base_model_relation: quantized
13
+ license: apache-2.0
14
  ---
 
15
 
16
+ # Model Card (SVDQuant)
17
 
18
+ > **Language**: English | [中文](README_CN.md)
19
 
20
+ ## Model name
21
 
22
+ - **Model repo**: `tonera/Chroma1-HD-SVDQ`
23
+ - **Base (Diffusers weights path)**: `tonera/Chroma1-HD-SVDQ` (repo root)
24
+ - **Quantized Transformer weights**: `tonera/Chroma1-HD-SVDQ/svdq-<precision>_r32-Chroma1-HD.safetensors`
 
 
25
 
26
+ ## Quantization / inference tech
 
 
 
27
 
28
+ - **Inference engine**: Nunchaku (`https://github.com/nunchaku-ai/nunchaku`)
29
 
30
+ Nunchaku is a high-performance inference engine for **4-bit (FP4/INT4) low-bit neural networks**. Its goal is to significantly reduce VRAM usage and improve inference speed while preserving generation quality as much as possible. It implements and productionizes post-training quantization methods such as **SVDQuant**, and uses operator/kernel fusion and other optimizations to reduce the extra overhead introduced by low-rank branches.
31
 
32
+ The Chroma1-HD quantized weights in this repository (e.g. `svdq-*_r32-*.safetensors`) are meant to be used with Nunchaku for efficient inference on supported GPUs.
33
 
34
+ ## You must install Nunchaku before use
35
 
36
+ - **Official installation docs** (recommended source of truth): `https://nunchaku.tech/docs/nunchaku/installation/installation.html`
37
 
38
+ ### (Recommended) Install the official prebuilt wheel
 
 
39
 
40
+ - **Prerequisite**: `PyTorch >= 2.5` (follow the wheel requirements as the source of truth)
41
+ - **Install the nunchaku wheel**: pick the wheel matching your environment from GitHub Releases / HuggingFace / ModelScope (note `cp311` means Python 3.11):
42
+ - `https://github.com/nunchaku-ai/nunchaku/releases`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
+ ```bash
45
+ # Example (choose the correct wheel URL for your torch/cuda/python versions)
46
+ pip install https://github.com/nunchaku-ai/nunchaku/releases/download/vX.Y.Z/nunchaku-X.Y.Z+torch2.9-cp311-cp311-linux_x86_64.whl
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  ```
48
 
49
+ - **Tip (RTX 50 series GPUs)**: usually `CUDA >= 12.8` is recommended, and FP4 models are preferred for better compatibility and performance (follow the official docs).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
+ ## Usage example (Diffusers + Nunchaku Transformer)
 
 
 
 
52
 
53
+ ```python
54
+ import torch
55
+ from diffusers import ChromaPipeline
56
 
57
+ from chroma_transformer import NunchakuChromaTransformer2dModel
58
+ from nunchaku.utils import get_precision
59
 
60
+ MODEL = "Chroma1-HD-SVDQ"
61
+ REPO_ID = f"tonera/{MODEL}"
62
 
63
+ if __name__ == "__main__":
64
+ transformer = NunchakuChromaTransformer2dModel.from_pretrained(
65
+ f"{REPO_ID}/svdq-{get_precision()}_r32-{MODEL}.safetensors"
66
+ )
 
 
67
 
68
+ pipe = ChromaPipeline.from_pretrained(
69
+ f"{REPO_ID}",
70
+ transformer=transformer,
71
+ torch_dtype=torch.bfloat16,
72
+ use_safetensors=True,
73
+ ).to("cuda")
74
 
75
+ prompt = "Make Pikachu hold a sign that says 'Nunchaku is awesome', yarn art style, detailed, vibrant colors"
76
+ image = pipe(prompt=prompt, guidance_scale=2.5, num_inference_steps=40).images[0]
77
+ image.save("Chroma1.png")
78
  ```
79
+
 
 
 
 
 
 
 
 
README_CN.md ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: text-to-image
3
+ library_name: diffusers
4
+ tags:
5
+ - Chroma
6
+ - quantization
7
+ - svdquant
8
+ - nunchaku
9
+ - fp4
10
+ - int4
11
+ base_model: tonera/Chroma1-HD-SVDQ
12
+ base_model_relation: quantized
13
+ license: apache-2.0
14
+ ---
15
+
16
+ # 模型说明(SVDQuant)
17
+
18
+ > **文档语言**:中文|[English](README.md)
19
+
20
+ ## 模型名称
21
+
22
+ - **模型仓库**:`tonera/Chroma1-HD-SVDQ`
23
+ - **Base(Diffusers 权重路径)**:`tonera/Chroma1-HD-SVDQ`(本仓库根目录)
24
+ - **量化 Transformer 权重**:`tonera/Chroma1-HD-SVDQ/svdq-<precision>_r32-Chroma1-HD.safetensors`
25
+
26
+ ## 量化 / 推理技术
27
+
28
+ - **推理引擎**:Nunchaku(`https://github.com/nunchaku-ai/nunchaku`)
29
+
30
+ Nunchaku 是一个面向 **4-bit(FP4/INT4)低比特神经网络**的高性能推理引擎,核心目标是在尽量保持生成质量的同时显著降低显存占用并提升推理速度。它实现并工程化了 **SVDQuant** 等后训练量化方案,并通过算子/内核融合等优化减少低秩分支带来的额外开销。
31
+
32
+ 本模型仓库中的 Chroma1-HD 量化权重(例如 `svdq-*_r32-*.safetensors`)用于配合 Nunchaku,在支持的 GPU 上进行高效推理。
33
+
34
+
35
+ ## 使用前必须安装 Nunchaku
36
+
37
+ - **官方安装文档**(建议以此为准):`https://nunchaku.tech/docs/nunchaku/installation/installation.html`
38
+
39
+ ### (推荐)方式:安装官方预编译 Wheel
40
+
41
+ - **前置条件**:安装 `PyTorch >= 2.5`(实际以对应 wheel 的要求为准)
42
+ - **安装 nunchaku wheel**:从 GitHub Releases / HuggingFace / ModelScope 选择与你环境匹配的 wheel(注意 `cp311` 表示 Python 3.11):
43
+ - `https://github.com/nunchaku-ai/nunchaku/releases`
44
+
45
+ ```bash
46
+ # 示例(请按你的 torch/cuda/python 版本选择正确的 wheel URL)
47
+ pip install https://github.com/nunchaku-ai/nunchaku/releases/download/vX.Y.Z/nunchaku-X.Y.Z+torch2.9-cp311-cp311-linux_x86_64.whl
48
+ ```
49
+
50
+ - **提示(50 系 GPU)**:通常建议 `CUDA >= 12.8`,并优先使用 FP4 模型以获得更好的兼容性与性能(以官方文档为准)。
51
+
52
+ ## 使用示例(Diffusers + Nunchaku Transformer)
53
+
54
+
55
+ ```python
56
+ import torch
57
+ from diffusers import ChromaPipeline
58
+
59
+ from chroma_transformer import NunchakuChromaTransformer2dModel
60
+ from nunchaku.utils import get_precision
61
+
62
+ MODEL = "Chroma1-HD-SVDQ"
63
+ REPO_ID = f"tonera/{MODEL}"
64
+
65
+ if __name__ == "__main__":
66
+ transformer = NunchakuChromaTransformer2dModel.from_pretrained(
67
+ f"{REPO_ID}/svdq-{get_precision()}_r32-{MODEL}.safetensors"
68
+ )
69
+
70
+ pipe = ChromaPipeline.from_pretrained(
71
+ f"{REPO_ID}",
72
+ transformer=transformer,
73
+ torch_dtype=torch.bfloat16,
74
+ use_safetensors=True,
75
+ ).to("cuda")
76
+
77
+ prompt = "Make Pikachu hold a sign that says 'Nunchaku is awesome', yarn art style, detailed, vibrant colors"
78
+ image = pipe(prompt=prompt, guidance_scale=2.5, num_inference_steps=40).images[0]
79
+ image.save("Chroma1.png")
80
+ ```
81
+