Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Quantizer configs are mutated in place, leaking modules_to_not_convert across loads

Ouverte
#15,124 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
54/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
python, pytorch

Piste de recherche

Start by reading _process_model_before_weight_loading in bnb_quantizer.py, torchao_quantizer.py, quanto_quantizer.py, and modelopt_quantizer.py, then trace how each quantizer handles modules_to_not_convert and modelopt_config["quant_cfg"]. Reproduce the shared-config mutation with the supplied BitsAndBytes example and check for tests covering repeated loads and PipelineQuantizationConfig. Done means repeated loads leave the shared config unchanged and do not accumulate entries in saved config.json.

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

Description

Describe the bug

BitsAndBytes (4-bit and 8-bit), TorchAO, Quanto, and ModelOpt quantizers each alias a modules_to_not_convert-style list directly from self.quantization_config and then call .extend() on it, instead of copying it first:

  • BitsAndBytes 4/8-bit: bnb_quantizer.py (_process_model_before_weight_loading)
  • TorchAO: torchao_quantizer.py (_process_model_before_weight_loading)
  • Quanto: quanto_quantizer.py (_process_model_before_weight_loading)
  • ModelOpt: modelopt_quantizer.py (_process_model_before_weight_loading), which also writes module entries into modelopt_config["quant_cfg"]

Reusing the same quantization_config object across two from_pretrained calls leaks state between loads — keep_in_fp32_modules and CPU/disk-offloaded module names accumulate on the shared config object across calls, and in PipelineQuantizationConfig the same quant_kwargs list / quant_mapping object is shared across components (including transformers text encoders), so the leak isn't confined to one component. The accumulated list also gets written into config.json on save.

Reproduction
import torch
from diffusers import BitsAndBytesConfig
from diffusers.quantizers.bitsandbytes.bnb_quantizer import BnB8BitDiffusersQuantizer

skip_modules = ["proj_out"]
config = BitsAndBytesConfig(load_in_8bit=True, llm_int8_skip_modules=skip_modules)
model = torch.nn.Sequential(torch.nn.Linear(4, 4), torch.nn.Linear(4, 4))

for _ in range(2):
    quantizer = BnB8BitDiffusersQuantizer(config)
    quantizer._process_model_before_weight_loading(model, device_map=None, keep_in_fp32_modules=["norm_out"])

print(config.llm_int8_skip_modules)
# ['proj_out', 'norm_out', 'norm_out'] after two loads - should stay ['proj_out']
System Info
  • diffusers @ main, commit aaf57d0
  • Python 3.12, Linux
Who can help?

(leaving blank — no specific quantization reviewer listed in the template's tag guide)

Langage dominant
Python
Étoiles
34.8k
Forks
7.4k
Merge moyen
2 j 15 h
PR mergées (30 j)
58

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de huggingface/diffusers

Toutes les issues de huggingface/diffusers

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

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