Unverified Commit 4132b3bf authored by Muyang Li's avatar Muyang Li Committed by GitHub
Browse files

feat: support Qwen-Image in ComfyUI-nunchaku (#632)

* update

* add parameter of act unsigned

* upgrade the diffusers to v0.35.1

* bump the comfyui version to 0.3.51

* update version

* revert the test comfyui-version back to 0.3.44
parent 3ec299f4
......@@ -67,8 +67,8 @@ jobs:
which python
echo "Installing dependencies"
pip install torch==2.7 torchvision==0.22 torchaudio==2.7 --index-url https://download.pytorch.org/whl/cu128
pip install git+https://github.com/huggingface/diffusers
pip install ninja wheel transformers==4.51 accelerate==1.7 sentencepiece==0.2 protobuf==6.31 huggingface_hub==0.34
pip install diffusers==0.35.1
pip install ninja wheel transformers==4.55 accelerate==1.10 sentencepiece==0.2 protobuf==6.31 huggingface_hub==0.34
- name: Build
run: |
source $(conda info --base)/etc/profile.d/conda.sh
......
......@@ -14,10 +14,13 @@ class SVDQW4A4Linear(nn.Module):
rank: int = 32,
bias: bool = True,
precision: str = "int4",
act_unsigned: bool = False,
torch_dtype: torch.dtype = torch.bfloat16,
device: str | torch.device = "cpu",
device: str | torch.device | None = None,
):
super(SVDQW4A4Linear, self).__init__()
if device is None:
device = torch.device("cpu")
self.in_features = in_features
self.out_features = out_features
self.rank = rank
......@@ -69,7 +72,7 @@ class SVDQW4A4Linear(nn.Module):
torch.ones(out_features, dtype=torch_dtype, device=device), requires_grad=False
)
self.act_unsigned = False
self.act_unsigned = act_unsigned
@classmethod
def from_linear(cls, linear: nn.Linear, **kwargs):
......@@ -140,9 +143,11 @@ class AWQW4A16Linear(nn.Module):
bias: bool = True,
group_size: int = 64,
torch_dtype: torch.dtype = torch.bfloat16,
device: str | torch.device = "cuda",
device: str | torch.device | None = None,
):
super(AWQW4A16Linear, self).__init__()
if device is None:
device = torch.device("cpu")
self.in_features = in_features
self.out_features = out_features
......
......@@ -280,3 +280,18 @@ def check_hardware_compatibility(quantization_config: dict, device: str | torch.
f"Unsupported GPU architecture {sm} due to the lack of 4-bit tensorcores. "
"Please use a Turing, Ampere, Ada or Blackwell GPU for this quantization configuration."
)
def get_precision_from_quantization_config(quantization_config: dict) -> str:
"""
Get the precision from the quantization configuration.
"""
if quantization_config["weight"]["dtype"] == "fp4_e2m1_all":
if quantization_config["weight"]["group_size"] == 16:
return "nvfp4"
else:
raise ValueError("Currently, nunchaku only supports nvfp4.")
elif quantization_config["weight"]["dtype"] == "int4":
return "int4"
else:
raise ValueError(f"Unsupported quantization dtype: {quantization_config['weight']['dtype']}")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment