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

Uploaded Python 3

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

Uploaded CPython 3.12+Windows x86-64

comfy_kitchen-0.2.19-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.19-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.19-cp311-cp311-win_amd64.whl (15.9 MB view details)

Uploaded CPython 3.11Windows x86-64

comfy_kitchen-0.2.19-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.19-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.19-cp310-cp310-win_amd64.whl (15.9 MB view details)

Uploaded CPython 3.10Windows x86-64

comfy_kitchen-0.2.19-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.19-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.19-py3-none-any.whl.

File metadata

  • Download URL: comfy_kitchen-0.2.19-py3-none-any.whl
  • Upload date:
  • Size: 119.4 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.19-py3-none-any.whl
Algorithm Hash digest
SHA256 0037442993812c686d0ac72e2238cde56ac19858d705d9b67b00514513aa9b18
MD5 b148619b281bba9ec09be9aadf48786c
BLAKE2b-256 6b2434bc8350ad96fc7524cf8b4f7282ab04c6eb01138ae9b908e77d467a6308

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.19-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ad1588b657646dae3f42269c36adb81dbdfddfe7e432e106fcc717544bc9a939
MD5 eac03e7c37d6769e7e384cd1b906fd5f
BLAKE2b-256 efdc4153e72c53b61505af5b1aae43e8a4955a52fbbd2fcf6a565891aee2fd14

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.19-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 37f77fd8f860b8e125716acd3fc6bc44caa03cb8ba418f4e518b221961a38c85
MD5 a3ccff3746bd50876c3cc2356227d9b4
BLAKE2b-256 b820ebaf9b2d1573afd677e180a783c7f570017c8f995c97aee6e12fa1f62e0b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.19-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 74e0c9ea02803e02cdf9b847b568187873454ada4e274d468d84181461dd5511
MD5 40e69f9070aa82238dd5c5964c8bdef6
BLAKE2b-256 5b44ed9d2ea4b817d1bfe8fab05218b56ce7b79d90d7e835e195ed62b0560324

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.19-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e5f8c1d6779b9c6ba755f1e309b6ebdeadb3a4728e447309eb0b71385e1c022d
MD5 3df5b5fc465abb62f15559ad6929cdea
BLAKE2b-256 d69c9442498849946b052243dc3f3324ad785428cb74a99972f488416e94e4a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.19-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d173780affb2737f709c427a93bcbd01b1838c86d4066671ac0fa1037883bffb
MD5 92c955bc153bc425838125ca6f8dc569
BLAKE2b-256 068e10203138864f36ca6ce03b4edb954f288c3287d8236410a7932c474c890f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.19-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a25595bc281c14c6e8d402b35fa0d556bd1efef232de2b427410d2b12696c5eb
MD5 c939ed43213bdfbddb5e4bf32df13333
BLAKE2b-256 9b66ad4f05312ec137843a926e0f3ff00085e8fcf27970f6f477d8d7cb1ca5d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.19-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 11285788788c86aef9ce180d4517061378b7a7a1dd2394fd7ca9797509dc03a3
MD5 16fa068020fc620909916060c9e44603
BLAKE2b-256 7c19f13435ba59aaf398ec38e5d04c5a185e9c009ccd9713fdd06697a5faa165

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.19-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7ea288d221daf385f4c10f8efb79cff32f7796fef935c20017ab3c1cbc11b694
MD5 23eaecdeeed8e1440556637837a71656
BLAKE2b-256 0e45f750fde6b41f6bb9b2d87a9283c5d46f56075651363b3e0bcee68547d3e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.19-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 60be486d09692e4591cfb1030e8b9cbacb78da4ae581b9a0f9e89ccde93dd601
MD5 535575b40330a1ebc8873e3944907785
BLAKE2b-256 5799b0fa00a1aa181b557d6ca0226d5929c89ce6ca8c23c8a585678e67fc6fd1

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