ComfyUI/comfy/quantization/torchao/__init__.py

32 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
ComfyUI TorchAO INT4 weight-only quantization backend.
W4A16 scheme: weights quantized to INT4 via torchao,
activations remain FP16. Supports CUDA, Intel XPU, and CPU.
Includes:
- TINT4Linear: INT4 linear layer with LoRA forward injection + QuaRot
- quantize_model: torchao INT4 quantization entry point
- reconstruct_int4_state_dict: rebuild TINT4Linear from safetensors
- build_hadamard / rotate_weight: QuaRot Hadamard rotation
"""
from .linear import TINT4Linear
from .quantize import quantize_model, reconstruct_int4_state_dict
from .quarot import build_hadamard, rotate_weight
# Public API — documented for docstring coverage
__all__ = [
"TINT4Linear",
"quantize_model",
"reconstruct_int4_state_dict",
"build_hadamard",
"rotate_weight",
]
# ★ FIX 3: 删除 __doc__ 覆写5 行)
# 原因:这些类/函数的 .py 文件里已有 docstring重复赋值会
# 1. 覆盖原始文档(如果两处不一致会让人困惑)
# 2. 干扰 Sphinx 等文档工具的正确引用
# 3. 违反 DRY 原则——文档应该只在源码处维护一份