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

Uploaded Python 3

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

Uploaded CPython 3.12+Windows x86-64

comfy_kitchen-0.2.17-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.17-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.17-cp311-cp311-win_amd64.whl (10.6 MB view details)

Uploaded CPython 3.11Windows x86-64

comfy_kitchen-0.2.17-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.17-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.17-cp310-cp310-win_amd64.whl (10.6 MB view details)

Uploaded CPython 3.10Windows x86-64

comfy_kitchen-0.2.17-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.17-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.17-py3-none-any.whl.

File metadata

  • Download URL: comfy_kitchen-0.2.17-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.17-py3-none-any.whl
Algorithm Hash digest
SHA256 a03836cddccf8849ebe4feafd2a6b861519ecd776a2b407455e86197b6ded6fa
MD5 81fd6011e8c67958f2b2e15266e007eb
BLAKE2b-256 e0f796a9a44e8458ce88a244b66ca8ff013da232f02262ba9b60ea1176791e4e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.17-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 96b82615cf02d062187bee0823326949ad436e1b7100a4fbe6d94e11adb0b015
MD5 09c278a0f79b3dc77ffdd86bd56cdb7f
BLAKE2b-256 a58ad419efb703b3fef44508e2c400c18a6b897a3d922b29e1eb418ac10e933a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.17-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 35044eeeb0db9ebfa328af8facbca019df6cc9b0ad65750616ca5549b87ec654
MD5 b71668221a7b5bdbb7ed8725fc2ad1ed
BLAKE2b-256 1667d8194ec57faab0d55a0976f8654b75b93271abf63064e482419f31b23795

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.17-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c4a4b3f5bb3f840d06a90f3fcf096c0d76c9e1209abdb3e173bf1f759bc7d758
MD5 d59d15c3fb6735770ef71edcaf87254c
BLAKE2b-256 1267d8e0f350e08547d65cface96d45bc5ff2d359cfcc856e4eb75ceb4a45174

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.17-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 53e1820fe2d2af6267d6c6cd46132c28ea9b28275115a6a8de876902844fcc6c
MD5 e10f8c0a2d7fa34f99d4cd33868ff77b
BLAKE2b-256 f50f51b756c35fba277f821ef60097748f29495566daa73d133f1ce50d223c37

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.17-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e86c7875e75d5ca1dab86f0397d3a68d47aa44a84907f2babd5dbf60e5de55a5
MD5 e65d0579190ce4c87c21873974931f6d
BLAKE2b-256 8437cc6134c004396df03200bbb9fee348c188e921fa402d23738a57bd2d6058

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.17-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ee294ba2ae31e59ec63fac07e616d6423e56a01bc5ed20c172666aea83280e13
MD5 c5d923ed22f73b90961681e8bedb4b61
BLAKE2b-256 101ae52b124acb6870152384a310100d44c24e142db5e65b6b49f571b004557d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.17-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 62450d84d6f2f41ca953bcfb0970de987bc48d05ae0ff60403c3d397629e29ee
MD5 946905c3336c63ccf9ccf0a6704083ea
BLAKE2b-256 2f175ad86f6bb3d234007b1c1782431334f699ecf46ab8f68597c640a6829955

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.17-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ee0bcbcddd1a0c581629f2c4132e8c45e44f1d60eb55be2bafcae6b2cf4b2f68
MD5 c6d492218c53a80ee843b60b5c42e1d3
BLAKE2b-256 0aee16578d2cfd2e31059565a2607634c8c8535f4cae811cee42cdd9389aec9f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comfy_kitchen-0.2.17-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4813754484dbcfd053aedc36c424b460e993242c71d6cc437ae286beb3f99e94
MD5 47e7644c7bc9ef35548b90c635ba726b
BLAKE2b-256 88198064098cb0669fa944f1c35ebf9aa7af29973fc06ffb89b912e346ad0658

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