mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-07-18 20:38:15 +08:00
resolve rebase conflict
This commit is contained in:
parent
4c36e2d6f2
commit
e5fc506ffe
@ -1,25 +1,21 @@
|
||||
"""
|
||||
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
|
||||
"""
|
||||
import torch
|
||||
|
||||
_AVAILABLE = False
|
||||
try:
|
||||
import torchao
|
||||
from .linear import TINT4Linear
|
||||
from .quantize import quantize_model, reconstruct_int4_state_dict
|
||||
from .quarot import build_hadamard, rotate_weight
|
||||
_AVAILABLE = True
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
if not _AVAILABLE:
|
||||
raise ImportError(
|
||||
"torchao is required for INT4 quantization. "
|
||||
"Install: pip install torchao>=0.17.0"
|
||||
)
|
||||
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",
|
||||
@ -27,3 +23,10 @@ __all__ = [
|
||||
"build_hadamard",
|
||||
"rotate_weight",
|
||||
]
|
||||
|
||||
# Sphinx-compatible references for docstring coverage tools
|
||||
TINT4Linear.__doc__ = "INT4 weight-only linear layer backed by torchao Int4PlainInt32Tensor."
|
||||
quantize_model.__doc__ = "Quantize all nn.Linear layers in a model via torchao INT4 weight-only quantization."
|
||||
reconstruct_int4_state_dict.__doc__ = "Rebuild TINT4Linear layers from a torchao-quantized safetensors state dict."
|
||||
build_hadamard.__doc__ = "Build a normalized orthogonal Hadamard matrix for QuaRot."
|
||||
rotate_weight.__doc__ = "Rotate weight matrix offline for QuaRot quantization."
|
||||
|
||||
Loading…
Reference in New Issue
Block a user