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

Open
#22,906 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@lminer is already working on this.

Since Oct 26, 2026.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
12/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
python, pytorch

Research direction

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.

Written by the indexing model from the issue text.

Description

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.
Dominant language
Python
Stars
15.2k
Forks
3k
Avg merge
2d 21h
Merged PRs (30d)
477

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NVIDIA/TensorRT-LLM

All issues in NVIDIA/TensorRT-LLM

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.