Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

QuantFunc/ComfyUI-QuantFunc

Repository files navigation

๐Ÿค— Hugging Face | ๐Ÿค– ModelScope | ๐Ÿ’ฌ WeChat (ๅพฎไฟก) | ๐ŸŽฎ Discord

ComfyUI-QuantFunc

ไธญๆ–‡่ฏดๆ˜Ž

1. Introduction

ComfyUI plugin for QuantFunc โ€” the fastest diffusion model inference engine. Run quantized text-to-image and image editing models at 2xโ€“11x speed with zero Python model dependencies.

Key features:

  • Native C++/CUDA acceleration via libquantfunc.so / quantfunc.dll
  • SVDQ (offline quantization) + Lighting (runtime quantization) dual engine
  • Zero-cost LoRA stacking
  • Image editing with reference images
  • Export runtime-quantized models with LoRA fusion support
  • Auto-update from ModelScope

Version History

Plugin (comfy) Engine (lib) Summary
0.0.02 (current) 0.0.07 v2 loader architecture ยท inpainting ยท full GPU coverage ยท faster editing โ€” details below
0.0.01 0.0.01 โ€“ 0.0.06 Base release: runtime/offline quantization ยท model & LoRA loaders ยท reference-image editing ยท export ยท auto-update

What's New in 0.0.02 (engine 0.0.07)

๐ŸŽฏ Ease of Use

  • v2 loaders โ€” separate MODEL / CLIP / VAE sockets feed a Build Pipeline node, so models wire up the ComfyUI-native way instead of one monolithic loader.
  • Universal format adapters โ€” load diffusers / BFL (Flux) / nunchaku SVDQ / bundled-checkpoint / HF layouts automatically, with no manual conversion.
  • Base Model Auto Loader with one-click download; the plugin also auto-pulls the matching engine on first startup.

๐Ÿงฉ Model Support

  • SVDQ (offline quantization) + Lighting (runtime BF16/FP16 โ†’ 4-bit) dual engine.
  • Pipelines: Z-Image ยท QwenImage ยท QwenImage-Edit ยท Flux.2 Klein.
  • Full GPU coverage (engine 0.0.07): consumer RTX 20 / 30 / 40 / 50-series, datacenter A100 / H100 / H200 / B100 / B200 / GB300, workstation RTX 6000 Ada / RTX PRO 6000 Blackwell โ€” across CUDA 12 & 13.

โšก Performance

  • Consumer GPUs run native SASS โ€” no first-run JIT compile stall on 20/30/40/50-series (datacenter/workstation cards JIT once, then cache).
  • Native FP4 (NVFP4) on Blackwell (SM120) โ€” the fastest 4-bit path.
  • QFRAW raw staging for reference images & masks skips the PNG/BMP encode (~80 ms saved per ref).
  • Multi-pipeline CPUโ†”GPU coexistence โ€” swap pipelines without a full reload; idle workers auto-free VRAM.

โœจ New Features

  • Inpainting โ€” MASK input plus Mask Config and Mask Scale By nodes (white = regenerate, black = preserve), mirroring ComfyUI's SetLatentNoiseMask.
  • Build Pipeline node (v2 assembly) with per-component precision control.
  • Robust worker-process architecture โ€” CPUโ†”GPU model swap + zombie-worker cleanup.

๐Ÿ›ก๏ธ Stability & Security

  • Fixed a /dev/shm RAM leak โ€” edit/inpaint staging files are now always cleaned up.
  • Zip-slip guard on dependency-archive extraction.
  • IPC bound-check on the worker โ†’ host image transfer.

The plugin auto-pulls the matching engine on startup: bumping comfy to 0.0.02 lets the updater fetch engine 0.0.07 from ModelScope (older comfy stays capped at engine 0.0.06).

2. Installation

2.1 Method A: Clone from Git (Recommended)

cd ComfyUI/custom_nodes
git clone https://github.com/QuantFunc/ComfyUI-QuantFunc.git

The plugin will automatically download the latest compatible libquantfunc.so (Linux) or quantfunc.dll (Windows) from ModelScope on first startup. No manual binary download needed.

2.2 Method B: Manual Installation

  1. Download or clone this repository into ComfyUI/custom_nodes/:
ComfyUI/
โ””โ”€โ”€ custom_nodes/
 โ””โ”€โ”€ ComfyUI-QuantFunc/
 โ”œโ”€โ”€ __init__.py
 โ”œโ”€โ”€ nodes.py
 โ”œโ”€โ”€ worker.py
 โ”œโ”€โ”€ auto_update.py
 โ””โ”€โ”€ bin/
 โ”œโ”€โ”€ linux/
 โ”‚ โ””โ”€โ”€ version.json
 โ””โ”€โ”€ windows/
 โ””โ”€โ”€ version.json
  1. Start ComfyUI โ€” the plugin auto-downloads the library binary on first run.

  2. (Optional) To skip auto-download, manually place the binary:

    • Linux: Download libquantfunc.so โ†’ bin/linux/
    • Windows: Download quantfunc.dll โ†’ bin/windows/

2.3 System Requirements

Requirement Minimum
GPU NVIDIA RTX 20 series or newer (CC 7.5+)
VRAM 8 GB
Driver NVIDIA โ‰ฅ 560
CUDA Runtime 13.0+
cuDNN 9.x
OS Linux (glibc 2.31+) or Windows 10/11
Python 3.9+ (ComfyUI's embedded Python)

2.4 Runtime Dependencies

Linux

# CUDA 12 runtime libraries
sudo apt install cuda-libraries-12-8
# or individual packages:
sudo apt install libcublas-12-8 libcurand-12-8 libcusolver-12-8 libcusparse-12-8 libnvjitlink-12-8
# cuDNN 9
sudo apt install libcudnn9-cuda-12
# --- OR ---
# CUDA 13 runtime libraries
sudo apt install cuda-libraries-13-0
# or individual packages:
sudo apt install libcublas-13-0 libcurand-13-0 libcusolver-13-0 libcusparse-13-0 libnvjitlink-13-0
# cuDNN 9
sudo apt install libcudnn9-cuda-13

Windows

  • NVIDIA Driver โ‰ฅ 560 (provides CUDA runtime DLLs)
  • Visual C++ Redistributable 2015-2022 (download)
  • cuDNN 9.x (download)

2.5 ModelScope Dependency (for auto-update)

Auto-update requires modelscope Python package:

pip install modelscope

If modelscope is not installed, auto-update is silently skipped. You can manually download binaries from:

2.6 Verify Installation

After starting ComfyUI, check the console for:

[QuantFunc] Checking for updates (plugin v0.0.01, lib v0.0.01)...
[QuantFunc] Library is up to date (v0.0.01)

If the library was not found:

[QuantFunc] No library found, checking ModelScope for download (plugin v0.0.01)...
[QuantFunc] Downloading libquantfunc.so v0.0.01 from ModelScope...
[QuantFunc] Updated libquantfunc.so to v0.0.01. Restart ComfyUI to use the new version.

3. Usage

See doc/ for detailed tutorials and workflow_sample/README.md for node reference.

Must-Read for Beginners: Generate Your First Image in 3 Nodes

The easiest way to get started โ€” import the Easy Gen workflow, pick a model from the dropdown, and the plugin auto-downloads everything. No manual model downloads or path configuration needed.

Beginners: Easy Gen โ†’

3.1 Runtime Quantization: Quantize BF16/FP16 Models to 4bit for Accelerated Inference

The Lighting backend provides runtime quantization โ€” it uses the Lighting engine to quantize any diffusers-format BF16/FP16 model (e.g., Qwen/Qwen-Image-Edit-2511) to 4bit at load time for accelerated inference. Just set model_backend to lighting and leave transformer_path empty โ€” no pre-quantized model download needed.

Tutorial 1: Runtime Quantization โ†’

3.2 Export Runtime-Quantized Models (with LoRA Fusion Support)

The Lighting export saves all runtime-quantized models to disk, so you don't need to re-quantize on every startup. If you've also stacked LoRAs, they are permanently fused into the exported weights โ€” no LoRA nodes needed, no re-quantization, load and go.

Tutorial 2: Export Runtime-Quantized Models โ†’

3.3 Download and Use Pre-exported Quantized Models

QuantFunc has pre-exported commonly used models (runtime-quantized and ready to use). Download them directly from ModelScope or HuggingFace โ€” same 2xโ€“11x inference speedup as runtime quantization, but with faster loading since the quantization step is skipped.

Tutorial 3: Download & Use Pre-exported Models โ†’

3.4 Example Workflows

Import from workflow_sample/:

File Use Case
QuantFunc-Easy-Gen.json Beginners โ€” 3-node auto-download workflow
QuantFunc-Text-to-Image-Workflow.json Text-to-image (SVDQ + Lighting side by side)
QuantFunc-Image-to-Image-Workflow.json Image editing with reference images
QuantFunc-Model-Export.json Export runtime-quantized models (supports LoRA fusion)

4. Troubleshooting

Issue Solution
Worker failed to start Check CUDA driver โ‰ฅ 560, ensure CUDA runtime libs installed
DLL/SO not found Check bin/linux/ or bin/windows/ contains the library; restart ComfyUI to trigger auto-download
No log output Update to latest library version (requires stderr log support)
cuDNN BAD_PARAM Delete cuDNN algo cache and retry
Noisy output Ensure model backend matches transformer weights (svdq vs lighting)
Auto-update fails Install modelscope package, or manually download from ModelScope

5. License

See QuantFunc Plugin License.

Community

Join our community for support, updates, and discussions:

  • ๐ŸŽฎ Discord server
  • ๐Ÿ’ฌ Scan the QR code below to join our WeChat group:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

Languages

AltStyle ใซใ‚ˆใฃใฆๅค‰ๆ›ใ•ใ‚ŒใŸใƒšใƒผใ‚ธ (->ใ‚ชใƒชใ‚ธใƒŠใƒซ) /