Instructions to use batteryphil/FLUX.1-schnell-PRIME-Quant with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use batteryphil/FLUX.1-schnell-PRIME-Quant with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("batteryphil/FLUX.1-schnell-PRIME-Quant", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
FLUX.1-schnell β PRIME-Quant (100% V3_P4_0, Zero CPU Offload)
A 100% 4-bit Prime-Harmonic (V3_P4_0) quantization of FLUX.1-schnell (12B MMDiT + 4.76B T5-XXL, upstream Apache-2.0) built with PRIME-Quant (@batteryphil).
Compresses the entire ~33.7 GB BF16 FLUX.1-schnell text-to-image stack down to 9.37 GB on disk (3.60Γ compression) β running 100% GPU-resident with zero CPU offload (9.49 GB resident VRAM, 11.01 GB peak at 1024Γ1024) on a single 16 GB AMD Radeon RX 9060 XT (ROCm 7.2) or 12β16 GB NVIDIA CUDA GPU.
Verified Benchmark Results (AMD RX 9060 XT 16 GB, ROCm 7.2)
All measurements freshly executed at 1024Γ1024, 4 steps, identical 512px-tiled BF16 AutoencoderKL (benchmarks/flux_schnell_bf16_vs_prime_benchmark.json):
| Metric | BF16 Baseline (Sequential CPU Offload) | PRIME-Quant (100% V3_P4_0, Zero CPU Offload) |
|---|---|---|
| Compressed Weights on Disk | ~33.7 GB |
9.37 GB (2.68 GB T5-XXL + 6.69 GB 12B MMDiT β 3.60Γ smaller) |
| Quantized Linear Coverage | 0 / 671 |
671 / 671 (100%) (169/169 T5-XXL + 502/502 MMDiT) |
| Total GPU-Resident Footprint | Cannot fit on 16 GB | 9,493.5 MB (T5-XXL + 12B DiT + CLIP-L + VAE all resident) |
Peak PyTorch VRAM (1024Γ1024) |
1,589.4 MB (per-layer CPU swap) |
11,005.8 MB (zero CPU offload!) |
Warm Time / 1024Γ1024 Image |
19.92 s (181.38 s cold #1) |
9.24 s (2.16Γ faster) (2.4 s for all 4 MMDiT steps) |
| 6-Prompt Parity (BF16 vs. P4_0) | Reference | 18.94 dB mean PSNR / 0.7097 SSIM (up to 23.88 dB / 0.8678) |
Visual Parity (Left = 33.7 GB BF16 Teacher, Right = 9.37 GB 100% PRIME-Quant V3_P4_0)
Multi-aspect stress tests (768Γ1344 vertical 9:16, 1344Γ768 panoramic 16:9, engraved brass typography 'PRIME QUANT 2026', architectural blueprint 'STAGE 4') all pass cleanly with zero tile seams or drift (benchmarks/stress/).
Quantization Architecture Highlights
- 100%
V3_P4_0Group-32 Prime-Harmonic Codebook: Zero BF16 weights left in eitherT5-XXL(22.54 dBmean weight SNR) or the12BFluxTransformer2DModel(22.53 dBmean block SNR). - Verified Exact Zero-Overhead
H_64/H_128Per-Head Walsh-Hadamard Rotations:T5-XXL: exactH_64onsa.v <-> sa.oacross all 24 blocks + on-the-fly FP32 unpack protection onwo(0extra VRAM).FLUX.1-schnell19 Dual-Stream blocks: exact joint-attentionH_128onto_v/add_v_proj<->to_out.0/to_add_out(verified51.8 / 53.0 dBBF16 rotation invariance).FLUX.1-schnell38 Single-Stream blocks: exactH_128onattn.to_v<->proj_out[:, :3072](verified58.4 / 58.1 dBBF16 rotation invariance).
- Kronecker
PRIMALConditioning Alignment:time_text_embed(timestep + CLIP-L pooled projection):46.12 dBvalidation SNR.- Co-Adapted
context_embedder: aligns all 256 unmasked tokens (active + pad) from 4-bitT5-XXLstraight onto the BF16 Teachercontext_embeddermanifold (5.13 dB -> 10.16 dBall-token /12.80 dBactive-token SNR).
Quickstart (Standalone β Zero Extra Repos Required)
pip install -r requirements.txt
# On AMD RDNA4 (RX 9060 XT / 9070 XT ROCm 7.x), enable experimental AOTriton SDPA:
TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=1 \
python run_flux_schnell_prime.py \
--prompt "Macro studio photograph of a polished brass plaque cleanly engraved with 'PRIME QUANT 2026' on dark walnut wood" \
--width 1024 --height 1024 --steps 4 --seed 101 \
--output prime_plaque.png
run_flux_schnell_prime.pyautomatically downloads only the tiny lightweight config, tokenizers, CLIP-L (246 MB), and VAE (168 MB) fromunsloth/FLUX.1-schnell(ungated Apache-2.0) β it never downloads the33.7 GBBF16 weights.
Licensing & Attribution
- PRIME-Quant checkpoints & standalone runtime (
prime_infer_runtime.py,run_flux_schnell_prime.py): Copyright (c) 2026 Philip Bartsch (@batteryphil), licensed under the Bartsch Personal-Free & 5% Commercial Profit-Share License v1.0 (free for personal, research, academic, and non-profit use). - Upstream Base Model (
FLUX.1-schnell): Apache License 2.0 by Black Forest Labs β see NOTICE.
- Downloads last month
- -
Model tree for batteryphil/FLUX.1-schnell-PRIME-Quant
Base model
black-forest-labs/FLUX.1-schnell
