Views
No views yet
diffusers Librarypip install transformers diffusers sentencepiece accelerate1import torch
2from diffusers import ChromaPipeline
3
4pipe = ChromaPipeline.from_pretrained("lodestones/Chroma1-HD", torch_dtype=torch.bfloat16)
5pipe.enable_model_cpu_offload()
6
7prompt = [
8 "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."
9]
10negative_prompt = ["low quality, ugly, unfinished, out of focus, deformed, disfigure, blurry, smudged, restricted palette, flat colors"]
11
12image = pipe(
13 prompt=prompt,
14 negative_prompt=negative_prompt,
15 generator=torch.Generator("cpu").manual_seed(433),
16 num_inference_steps=40,
17 guidance_scale=3.0,
18 num_images_per_prompt=1,
19).images[0]
20image.save("chroma.png")1import torch
2from diffusers import ChromaPipeline
3
4pipe = ChromaPipeline.from_pretrained("lodestones/Chroma1-HD", torch_dtype=torch.float16)
5#pipe.enable_model_cpu_offload()
6
7#######################################################
8import gemlite
9device = 'cuda:0'
10processor = gemlite.helper.A8W8_int8_dynamic
11#processor = gemlite.helper.A8W8_fp8_dynamic
12#processor = gemlite.helper.A16W4_MXFP
13
14for name, module in pipe.transformer.named_modules():
15 module.name = name
16
17def patch_linearlayers(model, fct):
18 for name, layer in model.named_children():
19 if isinstance(layer, torch.nn.Linear):
20 setattr(model, name, fct(layer, name))
21 else:
22 patch_linearlayers(layer, fct)
23
24def patch_linear_to_gemlite(layer, name):
25 layer = layer.to(device, non_blocking=True)
26 try:
27 return processor(device=device).from_linear(layer)
28 except Exception as exception:
29 print('Skipping gemlite conversion for: ' + str(layer.name), exception)
30 return layer
31
32patch_linearlayers(pipe.transformer, patch_linear_to_gemlite)
33torch.cuda.synchronize()
34torch.cuda.empty_cache()
35
36pipe.to(device)
37pipe.transformer.forward = torch.compile(pipe.transformer.forward, fullgraph=True)
38pipe.vae.forward = torch.compile(pipe.vae.forward, fullgraph=True)
39#pipe.set_progress_bar_config(disable=True)
40#######################################################
41
42prompt = [
43 "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."
44]
45negative_prompt = ["low quality, ugly, unfinished, out of focus, deformed, disfigure, blurry, smudged, restricted palette, flat colors"]
46
47import time
48for _ in range(3):
49 t_start = time.time()
50 image = pipe(
51 prompt=prompt,
52 negative_prompt=negative_prompt,
53 generator=torch.Generator("cpu").manual_seed(433),
54 num_inference_steps=40,
55 guidance_scale=3.0,
56 num_images_per_prompt=1,
57 ).images[0]
58 t_end = time.time()
59 print(f"Took: {t_end - t_start} secs.") #66.1242527961731 -> 27.72 sec
60
61image.save("chroma.png")

T5_xxl model in your ComfyUI/models/clip folder.FLUX VAE in your ComfyUI/models/vae folder.Chroma checkpoint in your ComfyUI/models/diffusion_models folder.<pad> tokens.-x^2) to prevent loss spikes and ensure the model trains effectively on both high-noise and low-noise regions.@misc{rock2025chroma,
author = {Lodestone Rock},
title = {Chroma1-HD},
year = {2025},
publisher = {Hugging Face},
journal = {Hugging Face repository},
howpublished = {\url{https://huggingface.co/lodestones/Chroma1-HD}},
}