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

Uploaded Python 3

comfy_kitchen-0.2.18-cp312-abi3-win_amd64.whl (10.6 MB view details)

Uploaded CPython 3.12+Windows x86-64

comfy_kitchen-0.2.18-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (15.5 MB view details)

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

comfy_kitchen-0.2.18-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (15.5 MB view details)

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

comfy_kitchen-0.2.18-cp311-cp311-win_amd64.whl (10.6 MB view details)

Uploaded CPython 3.11Windows x86-64

comfy_kitchen-0.2.18-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (15.5 MB view details)

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

comfy_kitchen-0.2.18-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (15.5 MB view details)

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

comfy_kitchen-0.2.18-cp310-cp310-win_amd64.whl (10.6 MB view details)

Uploaded CPython 3.10Windows x86-64

comfy_kitchen-0.2.18-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (15.5 MB view details)

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

comfy_kitchen-0.2.18-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (15.5 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.18-py3-none-any.whl.

File metadata

  • Download URL: comfy_kitchen-0.2.18-py3-none-any.whl
  • Upload date:
  • Size: 117.0 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.18-py3-none-any.whl
Algorithm Hash digest
SHA256 9ad86327e08316138b648a5032a22d97c85a5939b2f0319bf7188b197a1dc350
MD5 133377e87871e99e8efc969f8431edbb
BLAKE2b-256 c81fa14c4f4efaf87ca013fb2078c0d22fc8c01d71a5f675541c7e97952f1cce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.18-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e8dfc8404d5920f24f03d21e87b3485298b71a6d96ce9aec9829e10185537b6d
MD5 dde22437eca03dcdf1463232ba934f8e
BLAKE2b-256 e20c9c3c769ab5b9868b8feef7b810c7d2c7271feba468ed9da8f2b69805cf66

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.18-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 90f7ba3e2aef197c16e89a5f0c1e12b10e8eb160c2791373505b1c8476d062b7
MD5 2c23a2f16dcdd72937885d301bc95288
BLAKE2b-256 8eeecbdabbbbce5fd4415dc574d29d9b5111e54f3f17e272998c42b56c6d972d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.18-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 321b23d836f12efe7cc3acdfc21cb65f7a074437a6b71c31fdfa34c874225a98
MD5 da16d36643d114767b60c4b08bc7b3b5
BLAKE2b-256 9662e220adeb4ecc8c997bf9ca021f1c98dc5b7cfd9d856f3f62313a465ffd5b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.18-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 5ed3f00ebe02251ad11d1ae810632fbea2c70a98a4a615b1e3c880939b140e0f
MD5 54cbfbe730a7ab25fa78f50b0eb9df27
BLAKE2b-256 b974aaec0ca4e8e61baec55566247182e4232023514d22eab372e9f245e0b529

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.18-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3c630d06c7cf393dbfdb1060360c061f7d5582994262f970ad4be673435ddb63
MD5 bc408d19ba4ccf54374405df389fdd8a
BLAKE2b-256 50e1e14a3225299fa1e3b9058ac6d26b634de7fe293014ee17ebfc9fa7fa157b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.18-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8f1bbd8def021818bc38fbf8d3bb7e1530abc71be59392666f3c5c5127822cd9
MD5 591431c313b95a401e90887d6fb381cc
BLAKE2b-256 b6cb23848dc8402b2392c059464e910a32ea85c08eb911ef46e4f144378eea75

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.18-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 177692f01e7c13063f12eb8c5c78fd1c7da4e47c44a50f58fe1ac9029c0e7b36
MD5 9b60da55dc1cb1ed35865bb8c8df3802
BLAKE2b-256 23026342f68b022e3c633bf5d585126983518103e52acd1ffac709728f9d3f2f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.18-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 78975a9ff3b08220d09d84fc4d3769a73eb2f2da19a3ca93094f34b04d2210ec
MD5 4959835d3f1dd8f07406628fdfc2adae
BLAKE2b-256 dd2250c1a5a4e551f3de4fb00525ed55bd2404d5cc4f0a811036ae5087ff9370

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.18-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9e34ec4869d4593a4b525dae6ef681e17972b33d79fe974834ea8132cd0952c8
MD5 a038edf8b7e1a26fabeab85e7cc18635
BLAKE2b-256 0f10383dd721e66df7b8dd4c747a9ac4164eecb4d807755758d5e6e7145aa1cf

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