Chroma model support for Nunchaku - quantized inference for diffusion models
Project description
Nunchaku Chroma
Adds Chroma model support to Nunchaku for fast 4-bit quantized inference.
Installation
Requirements
- Python 3.10+
- PyTorch 2.0+
- CUDA-capable GPU
Install from PyPI
pip install nunchaku nunchaku-chroma
Install from source
pip install nunchaku
git clone https://github.com/spooknik/nunchaku-chroma.git
cd nunchaku-chroma
pip install -e .
Usage
Diffusers API
from diffusers import ChromaPipeline
from nunchaku_chroma import NunchakuChromaTransformer2DModel
import torch
# Load quantized transformer
transformer = NunchakuChromaTransformer2DModel.from_pretrained(
"path/to/quantized-chroma.safetensors",
device="cuda",
torch_dtype=torch.bfloat16,
)
# Create pipeline
pipe = ChromaPipeline.from_pretrained(
"lodestones/Chroma",
transformer=transformer,
torch_dtype=torch.bfloat16,
).to("cuda")
# Generate
image = pipe(
"A beautiful sunset over mountains",
num_inference_steps=20,
guidance_scale=4.0,
).images[0]
image.save("output.png")
LoRA Support
from nunchaku_chroma import NunchakuChromaTransformer2DModel
# Load quantized model
transformer = NunchakuChromaTransformer2DModel.from_pretrained(
"path/to/quantized-chroma.safetensors",
device="cuda",
torch_dtype=torch.bfloat16,
)
# Apply single LoRA with strength
transformer.update_lora_params("path/to/lora.safetensors", strength=0.8)
# Adjust strength dynamically (without reloading)
transformer.set_lora_strength(0.5)
# Reset to base model
transformer.reset_lora()
# Apply multiple LoRAs with different strengths
transformer.update_lora_params_multi([
("lora1.safetensors", 0.8),
("lora2.safetensors", 0.5),
])
ComfyUI
For ComfyUI integration, use the comfyui-nunchaku-chroma custom node:
# Install dependencies
pip install nunchaku nunchaku-chroma
# Install the ComfyUI node
cd ComfyUI/custom_nodes
git clone https://github.com/spooknik/comfyui-nunchaku-chroma.git
# Restart ComfyUI
The following nodes will be available:
- Nunchaku Chroma DiT Loader - Load quantized Chroma models
- Nunchaku Chroma LoRA Loader - Apply a single LoRA
- Nunchaku Chroma LoRA Stack - Apply multiple LoRAs at once
Supported LoRA Formats
- ComfyUI/Kohya format:
lora_unet_double_blocks_*,lora_unet_single_blocks_* - Diffusers format:
transformer_blocks.*.lora_A.weight, etc.
License
Apache-2.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nunchaku_chroma-0.1.1.tar.gz.
File metadata
- Download URL: nunchaku_chroma-0.1.1.tar.gz
- Upload date:
- Size: 31.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ec1a444cdbaf3cc70b8ea217a0c6d9107469c9162678197f9c5e9aac892edf5
|
|
| MD5 |
4e04a1430ad41856f8eac8c85737e869
|
|
| BLAKE2b-256 |
f97eccfc1e5229eaefb08ef012d1bfef832d6a7547474b650504162af5f5e031
|
Provenance
The following attestation bundles were made for nunchaku_chroma-0.1.1.tar.gz:
Publisher:
publish.yml on spooknik/nunchaku-chroma
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nunchaku_chroma-0.1.1.tar.gz -
Subject digest:
8ec1a444cdbaf3cc70b8ea217a0c6d9107469c9162678197f9c5e9aac892edf5 - Sigstore transparency entry: 736821660
- Sigstore integration time:
-
Permalink:
spooknik/nunchaku-chroma@9359a3a3197d2c8225d614ed17dfee37f8135d88 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/spooknik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9359a3a3197d2c8225d614ed17dfee37f8135d88 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file nunchaku_chroma-0.1.1-py3-none-any.whl.
File metadata
- Download URL: nunchaku_chroma-0.1.1-py3-none-any.whl
- Upload date:
- Size: 34.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
727a9039d81198f4aa60ebe8d78ef1b678ba957b4903f031a0f7e868a9beba0b
|
|
| MD5 |
7f78403f08c1164081f1b3009bbe63f8
|
|
| BLAKE2b-256 |
c862efd1ee662911c1caa125942c47b6c4829dff4c2408a29c9f11ef8247062d
|
Provenance
The following attestation bundles were made for nunchaku_chroma-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on spooknik/nunchaku-chroma
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nunchaku_chroma-0.1.1-py3-none-any.whl -
Subject digest:
727a9039d81198f4aa60ebe8d78ef1b678ba957b4903f031a0f7e868a9beba0b - Sigstore transparency entry: 736821662
- Sigstore integration time:
-
Permalink:
spooknik/nunchaku-chroma@9359a3a3197d2c8225d614ed17dfee37f8135d88 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/spooknik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9359a3a3197d2c8225d614ed17dfee37f8135d88 -
Trigger Event:
workflow_dispatch
-
Statement type: