Comfy-Org/comfy-kitchen
Multi-backend PyTorch kernels for quantized diffusion inference
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
Comfy Kitchen is an in-process Python/PyTorch operator library for diffusion inference, not a model server. Its registry checks device, dtype, shape, and compute capability before dispatching to a kernel. The documented default order is HIP → CUDA → Triton → eager; Ascend registers separately when torch-npu and a compatible device are present. If no backend accepts the call, dispatch raises NoCapableBackendError rather than trying kernels until one works.
Integration can happen through explicit operator calls or QuantizedTensor, a torch.Tensor subclass that intercepts supported PyTorch operations and dispatches quantized implementations where available. Eager is implemented in PyTorch, Triton kernels are JIT-compiled, and native CUDA and HIP extensions are built through setup.py using CMake and nanobind. The HIP backend compiles its own matmuls from comfy_kitchen/backends/hip/ without linking hipBLAS or hipBLASLt.
Key Capabilities & Differentiators
Operator coverage includes quantization, scaled matmul, AdaLN and RMS-AdaLN, RoPE and RMS-RoPE, 2D/3D neighborhood attention, and INT8 attention. Coverage varies by backend: INT8 attention has CUDA and HIP implementations but no eager entry; NVFP4 scaled matmul has CUDA and eager paths; MXFP8 dequantization and scaled matmul are eager-only. The listed Tensor Core layout floors are SM 8.9 for per-tensor E4M3 FP8 and SM 10.0 for 16-element NVFP4 and 32-element MXFP8 blocks, with E8M0 scales for MXFP8.
HIP uses WMMA GEMMs on RDNA3, RDNA3.5, and RDNA4. RDNA4 supports native FP8 WMMA; RDNA3/3.5 widen FP8 operands to BF16. RDNA2 runs non-WMMA operators such as RoPE, quantizers, and AWQ GEMV. HIP RoPE can act in place on strided Q/K views from packed QKV without first making contiguous copies. The optional Ascend backend uses torch-npu for selected INT8 operators and for interleaved and split-half RoPE.
Trade-offs & Limitations
Compared with plain PyTorch eager or maintaining separate CUDA, HIP, and Triton calls, the registry reduces hardware-specific branching at the integration layer. It does not make quantized formats interchangeable or guarantee a fallback: unsupported shapes or dtypes can bypass the preferred kernel, and operators such as INT8 attention have no eager implementation. Test numerical agreement against an eager reference where one exists and log actual dispatch for the shapes used in production.
Low-precision storage is not proof of lower peak VRAM or faster inference. Ascend convrot_w4a4_linear preserves the caller's rotation and quantization precision but unpacks weights into INT8 for INT32 accumulation; that costs memory and time and retains eager's FP16 range limitations. In contrast, HIP can fold activation into the ConvRot quantizer load to avoid writing a separate activation result to GPU memory. Profile peak memory and end-to-end latency at representative model sizes and concurrency before standardizing on a backend.
Hardware & Deployment Guide
Install comfy-kitchen into a local Python ≥3.10 and PyTorch ≥2.7 environment; no server or hosted inference endpoint is required. CUDA wheels target Linux x86_64 and Windows x64 and require CUDA runtime ≥13.0 and NVIDIA driver r580+. The pure Python wheel ships eager and Triton backends; that does not imply Triton will run on every host. CUDA source builds need Toolkit ≥12.8 and CUDA_HOME; native builds use nanobind ≥2.0, CMake ≥3.26, and Ninja.
On a ROCm-only host, pip install . selects HIP when nvcc is absent. Hosts with both toolchains default to CUDA-only unless COMFY_KITCHEN_BUILD_HIP=1 is set. With build isolation, set COMFY_HIP_ARCHS to target a particular AMD GPU instead of building for the whole target list. Windows HIP builds also need the Windows SDK and the recommended VS 2022 v143 C++ toolset. The package manifest lists version 0.2.42, but no GitHub release is listed, so release history does not establish when specific capabilities landed.
torch.Tensor subclass.torch-npu paths handle selected INT8 and rotary operators; W4A4 linear unpacks weights to INT8 for INT32 accumulation.ComfyUI or other PyTorch diffusion integrations that need a shared operator API and can validate quantized paths on their target GPUs or Ascend NPUs.
You need a complete model-serving stack, identical operator coverage across vendors, or already have a tested kernel for a single fixed target and do not need another dispatch layer.
Quick Start & Installation
pip install .Comparison vs. Top LLMs & Inference Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| comfy-kitchen ★ | 265 | +2 | Python | Apache-2.0 | Multi-backend PyTorch kernels for quantized diffusion inference |
| DeepSpeed | 43.4k | +33 | Python | Apache-2.0 | PyTorch runtime for distributed training and inference under GPU memory constrai |
| agent-lightning | 19k | +30 | Python | MIT | Proxy-based reinforcement learning for agents in their existing harnesses |
| ludwig | 11.8k | +6 | Python | Apache-2.0 | YAML-first framework for fine-tuning, training, and serving LLMs and multimodal |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/Comfy-Org/comfy-kitchen.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about comfy-kitchen
How do I integrate the library and verify which kernel path runs?
quantize_per_tensor_fp8, or construct a QuantizedTensor with from_float and use it with supported PyTorch operations such as torch.nn.functional.linear. Use ck.list_backends() to inspect availability, ck.use_backend(...) or the operator's backend= argument for controlled comparisons, and DEBUG logging on comfy_kitchen.dispatch to see which path dispatch selects.How much VRAM should I budget for quantized inference?
convrot_w4a4_linear unpacks weights to INT8. An eager fallback can also have a different memory and runtime profile.Can I self-host it or redistribute it in a commercial product?
LICENSE and NOTICE, preserve applicable notices, and verify the separate terms of bundled dependencies and accelerator runtimes. The project license does not determine model-weight licensing.When is it preferable to plain PyTorch or direct CUDA, HIP, or Triton calls?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy