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

Aperta Adatta ai principianti
#21,218 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Gloria72 ci sta già lavorando.

Dal 29/10/2026.

  • #21303 di @Gloria72 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Inizia in tensorrt_llm/_torch/autotuner.py, in corrispondenza di _deserialize_cache_data, dove l’avviso passa il valore raw di tactic come chiave. Leggi Logger.log_once in tensorrt_llm/logger.py per confermare che la chiave deve essere hashable, quindi verifica se esistono già test di deserializzazione di AutoTuner. Il lavoro è completato quando le voci tactic di tipo lista o dizionario vengono ignorate con l’avviso previsto e il resto della cache può ancora essere caricato.

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

Descrizione

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.

Lingua principale
Python
Stelle
15.1k
Fork
3k
Merge medio
3g 1h
PR unite (30g)
474

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

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

Tutte le issue di NVIDIA/TensorRT-LLM

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.