Skip to main content

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

nunchaku_chroma-0.1.2.tar.gz (32.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nunchaku_chroma-0.1.2-py3-none-any.whl (35.5 kB view details)

Uploaded Python 3

File details

Details for the file nunchaku_chroma-0.1.2.tar.gz.

File metadata

  • Download URL: nunchaku_chroma-0.1.2.tar.gz
  • Upload date:
  • Size: 32.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nunchaku_chroma-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9c9aa4b98e5b9314fb1cffdeaefe66bb4eacee60b6d54ef23d4dd991f921071d
MD5 eea95d85b7713dcbe6abdaac1942f705
BLAKE2b-256 1ceeb0211a1b1a7949d5c94d977fa7f74da2a9183fab65ecf5eb612f3a1d90e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for nunchaku_chroma-0.1.2.tar.gz:

Publisher: publish.yml on spooknik/nunchaku-chroma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nunchaku_chroma-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for nunchaku_chroma-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bf32827d26dc06ac3abc452622df427b6c8475b9d5a4c150452bf4362517c8bf
MD5 4258b4f1a40eb2d8ad0a87a807edf7e9
BLAKE2b-256 84f931fd835a9e8a0ec00fa220ebb01489b9d9a78320e0596d25bc93f337b9bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for nunchaku_chroma-0.1.2-py3-none-any.whl:

Publisher: publish.yml on spooknik/nunchaku-chroma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page