Quantizer configs are mutated in place, leaking modules_to_not_convert across loads
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 54/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Domínio
- machine-learning
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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)
- Linguagem predominante
- Python
- Estrelas
- 34.8k
- Forks
- 7.4k
- Merge médio
- 2d 10h
- PRs com merge (30d)
- 56
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de huggingface/diffusers
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
huggingface/diffusers#15125 ·
Mantenedores costumam responder em até 1 dia
-
`encode_video` truncates a fractional `fps`, so the video runs longer than its audioTalvez já em andamento @guptaishaan assumiu há 7 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 83/100
huggingface/diffusers#15104 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
VaeImageProcessor.denormalize() raises AttributeError for NumPy inputsTalvez já em andamento @tonycoder-hub assumiu há 17 dias. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
huggingface/diffusers#15011 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
`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`)Talvez já em andamento @Subodh-17 assumiu há 22 dias. Abertabug models
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
huggingface/diffusers#14952 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
UniPCMultistepScheduler fails in torch.linalg.solve under a float64 default dtype: the unit entry of rks takes the default dtypeTalvez já em andamento @deep1blue assumiu há 10 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
huggingface/diffusers#14888 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de huggingface/diffusers
Issues semelhantes
-
app: scripts status: backlog type: documentation
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
netbox-community/netbox-scripts#68 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 91/100
marin-community/marin#10765 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 70/100
flathub/com.unity.UnityHub#230 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
namespace operations
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 63/100
EclipseFdn/open-vsx.org#14910 ·
Mantenedores costumam responder em até 1 dia