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

Uploaded Python 3

comfy_kitchen-0.2.20-cp312-abi3-win_amd64.whl (15.9 MB view details)

Uploaded CPython 3.12+Windows x86-64

comfy_kitchen-0.2.20-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (23.5 MB view details)

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

comfy_kitchen-0.2.20-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (23.4 MB view details)

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

comfy_kitchen-0.2.20-cp311-cp311-win_amd64.whl (15.9 MB view details)

Uploaded CPython 3.11Windows x86-64

comfy_kitchen-0.2.20-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (23.5 MB view details)

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

comfy_kitchen-0.2.20-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (23.4 MB view details)

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

comfy_kitchen-0.2.20-cp310-cp310-win_amd64.whl (15.9 MB view details)

Uploaded CPython 3.10Windows x86-64

comfy_kitchen-0.2.20-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (23.5 MB view details)

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

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

File metadata

  • Download URL: comfy_kitchen-0.2.20-py3-none-any.whl
  • Upload date:
  • Size: 119.6 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.20-py3-none-any.whl
Algorithm Hash digest
SHA256 ae3a43f7b6d83bce000f17c809e84a5521b1c941f750c63023b5fa1dd768813f
MD5 cd4e986a85d9b31b1f82584279eae6e0
BLAKE2b-256 0a2d0d7fac23b4284e3fa630accea21e72855f98722c24645c8cf13e3f2ddc92

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.20-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a64bf39504ee690f6170c171179c638c2e19bf76f472d89c75099b9c215adf7f
MD5 2d76ca1d61621131621ea8c1bd8ce5b8
BLAKE2b-256 fac452c2727cede6df8cef13b4d44cf9026afa64e265c4e05c3cbd3f8d4e181d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.20-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d9ee51774972e13f5d20a1067a334ee2648e4e7dc4aa7befe10508eb2780f7f0
MD5 1e784d28bb02e57da8073c745613a763
BLAKE2b-256 ff3b7572c2798037b9a8874e247f439cf5c3a101ee8f508fb069ad2b628ab9ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.20-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5db113d0de2e74b99035a4a3c6021563b254670d027d3c31580265ac44c842d7
MD5 210caa770baf7e15f72f48a3a7e75bed
BLAKE2b-256 8df5b120e5595c48a5b8eecaae8da7ee000ee3fb622a099df2907782d9a4ef65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.20-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 639c600a8212cc084977cb3f5268b9904eadb15d3a3995bade23acd9818e8c28
MD5 16a163320549e2b69806c8afca267623
BLAKE2b-256 32c7ff9a9ec58a3d35c0b94ac92020d829c1e72f29d1caa200818a7dae1cca69

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.20-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 352ada00ce6600eecd2dfc988e09d503adb229aef8fcc69605d966a09ab7a8e7
MD5 1f3dae51aff2d98a321afb7e9a4f7648
BLAKE2b-256 f8e012f0b320e4602661ca160e57fe8b582b3c151515e7fee14a95103cdafeec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.20-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 14028a6a83bfbb5df02a692bd7b36befa87d5503acbbf2a1b2211f0e604cc46d
MD5 c3ce5639044bfa90420d62d18e2decd1
BLAKE2b-256 4191a9de4e250e6d78f50aac952c1123781aabf901f195cd2864353925935a40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.20-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a0307aac777b1c1e23493e2f320db2c0b19cee01e6819bcfa11b860b99dabaa1
MD5 6a1cd3b304365d533627ad7a81034e1f
BLAKE2b-256 a4fd9923bf256138d5673a9b4bd1fc0d0d0ebfa92417c8d9a894837d108c8789

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.20-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d9390484f9802b1a702064908aba9ee0fa02c662d8fbd80a200135536c415c27
MD5 2337429c0b91c826d2d88f17b960e45d
BLAKE2b-256 dfb46e2f347a2bbec0aed1c5402408e8665cef6b3012634417d0c50dee694fde

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.20-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6c5d650d5ec3656de8869c549765af25bd2c82b7efbece5b5bd42a23e7ebf00c
MD5 48290cbbcefa235943fbb822d76f0729
BLAKE2b-256 0e6a2c08dd46525a3478e895af9ff7c8b9eb071b688ea603c63388637e0500ca

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