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.23-py3-none-any.whl (127.2 kB view details)

Uploaded Python 3

comfy_kitchen-0.2.23-cp312-abi3-win_arm64.whl (6.4 MB view details)

Uploaded CPython 3.12+Windows ARM64

comfy_kitchen-0.2.23-cp312-abi3-win_amd64.whl (26.7 MB view details)

Uploaded CPython 3.12+Windows x86-64

comfy_kitchen-0.2.23-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (39.8 MB view details)

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

comfy_kitchen-0.2.23-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (39.7 MB view details)

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

comfy_kitchen-0.2.23-cp311-cp311-win_amd64.whl (26.8 MB view details)

Uploaded CPython 3.11Windows x86-64

comfy_kitchen-0.2.23-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (39.8 MB view details)

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

comfy_kitchen-0.2.23-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (39.7 MB view details)

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

comfy_kitchen-0.2.23-cp310-cp310-win_amd64.whl (26.8 MB view details)

Uploaded CPython 3.10Windows x86-64

comfy_kitchen-0.2.23-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (39.8 MB view details)

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

comfy_kitchen-0.2.23-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (39.7 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.23-py3-none-any.whl.

File metadata

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

File hashes

Hashes for comfy_kitchen-0.2.23-py3-none-any.whl
Algorithm Hash digest
SHA256 466abe080706084223a10efedd449f6f19e2a4ca6b0ccd02cf22971b8c9a18ef
MD5 304f97251e4f9b6e02f59121e53b2371
BLAKE2b-256 ae482017ad1364220bc65f1e1222e95f775c103cd865bceb8b395f4e49847a51

See more details on using hashes here.

File details

Details for the file comfy_kitchen-0.2.23-cp312-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for comfy_kitchen-0.2.23-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 a27cb1c5f00816e5b8457f85eebcec28237085df71eb231044391122695e547e
MD5 5b0ec300c21a9d54d24e26d1a3523275
BLAKE2b-256 525aeba71c0ff95e29817daf47d12f86125dc351b5ed9813ff804c15bfbbde2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.23-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f4d3723e09afd9fdaffca9661d74ecf2c91dd69c43d3432b19a4ecca3a142f65
MD5 361b1b03c45f00b85b1a6c119abc5dba
BLAKE2b-256 03b5df96b2d956b1821e137794e8a4d22738bd0f4883ca154e538c7a7452ad74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.23-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e9d6cc50272d8716993043c89ea5b15180d9a89dbc8eb021b96056f0a48e25ad
MD5 caac54c664bf2e6072c70777361ff1a0
BLAKE2b-256 284488ef1b04448f189edfbae7c9b4f3ca08d391d697da9bc0c95884e5ba482f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.23-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 15ae9fa58f833a766f4c1726bf099817431a52340d092b6e74ab85add56c4664
MD5 6399b3166a138cd5db856fd57676c98b
BLAKE2b-256 53f5d32fbfd1ecce9a48818e0484c25325037dc2bde0778ed2f4f2caa6e24680

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.23-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9aabbbad594becf3181a6adfbc77cc844c3bd654bd18bd3cdcb7684d7347b771
MD5 a0d6e2d49bbee2e5e0531f9add8e8f74
BLAKE2b-256 e71ffc6f3e2b51127bfba27926643e46f5730580bf781c256ec7764697ecaa49

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.23-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1ef864b9fa8c0d43153405e2a9c6a86eac655770e241798fa8b02b919d06d194
MD5 6daa076b104998de6cb44c9ec3fa23b9
BLAKE2b-256 dee963f08be67193f88c95a0b26fb250afcfca43aec02daf68909141efca5161

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.23-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0fe0363f017043274c3ec259757a253c45f04ac210773a0a8edb22a5b475a91e
MD5 49c7fce84485f82fe30fcfa4ce3244b4
BLAKE2b-256 d8527c04d83882148b898fe76fa8950cd6ffdd37d0436106f7d51dddd7d310fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.23-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 1392f2e5d4fcafdd82fb4a5df3c7c89c382e4cb93e380537e6eefceae0e0ec3d
MD5 96869d5329af48b971d4d6e5cc76a298
BLAKE2b-256 7cc87ef93e13412ec013d124dd2a8b439311538bd50eac945bb3728979b85fff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.23-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d9d1267fdc3c5db1b6b6245a6b41032430c247ef67ab0b00a035f0aeb2038b1f
MD5 6df96c53233abbbf9e434fd36ffbc494
BLAKE2b-256 5bea7b4029778467b7a13f2c7d897cb73bfd16cf53c38fc0337998985b9fae6f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.23-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 18156474dc33211c8da57c5c3ae0a00d6def01118985015201b01c0a02078bc2
MD5 1ac33615cda1936c8d35a0e3095d94db
BLAKE2b-256 e17d83b382caa0a40a3629f3dd7e0da3ecaa984d0a1970bec7ee83c8c5753c2c

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