skillfed

k-diffusion

Karras et al. (2022) diffusion models for PyTorch

k-diffusion v0.1.1.post1 120.1K downloads/30d#12,043 on PyPI2,600
Permissive license MIT AGING released

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-diffusion

uv

uv add k-diffusion

poetry

poetry add k-diffusion

Installing 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

diffusion model pytorchgenerative model trainingkarras diffusion implementationdpm-solver samplingtransformer diffusion modelsclip guided samplingdiffusion model library
diffusion-modelsgenerative-airesearch

More Artificial Intelligence packages