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

Đang mở
#22,906 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@lminer đang làm issue này rồi.

Từ ngày 26/10/2026.

  • #21045 của @lminer — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
12/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python, pytorch
Lĩnh vực
ai-infra-agents

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
Python
Star
15.2k
Fork
3k
Merge trung bình
2 ngày 21 giờ
Pull request đã merge (30 ngày)
477

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NVIDIA/TensorRT-LLM

Tất cả issue của NVIDIA/TensorRT-LLM

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.