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

Aperta
#22,906 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@lminer ci sta già lavorando.

Dal 26/10/2026.

  • #21045 di @lminer — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
12/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python, pytorch

Direzione di ricerca

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.

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

Descrizione

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.
Lingua principale
Python
Stelle
15.2k
Fork
3k
Merge medio
2g 21h
PR unite (30g)
477

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.