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

オープン 初心者向け
#21,218 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Gloria72 がすでに取り組んでいます。

2026年10月29日 から。

  • #21303 @Gloria72 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

tensorrt_llm/_torch/autotuner.py の _deserialize_cache_data から始めます。ここでは、警告のキーとして tactic の raw 値が渡されています。tensorrt_llm/logger.py の Logger.log_once を読んで、キーが hashable である必要があることを確認し、既存の AutoTuner のデシリアライズテストを確認します。リストまたは辞書の tactic エントリが意図された警告とともにスキップされ、キャッシュの残りの部分は引き続き読み込める状態になれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
15.1k
フォーク
3k
平均マージ
3日 1時間
マージ済み PR(30日)
474

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NVIDIA/TensorRT-LLM のほかの issue

NVIDIA/TensorRT-LLM の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。