Quantizer configs are mutated in place, leaking modules_to_not_convert across loads
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
- Ambito
- machine-learning
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 intomodelopt_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, commitaaf57d0- 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
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di huggingface/diffusers
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
huggingface/diffusers#15125 ·
I maintainer di solito rispondono entro 1 giorno
-
`encode_video` truncates a fractional `fps`, so the video runs longer than its audioForse già presa @guptaishaan l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
huggingface/diffusers#15104 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
VaeImageProcessor.denormalize() raises AttributeError for NumPy inputsForse già presa @tonycoder-hub l’ha presa 15 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
huggingface/diffusers#15011 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
`ModelMixin.from_pretrained` on a sharded checkpoint fails under `HF_HUB_OFFLINE=1` even when fully cached (`_get_checkpoint_shard_files` still calls `model_info`)Forse già presa @Subodh-17 l’ha presa 21 giorni fa. Apertabug models
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
huggingface/diffusers#14952 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
UniPCMultistepScheduler fails in torch.linalg.solve under a float64 default dtype: the unit entry of rks takes the default dtypeForse già presa @deep1blue l’ha presa 8 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
huggingface/diffusers#14888 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di huggingface/diffusers
Issue simili
-
backlog
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 91/100
EchoTools/nevr-runtime#1108 ·
I maintainer di solito rispondono entro 1 giorno
-
parse names a key after a top-level multi() threshold Bitcoin Core v31.1 refuses as not validAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
btclib-org/btclib-wallet#587 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Judgment-Pack/judgment-pack-spec#275 ·
I maintainer di solito rispondono entro 1 giorno