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

NVIDIAModelOptConfig.to_dict() crashes from_pretrained/save_pretrained when forward_loop is set

Aperta
#15,122 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à
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python, pytorch

Direzione di ricerca

Read NVIDIAModelOptConfig in src/diffusers/quantizers/quantization_config.py and the telemetry serialization call in src/diffusers/models/modeling_utils.py. Use the reproduction to check how to_dict() handles forward_loop, then verify that json.dumps(config.to_dict()) succeeds and from_pretrained/save_pretrained no longer fail when a forward loop is set.

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

Descrizione

Describe the bug

forward_loop is a documented NVIDIAModelOptConfig constructor parameter. NVIDIAModelOptConfig has no to_dict() override, so it inherits QuantizationConfigMixin.to_dict(), which returns copy.deepcopy(self.__dict__) — including the raw forward_loop callable.

src/diffusers/models/modeling_utils.py calls json.dumps(hf_quantizer.quantization_config.to_dict(), sort_keys=True) for telemetry during from_pretrained, with no error handling around it. Any model loaded (or saved) with a NVIDIAModelOptConfig(forward_loop=...) crashes with TypeError: Object of type function is not JSON serializable.

Reproduction
import json
from diffusers.quantizers.quantization_config import NVIDIAModelOptConfig

config = NVIDIAModelOptConfig(
    quant_type="FP8",
    forward_loop=lambda model: model,
    modelopt_config={"quant_cfg": {}},
)

json.dumps(config.to_dict())
Logs
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: Object of type function is not JSON serializable

This is the same call modeling_utils.py makes internally during from_pretrained:

  File ".../diffusers/src/diffusers/models/modeling_utils.py", line 1206, in from_pretrained
    serialized_quant_config = json.dumps(hf_quantizer.quantization_config.to_dict(), sort_keys=True)
TypeError: Object of type function is not JSON serializable
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 20h
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.