Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

diffusion-pipeline-utils

Production utilities for Stable Diffusion and ComfyUI pipelines.

Small, sharp tools extracted from a working VFX pipeline: VRAM-aware batch planning, latent-space helpers, and ComfyUI workflow graph manipulation — the glue code everyone rewrites and nobody publishes.

What's in here

dpu.vram — batch planning that doesn't OOM at frame 4,712

Estimates peak VRAM for a (resolution, batch, dtype, model) combination and picks the largest batch size that fits, with headroom for the VAE decode spike — which is where most "it worked in testing" render jobs actually die.

from dpu.vram import plan_batches

plan = plan_batches(
    width=1024, height=1024, count=5000,
    model="sdxl", dtype="fp16", vram_gb=24,
)
# BatchPlan(batch_size=9, num_batches=556, est_peak_gb=21.0, headroom_gb=3.0)

dpu.latents — latent-space helpers

  • slerp / lerp interpolation between latents (slerp for noise, lerp for decoded-space blends — mixing these up is the classic mistake)
  • seed-stable noise generation independent of batch position
  • latent → preview decode via the tiny TAESD approximator for cheap progress frames

dpu.comfy — ComfyUI workflow surgery

Load an API-format workflow JSON, retarget nodes by class or title, and submit batches programmatically:

from dpu.comfy import Workflow

wf = Workflow.load("workflows/upscale_pass.json")
wf.set_input("KSampler", "seed", 42)
wf.set_input("CheckpointLoaderSimple", "ckpt_name", "sdxl_lightning_8step.safetensors")
for frame in frames:
    wf.set_input("LoadImage", "image", frame)
    wf.queue("http://127.0.0.1:8188")

Install

pip install -e .

Requires Python 3.10+. torch is only needed for the latents module; vram and comfy are dependency-free by design so they can run on the farm scheduler, not just the GPU box.

Design position

Pipeline utilities should be boring. No wrapper classes around diffusers, no config framework, no plugin system. Functions in, dataclasses out, and every estimate annotated with the measurement it came from.

License

MIT

About

Production utilities for Stable Diffusion / ComfyUI — VRAM-aware batch planning, latent-space helpers, workflow graph surgery

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages