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

Uploaded Python 3

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

Uploaded CPython 3.12+Windows ARM64

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

Uploaded CPython 3.12+Windows x86-64

comfy_kitchen-0.2.24-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.24-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.24-cp311-cp311-win_amd64.whl (26.8 MB view details)

Uploaded CPython 3.11Windows x86-64

comfy_kitchen-0.2.24-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.24-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.24-cp310-cp310-win_amd64.whl (26.8 MB view details)

Uploaded CPython 3.10Windows x86-64

comfy_kitchen-0.2.24-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.24-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.24-py3-none-any.whl.

File metadata

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

File hashes

Hashes for comfy_kitchen-0.2.24-py3-none-any.whl
Algorithm Hash digest
SHA256 45f8de14d15640f5a2c4a0f3937d33973a193a1025568874d004a4b588a24cd8
MD5 9f029ed8bef6745c090b2d3b1e2a4851
BLAKE2b-256 835f041dcabe870f4d6e372e92251a5d68f87be542cb937eeb60e24ea24cea0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.24-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 4929af8d203c9d0ea7aa75e7e7e1bd0a6ba1c9ff59e33d84cd5a479f097da2d8
MD5 f422fb2427c74e53eb0120b848b975be
BLAKE2b-256 62349e8bb225efdafa1a7ea83a45c807d8a9cb5a8386d4174fdb7ee6526a901a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.24-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d744bebb744f9fee730ece59084743b3df117d5590dccef9b454a140efdddc02
MD5 e515d8c9ab97a5eb5fe3737bd162b576
BLAKE2b-256 f32ec9d3d66f429667d31065c9d3749e919a5a9b1408137152bfc0dd1366a258

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.24-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 54ef947f2ca4ae9a177a0a059684ea76b3d9abfd34736845962a6c63f725b3b3
MD5 0c94dfd059375a12dfc4a22e042d1104
BLAKE2b-256 f6d4aac38655a7b5df92989940888a9b2c6e88a9234644b8d0f775a2eacffacc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.24-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d1a6ddfb09d3a35ac388e59a5b6dc0f64ef9cc2fa0e771631323d7d513a7d3c4
MD5 e7c2bed4091098f9ff340971b519d7a6
BLAKE2b-256 3d93c0fb066ace836651eb0b7564249f83d4f729c30da59f6c81373970fbcce4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.24-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 57c8e664279991179469efd3961b7ef2af4c8822590149ff8f4ef0ce3d5b4147
MD5 df720fea3ab465d3d2d4a18e4f92fbf9
BLAKE2b-256 03032a1cebc7d7e722e5eac6ec8b0c739b808016e4e20882d5ab6c8ab829b881

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.24-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0a926ec94538b381c3b8eb482d82673c947b743b41ef19a67b391da77d291dfb
MD5 93c0749b420485ba9b81521bab9e9b28
BLAKE2b-256 36089201911d6c8ddfe83988dad4eb2572343a56aee86d7af446826916970400

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.24-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1243418e0c3b047ac959bafff5f6cf8f64c3a41b712ae5b2b94bc6de18ee62da
MD5 d38e067d4d0124f61466164e89686c5e
BLAKE2b-256 c8c55639a7d30d8d2ecf3bd7907eea63b26e09f3b9e3f93e550ae78bdc9e4f71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.24-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 237e1b52ee3db9d6db4426144479868630512e9bd26b4593d1d99c4a40eec968
MD5 f76f6ce6f4f9201f02fe2e5056828deb
BLAKE2b-256 0edea5e02e7aa650bf06f0e35886dfff8f7ab4459ce1cb8d7ee9816e3b94d916

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.24-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e4f931bb046c7a79bbfed48a440a9c72f7aa43bf67ea2d1b3ee1ab726fa7a26a
MD5 162307e86cbbdbb994ba0f20c8c65cd8
BLAKE2b-256 a0f7c5c9e0e5dd4853e83945534fafd2894f417607987f53867161e8032b2ddb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.24-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 fabcb8a921f33c5f9e0a15d4205b14fb2cc2864f474a794b9dbcfef7f56cc6b4
MD5 dcbf913b8e7343bad763e3e0d9dcc876
BLAKE2b-256 c2bda31878986f84b58ad01f9abff35d9d4372bcdbf7c9dc3ce7d912a5291e60

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