CoolFace
Modelpublic

ApacheOne/OBS-Diff-SDXL-creaprompthyper1.2

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes
Model Card

<div align="center">

OBS-Diff SDXL — CreaPrompt Hyper 1.2

Full-shape sparse SDXL UNets pruned with OBS-Diff at 20%, 30%, 40%, and 50%

Base checkpoint: CreaPrompt Hyper SDXL 1.2 Inference: 4 steps · CFG 0.0 · DPM++ SDE normal · 1024×1024 Format: Diffusers UNet2DConditionModel components

</div>

[!IMPORTANT] These are complete loadable SDXL UNet components, not complete text-to-image pipelines. You still need the original checkpoint's two text encoders, tokenizers, VAE, and scheduler.
[!NOTE] OBS-Diff applied unstructured pruning. The selected weights are stored as exact zeros, but the tensor shapes and parameter count remain unchanged. The folders are therefore approximately the same extracted size and do not automatically run faster with ordinary dense CUDA kernels.

Overview

This repository contains four independently pruned versions of the CreaPrompt Hyper SDXL 1.2 UNet:

VariantTargeted-weight sparsityWhole-UNet zerosMean ImageRewardDelta vs. denseWins vs. denseMean generation time
Dense reference0.0000%0.0001%+0.771080+0.0000001.9656 s
OBS 20%20.0004%17.0132%+0.758518-0.0125632/41.9399 s
OBS 30%30.0004%25.5196%+0.731054-0.0400262/41.9611 s
OBS 40%40.0004%34.0260%+0.687856-0.0832253/41.9567 s
OBS 50%50.0004%42.5324%+0.380332-0.3907481/41.9403 s

<div align="center">

Preliminary interpretation

VariantPractical reading
20%Best overall fidelity/quality tradeoff in this small evaluation
30%Moderate quality decline with stronger output changes
40%More aggressive; won 3/4 individual comparisons but had a lower overall mean
50%Experimental; substantial quality instability and one severe failure

</div>

The evaluation contains only four prompts, so these results are a screening benchmark, not a universal quality guarantee.


Repository structure

text
obs_diff_sdxl_results/
├── images/
│   ├── dense/
│   ├── sparsity_20/
│   ├── sparsity_30/
│   ├── sparsity_40/
│   └── sparsity_50/
├── unets/
│   ├── sparsity_20/
│   ├── sparsity_30/
│   ├── sparsity_40/
│   └── sparsity_50/
├── obs_sdxl_compare.html
├── obs_sdxl_compare.json
├── obs_sdxl_compare_scored.html
├── obs_sdxl_compare_scored.json
├── obs_diff_sdxl_prune.log
└── obs_diff_sdxl_imagereward.log

Each unets/sparsity_* directory is a complete Diffusers UNet component produced with save_pretrained().


Visual comparisons

Adult bear standing in a field

DenseOBS 20%OBS 30%OBS 40%OBS 50%
IR +1.138650IR +1.165112IR +1.243169IR +1.197060IR +1.149614
[image][image][image][image][image]

Odd-looking toilet against a wall

DenseOBS 20%OBS 30%OBS 40%OBS 50%
IR +0.776347IR +0.756794IR +0.515587IR +0.180844IR -0.667451
[image][image][image][image][image]

Bathroom with a tub and counter

DenseOBS 20%OBS 30%OBS 40%OBS 50%
IR +0.458368IR +0.508567IR +0.511803IR +0.560043IR +0.362720
[image][image][image][image][image]

Large plane flying in the sky

DenseOBS 20%OBS 30%OBS 40%OBS 50%
IR +0.710957IR +0.603597IR +0.653658IR +0.813476IR +0.676448
[image][image][image][image][image]

Loading a pruned UNet

The saved folders can be loaded independently as UNet2DConditionModel components.

python
import torch
from diffusers import UNet2DConditionModel

REPO_ID = "ApacheOne/OBS-Diff-SDXL-creaprompthyper1.2"

unet = UNet2DConditionModel.from_pretrained(
    REPO_ID,
    subfolder="obs_diff_sdxl_results/unets/sparsity_20",
    torch_dtype=torch.float16,
)

unet.eval()
print(type(unet).__name__)
print(f"Parameters: {sum(p.numel() for p in unet.parameters()):,}")

Available subfolders:

text
obs_diff_sdxl_results/unets/sparsity_20
obs_diff_sdxl_results/unets/sparsity_30
obs_diff_sdxl_results/unets/sparsity_40
obs_diff_sdxl_results/unets/sparsity_50

Text-to-image usage

These repositories contain the UNet only. Load the original complete CreaPrompt Hyper SDXL 1.2 checkpoint for the remaining SDXL components, then replace its UNet.

python
import torch
from diffusers import (
    DPMSolverSinglestepScheduler,
    StableDiffusionXLPipeline,
    UNet2DConditionModel,
)

REPO_ID = "ApacheOne/OBS-Diff-SDXL-creaprompthyper1.2"

# Local copy of the original complete single-file checkpoint.
BASE_CHECKPOINT = (
    "/content/models/hyper_sdxl_4step_471056.safetensors"
)

# Change to sparsity_20, sparsity_30, sparsity_40, or sparsity_50.
SPARSITY = "sparsity_20"

unet = UNet2DConditionModel.from_pretrained(
    REPO_ID,
    subfolder=f"obs_diff_sdxl_results/unets/{SPARSITY}",
    torch_dtype=torch.float16,
)

pipe = StableDiffusionXLPipeline.from_single_file(
    BASE_CHECKPOINT,
    unet=unet,
    torch_dtype=torch.float16,
    use_safetensors=True,
)

pipe.scheduler = DPMSolverSinglestepScheduler.from_config(
    pipe.scheduler.config,
    algorithm_type="sde-dpmsolver++",
    solver_order=2,
    solver_type="midpoint",
    lower_order_final=True,
    use_karras_sigmas=False,
    use_exponential_sigmas=False,
    use_beta_sigmas=False,
    final_sigmas_type="zero",
)

pipe.vae.enable_slicing()
pipe.vae.enable_tiling()
pipe.to("cuda")

generator = torch.Generator("cuda").manual_seed(1234)

image = pipe(
    prompt=(
        "a cinematic photograph of a red fox standing in snow, "
        "detailed fur, natural lighting"
    ),
    width=1024,
    height=1024,
    num_inference_steps=4,
    guidance_scale=0.0,
    generator=generator,
).images[0]

image.save("obs_diff_sdxl_test.png")

Technical details

Pruning method

OBS-Diff uses second-order information to select and compensate pruned weights. This adaptation calibrated the SDXL UNet using its four-step denoising trajectory and independently exported four sparsity targets.

text
Method:              OBS-Diff / second-order unstructured pruning
Checkpoint format:   Complete single-file SDXL checkpoint
UNet parameters:     2,567,463,684
Targeted parameters: 2,183,987,200
Calibration prompts: 16
Calibration size:    512×512
Comparison size:     1024×1024
Scheduler:           DPM++ SDE normal
Inference steps:     4
Guidance scale:      0.0
OBS damping:         0.01
Column block:        128
Maximum tokens:      128
Evaluation seeds:    1234–1237
Quality metric:      ImageReward

What “20–50%” means

The percentage names refer to sparsity among the targeted attention and feed-forward weights, not the percentage of the complete UNet file physically deleted.

VariantTargeted zerosWhole-UNet zeros
OBS 20%20.0004%17.0132%
OBS 30%30.0004%25.5196%
OBS 40%40.0004%34.0260%
OBS 50%50.0004%42.5324%

Why the files are not smaller

The pruning is unstructured:

text
Original dense tensor shape → same tensor shape
Selected FP16 values        → replaced by exact zero
Parameter count             → unchanged

An FP16 zero still occupies two bytes in a normal dense SafeTensors tensor. Therefore:

  • all four UNets have approximately the same extracted size;
  • normal dense CUDA kernels still execute the same matrix dimensions;
  • standard inference does not receive a proportional speedup;
  • specialized sparse storage and sparse kernels would be needed to convert the zero pattern into storage or runtime gains.

Benchmark notes

The comparison used only four prompts. Individual outputs can improve even when the aggregate mean declines:

  • OBS 40% achieved the best ImageReward on the bathroom and plane examples.
  • OBS 30% achieved the best ImageReward on the bear example.
  • OBS 50% produced a major failure on the toilet example.
  • OBS 20% stayed closest to the dense aggregate result.

Use the provided HTML and JSON reports for the full per-image metrics:

text
obs_diff_sdxl_results/obs_sdxl_compare_scored.html
obs_diff_sdxl_results/obs_sdxl_compare_scored.json

Limitations

  • These are UNet components, not complete SDXL pipelines.
  • The original text encoders, tokenizers, VAE, and scheduler are not included.
  • The original CreaPrompt Hyper SDXL 1.2 checkpoint is required for matching T2I behavior.
  • Sparsity is unstructured and does not physically shrink dense tensor dimensions.
  • No retraining or recovery fine-tuning was performed.
  • The benchmark is small and should not be treated as a general quality ranking.
  • Results may change with prompt, seed, resolution, sampler, scheduler, and inference step count.
  • The models were evaluated specifically at four steps and CFG 0.0.

Credits

  • OBS-Diff: pruning method and reference implementation
  • Diffusers: SDXL pipeline and UNet serialization
  • ImageReward: prompt-image quality evaluation
  • CreaPrompt Hyper SDXL 1.2: source checkpoint used for this experiment

<div align="center">

Recommended starting point: sparsity_20

It produced the smallest aggregate ImageReward decline in this initial comparison while retaining approximately 17.01% whole-UNet zeros.

</div>