Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Quantizer configs are mutated in place, leaking modules_to_not_convert across loads

Aperta
#15,124 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
54/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python, pytorch

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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)

Lingua principale
Python
Stelle
34.8k
Fork
7.4k
Merge medio
2g 10h
PR unite (30g)
56

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di huggingface/diffusers

Tutte le issue di huggingface/diffusers

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.