Text-to-Image
Diffusers
English
stable-diffusion-3
flow-matching
inference-time-alignment
preference-optimization
pg-map
ug-fm
neurips-2026
Instructions to use sophialan/pg-map-sd3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use sophialan/pg-map-sd3 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("sophialan/pg-map-sd3", 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
- Draw Things
- DiffusionBee
| """sophialan/pg-map-sd3 — PG-MAP custom pipeline for Stable Diffusion 3.5-medium. | |
| Loaded by the HuggingFace community-pipeline registry:: | |
| from diffusers import DiffusionPipeline | |
| pipe = DiffusionPipeline.from_pretrained( | |
| "stabilityai/stable-diffusion-3.5-medium", | |
| custom_pipeline="sophialan/pg-map-sd3", | |
| torch_dtype=torch.float16, | |
| ).to("cuda") | |
| This file is a thin re-export shim. Install the ``pg-map`` PyPI package | |
| first:: | |
| pip install pg-map | |
| Defaults to **UG-FM** (the paper's 91.9 % PickScore / 75.7 % HPS row on | |
| PartiPrompts $n{=}1632$): data-side gate, K_UG=4, eta_z=0.1, full | |
| backprop through the velocity prediction. To run the more expensive | |
| full PG-MAP-FM (joint c + z_t with flow consistency + Gaussian priors | |
| + reward), pass ``pg_map_config`` with ``optimize_c=True``:: | |
| from pgmap import sdxl_defaults | |
| from pgmap_config import PGMAPConfig | |
| from dataclasses import replace | |
| cfg = sdxl_defaults() # use as starting point | |
| cfg = replace(cfg, optimize_c=True, optimize_z=True) | |
| # ... cfg.refinement.K, cfg.refinement.eta_c, etc. as desired | |
| image = pipe("a phoenix rising from ashes", pg_map_config=cfg).images[0] | |
| Note: SD3.5-medium requires acceptance of the Stability AI Community | |
| License on huggingface.co before first load. | |
| Citation:: | |
| @inproceedings{sun2026pgmap, | |
| title={PG-MAP: Joint MAP Optimization for Inference-Time Alignment | |
| of Diffusion and Flow-Matching Models}, | |
| author={Sun, Ruolan and Polak, Pawel}, | |
| booktitle={NeurIPS}, | |
| year={2026}, | |
| } | |
| """ | |
| from __future__ import annotations | |
| try: | |
| from pgmap.pipelines.sd3 import PGMAPStableDiffusion3Pipeline | |
| except ImportError as e: | |
| raise ImportError( | |
| "Custom pipeline `sophialan/pg-map-sd3` requires the `pg-map` " | |
| "package.\n" | |
| " Install from PyPI: pip install pg-map\n" | |
| " Install from source: pip install git+https://github.com/sophialanlan/PG-MAP\n" | |
| "Repo: https://github.com/sophialanlan/PG-MAP" | |
| ) from e | |
| __all__ = ["PGMAPStableDiffusion3Pipeline"] | |