k-diffusion
Karras et al. (2022) diffusion models for PyTorch
What it is and what it does
k-diffusion is a research-oriented PyTorch library that implements the diffusion model design space from Karras et al. (2022). It provides training and sampling infrastructure for diffusion-based generative models, with particular emphasis on improved sampling algorithms like DPM-Solver and support for transformer-based architectures. The library includes wrappers to use models from other frameworks with its own samplers, plus features like CLIP-guided sampling, FID and KID evaluation during training, and log-likelihood calculation.
The package is designed primarily for research and experimentation rather than production deployment. Installation via PyPI gives you the library code for use as a dependency, while full training and inference scripts require cloning the repository. The 17 runtime dependencies—including torch, torchvision, accelerate, and various image and math libraries—mean this is a heavyweight addition to any environment, intended for GPU-based machine learning workflows.
Use it for:
- Train diffusion models on custom datasets with multi-GPU support via accelerate
- Experiment with transformer-based diffusion architectures as an alternative to convolutional designs
- Sample from diffusion models using DPM-Solver with adaptive step control for quality at low step counts
- Perform CLIP-guided generation from unconditional diffusion models
- Evaluate model quality during training using FID and KID metrics
- Wrap and sample from models trained with other frameworks using k-diffusion's samplers
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
k-diffusion is a PyTorch library implementing diffusion-based generative models from Karras et al. (2022), with improved sampling algorithms, transformer-based model support, and compatibility wrappers for other diffusion frameworks.
Yes, if you are actively researching diffusion models or need a flexible PyTorch-native training framework with advanced sampling algorithms. The aging maintenance status (no releases since 2023-12-07) and substantial dependency footprint make it less suitable for production systems or lightweight prototyping. No known security vulnerabilities. Best suited for GPU-equipped research environments.
Install
k-diffusion on PyPI
pip
pip install k-diffusionuv
uv add k-diffusionpoetry
poetry add k-diffusionInstalling k-diffusion
Before you install
Low install friction with a pure-Python wheel, but 17 runtime dependencies including torch, torchvision, and accelerate create a substantial environment footprint. Maintenance status is aging—last release was 2023-12-07, though the repository remains unarchived.
License in practice
MIT license is permissive, allowing commercial and private use with minimal restrictions beyond attribution.
Quickstart
pip install k-diffusion
import k_diffusion
# For full training/inference scripts, clone the repository and run: pip install -e .
Requires torch and torchvision; GPU strongly recommended for practical use. Full training scripts require repository clone, not available via PyPI install alone.
Verify before relying
- Whether the package's transformer diffusion enhancements are production-ready or experimental
- Current state of latent diffusion support (listed as 'To do' in the description)
- Compatibility with recent PyTorch and torchvision versions given the aging maintenance status
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 17 — accelerate, clean-fid, clip-anytorch, dctorch, einops, jsonmerge, kornia, Pillow, safetensors, scikit-image, scipy, torch, torchdiffeq, torchsde, torchvision, tqdm, wandb |
| Maintenance | aging — 981 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 120,076/month — #12,043 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: k_diffusion-0.1.1.post1-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
diffusersDiffusers provides pretrained diffusion models…
permissive · top 5,000 on PyPI
tomesdSpeeds up Stable Diffusion image generation by…
permissive · top 15,000 on PyPI
lycoris-loraImplements parameter-efficient fine-tuning…
permissive · top 15,000 on PyPI
color-matchercolor-matcher transfers color characteristics…
copyleft · top 15,000 on PyPI
clean-fidComputes Fréchet Inception Distance (FID) and…
permissive · top 15,000 on PyPI
f5-ttsF5-TTS generates natural-sounding speech from…
permissive · top 15,000 on PyPI
pytorchcvProvides a collection of pretrained computer…
unclear · top 15,000 on PyPI
torchsdeSolves stochastic differential equations (SDEs)…
permissive · top 5,000 on PyPI
segmentation-models-pytorchProvides PyTorch-based neural network models…
permissive · top 15,000 on PyPI
open-clip-torchOpenCLIP provides open-source implementations…
permissive · top 5,000 on PyPI