unsloth/scripts
Daniel Han b90f833469 Studio diffusion (Phase 9): pre-quantized transformer loading
The Phase 8 fast transformer_quant path materialises the dense bf16 transformer on
the GPU and torchao-quantises it in place, so its load peak is ~2x GGUF's (~21 vs
13.4 GB) plus a ~12 GB download. Add a pre-quantized branch: quantise once offline
(scripts/build_prequant_checkpoint.py) and at runtime build the transformer skeleton
on the meta device (accelerate.init_empty_weights) and load_state_dict(assign=True)
the quantized weights, so the dense bf16 never touches the GPU.

Measured (B200, Z-Image fp8): full-pipeline GPU load peak 21.2 -> 14.6 GB (matching
GGUF's 13.4), on-disk 12 -> 6.28 GB, output bit-identical (LPIPS 0.0). It is the same
torchao config + min_features filter the runtime path uses, applied ahead of time.

New core/inference/diffusion_prequant.py (resolve_prequant_source +
load_prequantized_transformer, best-effort, lazy imports). diffusion.py
_load_dense_quant_pipeline tries the pre-quant source first and falls back to the
dense materialise+quantise path, then to GGUF, so the default is unchanged.
DiffusionLoadRequest gains transformer_prequant_path; DiffusionFamily gains an empty
prequant_repos map for hosted checkpoints (hosting deferred). Hermetic CPU tests for
the resolver, the meta-init+assign loader, and the backend branch selection +
fallbacks; GPU verification via scripts/verify_prequant_backend.py.
2026-06-26 11:23:20 +00:00
..
data CI: scope GITHUB_TOKEN permissions, add MLX CI, unblock ~60 skipped tests (#5312) 2026-05-11 03:19:13 -07:00
build_prequant_checkpoint.py Studio diffusion (Phase 9): pre-quantized transformer loading 2026-06-26 11:23:20 +00:00
check_frontend_dep_removal.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
check_new_install_scripts.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
compare_engines.py Studio diffusion (Phase 7): max tier uses max-autotune-no-cudagraphs + engine/lever benchmarks 2026-06-26 05:04:10 +00:00
compile_probe.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-06-26 03:20:02 +00:00
diffusion_bench.py Studio diffusion (Phase 8): detect consumer vs data-center GPU for fp8 accumulate, with user override 2026-06-26 08:01:15 +00:00
diffusion_quality.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-06-25 13:56:37 +00:00
enforce_kwargs_spacing.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
fp8_overflow_check.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-06-26 07:38:27 +00:00
install_gemma4_mlx.sh Update Install Scripts (#5968) 2026-06-03 05:39:42 -07:00
install_qwen3_6_mlx.sh Update Install Scripts (#5968) 2026-06-03 05:39:42 -07:00
install_rocm_wsl_strixhalo.sh Windows/WSL installer: fix winget msstore cert failure, amd-smi DiskPart prompt, and enable AMD GPU (Strix Halo gfx1151) (#5940) 2026-06-10 04:24:49 -07:00
leverage_probe.py Studio diffusion (Phase 7): max tier uses max-autotune-no-cudagraphs + engine/lever benchmarks 2026-06-26 05:04:10 +00:00
lint_workflow_triggers.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
lockfile_supply_chain_audit.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
notebook_to_python.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
notebook_validator.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
nvfp4_probe.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-06-26 08:24:58 +00:00
nvfp4_t211_probe.py Studio diffusion (Phase 8): prefer fp8 over nvfp4 in Blackwell auto ladder 2026-06-26 08:56:23 +00:00
perf_verify.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-06-26 03:20:02 +00:00
prequant_probe.py Studio diffusion (Phase 9): pre-quantized transformer loading 2026-06-26 11:23:20 +00:00
quant_probe.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-06-26 06:17:18 +00:00
run_ruff_format.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
scan_npm_packages.py Package scanners: close fail-open gaps in the sdist fallback and hidden-payload paths (#6359) 2026-06-18 06:50:16 -07:00
scan_npm_packages_baseline.json Package scanners: close fail-open gaps in the sdist fallback and hidden-payload paths (#6359) 2026-06-18 06:50:16 -07:00
scan_packages.py Package scanners: close fail-open gaps in the sdist fallback and hidden-payload paths (#6359) 2026-06-18 06:50:16 -07:00
scan_packages_baseline.json Studio: remove OpenEnv and other unused packages (#6585) 2026-06-23 07:20:47 -07:00
sd_cpp_smoke.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-06-25 16:08:55 +00:00
sparse_accum_probe.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-06-26 06:48:40 +00:00
stamp_studio_release.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
sync_allow_scripts_pins.py Studio: auto-sync allowScripts pins after dependency bumps (#6136) 2026-06-10 02:35:37 -07:00
uninstall.ps1 Windows installer: fix DiskPart UAC mid-install, drive-root cache, and spurious unsloth.exe rename warning (#6296) 2026-06-22 03:09:08 -07:00
uninstall.sh Windows installer: fix DiskPart UAC mid-install, drive-root cache, and spurious unsloth.exe rename warning (#6296) 2026-06-22 03:09:08 -07:00
verify_comment_only_diff.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
verify_import_hoist.py CI: fix import-hoist false positive, vision-cache test cwd, llama.cpp CLI smoke (#6598) 2026-06-23 01:16:47 -07:00
verify_prequant_backend.py Studio diffusion (Phase 9): pre-quantized transformer loading 2026-06-26 11:23:20 +00:00