huggingface / huggingface/diffusers

Failed to load lora in int8 mode

Ouverte
#11,752 5 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Python
Étoiles
34.5k
Forks
7.3k
Merge moyen
3 j 3 h
PR mergées (30 j)
91

Description

Let me introduce the background. The fill model changes the picture background. Torchao quantization is used for inference, but it fails when loading Lora. If Lora is not quantized, it can be loaded.

`transformer = FluxTransformer2DModel.from_pretrained(
model_path
, subfolder = "transformer"
, torch_dtype = torch.bfloat16
)
quantize_device = DEVICE_ID
#int8方式加载
quantize_(
transformer,
int8_weight_only(),
device = quantize_device # quantize using GPU to accelerate the speed
)
#fp8方式加载
# quantize_(
# transformer,
# float8_weight_only(),
# device = quantize_device # quantize using GPU to accelerate the speed
# )
self.pipe = FluxFillPipeline.from_pretrained(
model_path,
transformer = transformer,
torch_dtype = torch.bfloat16
)

if is_add_loramodel:
self.pipe.load_lora_weights("/Flux-Midjourney-Mix2-LoRA/", weight_name="mjV6.safetensors")
self.pipe.fuse_lora(lora_scale=1.2)
#self.pipe.to("cuda:0") #速度快耗费显存全流程不到10s,节省内存 全模型常驻GPU
self.pipe.enable_model_cpu_offload(gpu_id = pipe_gpu_id)#速度慢耗费内存,节省显存空载几乎不消耗显存。`

TypeError: TorchaoLoraLinear.__init__() missing 1 required keyword-only argument: 'get_apply_tensor_subclass'

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Reproduisez la configuration FluxFillPipeline présentée avec la quantification int8 de torchao, puis suivez load_lora_weights et fuse_lora jusqu’à TorchaoLoraLinear.__init__. C’est terminé lorsque le transformer quantifié peut charger et fusionner la LoRA sans que l’argument get_apply_tensor_subclass manque.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python, pytorch
Domaine
machine-learning
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.