Skip to main content

Comfy Kitchen

Fast kernel library for Diffusion inference with multiple compute backends.

Backend Capabilities Matrix

Function eager cuda triton
quantize_per_tensor_fp8
dequantize_per_tensor_fp8
quantize_nvfp4
dequantize_nvfp4
scaled_mm_nvfp4
quantize_mxfp8
dequantize_mxfp8
scaled_mm_mxfp8
apply_rope
apply_rope1

Quantized Tensors

The library provides QuantizedTensor, a torch.Tensor subclass that transparently intercepts PyTorch operations and dispatches them to optimized quantized kernels when available.

Layout Format HW Requirement Description
TensorCoreFP8Layout FP8 E4M3 SM ≥ 8.9 (Ada) Per-tensor scaling, 1:1 element mapping
TensorCoreNVFP4Layout NVFP4 E2M1 SM ≥ 10.0 (Blackwell) Block quantization with 16-element blocks
TensorCoreMXFP8Layout MXFP8 E4M3 SM ≥ 10.0 (Blackwell) Block quantization with 32-element blocks, E8M0 scales
from comfy_kitchen.tensor import QuantizedTensor, TensorCoreFP8Layout, TensorCoreNVFP4Layout

# Quantize a tensor
x = torch.randn(128, 256, device="cuda", dtype=torch.bfloat16)
qt = QuantizedTensor.from_float(x, TensorCoreFP8Layout)

# Operations dispatch to optimized kernels automatically
output = torch.nn.functional.linear(qt, weight_qt)

# Dequantize back to float
dq = qt.dequantize()

Installation

From PyPI

# Install default (Linux/Windows/MacOS)
pip install comfy-kitchen

# Install with CUBLAS for NVFP4 (+Blackwell)
pip install comfy-kitchen[cublas]

Package Variants

  • CUDA wheels: Linux x86_64 and Windows x64
  • Pure Python wheel: Any platform, eager and triton backends only

Wheels are built for Python 3.10, 3.11, and 3.12+ (using Stable ABI for 3.12+).

From Source

# Standard installation with CUDA support
pip install .

# Development installation
pip install -e ".[dev]"

# For faster rebuilds during development (skip build isolation)
pip install -e . --no-build-isolation -v

Build Options

These options require using setup.py directly (not pip install):

Option Command Description Default
--no-cuda python setup.py bdist_wheel --no-cuda Build CPU-only wheel (py3-none-any) Enabled (build with CUDA)
--cuda-archs=... python setup.py build_ext --cuda-archs="80;89" CUDA architectures to build for 75-virtual;80;89;90a;100f;120f (Linux), 75-virtual;80;89;120f (Windows)
--debug-build python setup.py build_ext --debug-build Build in debug mode with symbols Disabled (Release)
--lineinfo python setup.py build_ext --lineinfo Enable NVCC line info for profiling Disabled
# Build CPU-only wheel (pure Python, no CUDA required)
python setup.py bdist_wheel --no-cuda

# Build with custom CUDA architectures
python setup.py build_ext --cuda-archs="80;89" bdist_wheel

# Debug build with line info for profiling
python setup.py build_ext --debug-build --lineinfo bdist_wheel

Requirements

  • Python: ≥3.10
  • PyTorch: ≥2.5.0
  • CUDA Runtime (for CUDA wheels): ≥13.0
    • Pre-built wheels require NVIDIA Driver r580+
    • Building from source requires CUDA Toolkit ≥12.8 and CUDA_HOME environment variable
  • nanobind: ≥2.0.0 (for building from source)
  • CMake: ≥3.18 (for building from source)

Quick Start

import comfy_kitchen as ck
import torch

# Automatic backend selection (triton -> cuda -> eager)
x = torch.randn(100, 100, device="cuda")
scale = torch.tensor([1.0], device="cuda")
result = ck.quantize_per_tensor_fp8(x, scale)

# Check which backends are available
print(ck.list_backends())

# Force a specific backend
result = ck.quantize_per_tensor_fp8(x, scale, backend="eager")

# Temporarily use a different backend
with ck.use_backend("triton"):
    result = ck.quantize_per_tensor_fp8(x, scale)

Backend System

The library supports multiple backends:

  • eager: Pure PyTorch implementation
  • cuda: Custom CUDA C kernels (CUDA only)
  • triton: Triton JIT-compiled kernels

Automatic Backend Selection

When you call a function, the registry selects the best backend by checking constraints in priority order (cudatritoneager):

# Backend is selected automatically based on input constraints
result = ck.quantize_per_tensor_fp8(x, scale)

# On CPU tensors → falls back to eager (only backend supporting CPU)
# On CUDA tensors → uses cuda or triton (higher priority)

Constraint System

Each backend declares constraints for its functions:

Constraint Description
Device Which device types are supported
Dtype Allowed input/output dtypes per parameter
Shape Shape requirements (e.g., 2D tensors, dimensions divisible by 16)
Compute Capability Minimum GPU architecture (e.g., SM 8.0 for FP8, SM 10.0 for NVFP4)

The registry validates inputs against these constraints before calling the backend—no try/except fallback patterns. If no backend can handle the inputs, a NoCapableBackendError is raised with details.

# Debug logging to see backend selection
import logging
logging.getLogger("comfy_kitchen.dispatch").setLevel(logging.DEBUG)

Testing

Run the test suite with pytest:

# Run all tests
pytest

# Run specific test file
pytest tests/test_backends.py

# Run with verbose output
pytest -v

# Run specific test
pytest tests/test_backends.py::TestBackendSystem::test_list_backends

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

comfy_kitchen-0.2.22-py3-none-any.whl (119.7 kB view details)

Uploaded Python 3

comfy_kitchen-0.2.22-cp312-abi3-win_amd64.whl (20.0 MB view details)

Uploaded CPython 3.12+Windows x86-64

comfy_kitchen-0.2.22-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (29.4 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

comfy_kitchen-0.2.22-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (29.4 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

comfy_kitchen-0.2.22-cp311-cp311-win_amd64.whl (20.0 MB view details)

Uploaded CPython 3.11Windows x86-64

comfy_kitchen-0.2.22-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (29.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

comfy_kitchen-0.2.22-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (29.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

comfy_kitchen-0.2.22-cp310-cp310-win_amd64.whl (20.0 MB view details)

Uploaded CPython 3.10Windows x86-64

comfy_kitchen-0.2.22-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (29.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

comfy_kitchen-0.2.22-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (29.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

File details

Details for the file comfy_kitchen-0.2.22-py3-none-any.whl.

File metadata

  • Download URL: comfy_kitchen-0.2.22-py3-none-any.whl
  • Upload date:
  • Size: 119.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for comfy_kitchen-0.2.22-py3-none-any.whl
Algorithm Hash digest
SHA256 d04f1476e609a1aeb3af8b5fe6212beb5741ba71e0263c85d1c990f6b3fc7abf
MD5 e57fb2f80581e0ff08e01e5bf168e283
BLAKE2b-256 d99ed3da7d0aa4fc1efdba2689577bdaf92f4ad7e03f393ecdf37f5ab9ed909d

See more details on using hashes here.

File details

Details for the file comfy_kitchen-0.2.22-cp312-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for comfy_kitchen-0.2.22-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c88669303a9ed2a14f436d5f8297fce79a0cdf6ad55eb398995c2320b82cd120
MD5 d6e3633a3cb65e06e1eaaf2df11b04dd
BLAKE2b-256 4bb72a2ab472607f12f639f3af83783ae69564d7540f32ffacda0b7b3c9b716e

See more details on using hashes here.

File details

Details for the file comfy_kitchen-0.2.22-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for comfy_kitchen-0.2.22-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 276272da8d29dc758b44e35e3c78ce175ece50aa6426633c0b6b68a5ea1e82b8
MD5 0883d129738894235c192dcf980514d2
BLAKE2b-256 79df234ec19cb8c74352c1e66317305f4e6161e316c845144515523ee1bcfad7

See more details on using hashes here.

File details

Details for the file comfy_kitchen-0.2.22-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for comfy_kitchen-0.2.22-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f5aa0c0570e0730b2807f750e8b7c1cd9fdef232a6effb946cc51edbd988b7a8
MD5 369bce7dd36e28be68a5ef05f0d173fb
BLAKE2b-256 f390293214ad9d5cd2ff33dd7d2d005e8cae8ba6051b6b24329abc23bb4ac427

See more details on using hashes here.

File details

Details for the file comfy_kitchen-0.2.22-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for comfy_kitchen-0.2.22-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b2a5dbea4d966c9850a02085a27ca7d304d7c3fc323c5dcedb056c707d7653a4
MD5 11b3abbf372b560a362b00c0d6696064
BLAKE2b-256 a7cdca3b0a459e5759dbae754b2f4c9afe4d3eaf3e1ae8c41d19750741017a03

See more details on using hashes here.

File details

Details for the file comfy_kitchen-0.2.22-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for comfy_kitchen-0.2.22-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a8823011787bae5b3772d355d117c69deb693f16cda0ee80a5d3735ce731e7eb
MD5 a87e3dac0c31f50f9843bf54d1b93537
BLAKE2b-256 6e2c45098361533ab91f3de8b151edb9c41f28cd5fa401d3bc295ac26aa65e6a

See more details on using hashes here.

File details

Details for the file comfy_kitchen-0.2.22-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for comfy_kitchen-0.2.22-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9972afcf5cdb033b3c54d6a27f24927376830b10dc833fca987632d8cd4be8d7
MD5 4fdee0c3dc3b3f6c980c7a1c88af798f
BLAKE2b-256 bf0609045274d5b92190c82b22a0eb85787cb4fa213e1a7dfb8161f0f5827906

See more details on using hashes here.

File details

Details for the file comfy_kitchen-0.2.22-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for comfy_kitchen-0.2.22-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8554cd59e4bf3040f750d20cba4f80b9688ed3a7ed0ca0897e13eb220275dbfc
MD5 7509d738881b2f0bb88634846e41ec5b
BLAKE2b-256 46c2e3b3f9ceedfc9b311ed3a559dc22007f84a99b83ed01707540dd9b864fd1

See more details on using hashes here.

File details

Details for the file comfy_kitchen-0.2.22-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for comfy_kitchen-0.2.22-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 579b192458c599f68846d330769adf507481079275437aa53ef6675e879b962b
MD5 5387485dccd8ae7e70f1713d3b5c23c4
BLAKE2b-256 a2d37fee989220964f9301ebbb85a4894034bfe54ba879607d2e6daf9a31f869

See more details on using hashes here.

File details

Details for the file comfy_kitchen-0.2.22-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for comfy_kitchen-0.2.22-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1794bd0331251c9ca30fd54165242d71a73762f3e968aca9b570571951f999df
MD5 6750716e6564b5448a91def2752fb812
BLAKE2b-256 34667e4d1e68f3f5dc466bc0632450fe0b727e7c42b042ad77a77d9c6ca9bfcd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page