Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#15,122 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
70/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python, pytorch

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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)

Lenguaje dominante
Python
Estrellas
34.8k
Forks
7.4k
Merge medio
2 d 6 h
PR fusionados (30 d)
54

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de huggingface/diffusers

Todos los issues de huggingface/diffusers

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.