[Bug]: AutoTuner load_cache crashes on a non-string tactic entry: warning_once(key=<list>) raises TypeError: unhashable type

Abierto Apto para principiantes
#21,218 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@Gloria72 ya está trabajando en esto.

Desde el 29/10/2026.

  • #21303 de @Gloria72 — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
backend

Línea de trabajo

Empieza en tensorrt_llm/_torch/autotuner.py, en _deserialize_cache_data, donde la advertencia pasa el valor raw de tactic como clave. Lee Logger.log_once en tensorrt_llm/logger.py para confirmar que la clave debe ser hashable y luego comprueba si ya existen pruebas de deserialización de AutoTuner. Se considera terminado cuando se omiten las entradas de tactic que sean listas o diccionarios con la advertencia prevista y el resto de la caché todavía puede cargarse.

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

Descripción

Customized kernels
System info
  • TensorRT-LLM main at f65df75fcd (tensorrt_llm/version.py: 1.4.0rc3). The code path is unchanged since #9835.
  • Pure Python logic, independent of GPU and driver. Reproduced with Python 3.12.
Reproduction

Load an AutoTuner cache file in which one entry's "tactic" is not a string, for example a list or a dict. A cache written before #9835 stored the raw tactic ("tactic": tactic), so a list tactic is what an old-format or hand-merged cache contains:

{"<shared key>": {"('op', 0, ((16, 128),))": {"runner_id": 0, "tactic": [1, 2], "min_time": 0.1}}}

The same thing happens when calling _deserialize_cache_data directly with that entry.

Expected

The entry is skipped with the "Could not deserialize tactic ... skipping entry" warning, as the comment above that except intends ("so one bad entry can't crash the whole load").

Actual

ast.literal_eval raises on the non-string value, and the handler then raises while logging the warning, so load_cache logs Failed to load cache with JSON and re-raises:

Traceback (most recent call last):
  File "tensorrt_llm/_torch/autotuner.py", line 872, in _deserialize_cache_data
    tactic = ast.literal_eval(value["tactic"])
  ...
ValueError: malformed node or string: [1, 2]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "tensorrt_llm/_torch/autotuner.py", line 879, in _deserialize_cache_data
    logger.warning_once(
  File "tensorrt_llm/logger.py", line 343, in warning_once
    self.log_once(self.WARNING, *msg, key=key)
  File "tensorrt_llm/logger.py", line 320, in log_once
    if key not in self._appeared_keys:
TypeError: unhashable type: 'list'

A dict tactic fails the same way (unhashable type: 'dict').

Location

tensorrt_llm/_torch/autotuner.py, _deserialize_cache_data (line 879 on f65df75fcd):

logger.warning_once(
    f"[AutoTuner] Could not deserialize tactic: {value['tactic']} for cache key {key_str}; skipping entry.",
    key=value["tactic"])

Logger.log_once stores key in a set, so the key must be hashable. The raw JSON value is not hashable when it is a list or a dict.

Suggested fix

Use a hashable key, for example key=("autotuner_deserialize_tactic", repr(value["tactic"])). The serialize-side warning_once(..., key=tactic_str) is already a string and is fine.

Lenguaje dominante
Python
Estrellas
15.1k
Forks
3k
Merge medio
3 d 1 h
PR fusionados (30 d)
474

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

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 NVIDIA/TensorRT-LLM

Todos los issues de NVIDIA/TensorRT-LLM

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.