Stable Diffusion 3.5: Generation & Upscaling
NF4-quantised SD 3.5 Large on consumer GPUs: 512² generation pushed to crisp 2048² with the X4 upscaler.

What it is
What it does
A practical recipe for running SD 3.5 Large where it nominally doesn't fit: the transformer loads in 4-bit NF4 through bitsandbytes, the heavy T5 encoder uses a pre-quantised NF4 checkpoint, components split across two GPUs with CPU offload bridging the rest, then the SD X4 upscaler takes 512×512 output to 2048×2048.
Why it exists
SD 3.5 Large didn't fit on my card, and naive CPU offloading made it crawl. I kept the parts that affect prompt fidelity at full precision and quantised only the heavy transformer and T5. It fits now, and still looks right.
Repo Amit-kr26/Stable-Diffusion-3-Image-Generation-and-UpscalingStack Stable Diffusion 3.5 · T5 Encoder · diffusers · bitsandbytes · PyTorch
How it is built
Selective NF4 quantisation
SD3Transformer2DModel loads via BitsAndBytesConfig(load_in_4bit, nf4, fp16 compute); the third text encoder swaps for diffusers' pre-quantised t5-nf4 checkpoint.
Multi-GPU placement
Transformer pins to cuda:0, T5 to cuda:1, with enable_model_cpu_offload() chaining the remaining components through available memory.
Allocator tuning
PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True fights fragmentation during long generation sessions.
Two-stage resolution
Generation runs 512×512 at 50 steps / guidance 7.5; StableDiffusionUpscalePipeline (fp16, safetensors) finishes at 2048×2048 in 30 steps.
Artifact pipeline
Each run saves the raw 512² generation and the 2048² upscaled result as separate PNGs, wrapped in an interactive prompt loop for iterating on photorealistic prompts.
How the pieces connect
Drawing is wider than the frame. Drag to pan.
Also filed under ML / DL