[Feature]: PyTorch backend: let a Whisper request carry a precomputed log-mel spectrogram

オープン
#22,906 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

2026年10月26日 から。

  • #21045 @lminer による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
12/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python, pytorch

調査の方向性

The request path for audio items lives in WhisperInputProcessor, which pads audio to the 30-second window before the encoder computes the log-mel spectrogram; WhisperEncoder.forward already accepts a precomputed spectrogram. Read how the processor handles the audio item, then check the shape validation against num_mel_bins. Done means a request with an input_features item reaches the encoder without recomputing mel and is rejected cleanly on wrong shapes, but this issue already has a linked open pull request (#21045) implementing it.

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

説明

Pytorch
🚀 The feature, motivation and pitch

On the PyTorch backend, a Whisper request can only carry audio: a file path or URL, an (array, sample_rate) tuple, or an {"array", "sampling_rate"} mapping. WhisperInputProcessor pads it to the 30-second window and the engine computes the log-mel spectrogram itself.

Some clients already have the spectrogram, because feature extraction runs elsewhere in their pipeline or is shared between models. They have no way to send it, so the audio has to be kept around and the log-mel computed a second time. WhisperEncoder.forward already accepts a spectrogram and skips the log-mel step for it; only the request path is missing.

The request: let the audio item be {"input_features": ...}, the array the checkpoint's WhisperFeatureExtractor returns for one window, as numpy or torch.

  • Each request picks its form by its item, so one LLM serves audio and spectrogram requests, also in the same batch. Nothing is configured on the LLM.
  • The shape is checked against the checkpoint (num_mel_bins by the extractor's frame count), and other shapes are rejected with a clear message.
  • A spectrogram that is already on the GPU stays there.
  • Encoder CUDA graphs, the decoder prompt and the max_tokens cap work the same way for both forms.
mel = extractor(wave, sampling_rate=sample_rate, truncation=False, return_tensors="np")["input_features"]
llm.generate([
    {"prompt": "", "multi_modal_data": {"audio": [(wave, sample_rate)]}},
    {"prompt": "", "multi_modal_data": {"audio": {"input_features": mel}}},
])
Alternatives
  • Choosing the form once per LLM. That forces a deployment to pick one form and to run two instances to serve both.
  • Sending the audio and letting the engine recompute the spectrogram, as today. That works, but repeats work the client has done and requires keeping the audio.
Additional context

#21045 implements this.

Before submitting a new issue...
  • Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.
主要言語
Python
スター
15.2k
フォーク
3k
平均マージ
2日 21時間
マージ済み PR(30日)
477

環境構築

Codespaces で開く

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

はじめの一歩

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

NVIDIA/TensorRT-LLM のほかの issue

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

似ている issue

Python の issue をもっと見る

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

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