Views
No views yet
openai/whisper-small designed for NVIDIA GPUs. It achieves up to 4x speedup compared to the baseline by leveraging:static cache.fp32 eager mode.torch.compile.1import torch
2from transformers import WhisperForConditionalGeneration, WhisperProcessor
3
4model_id = "YOUR_USERNAME/YOUR_REPO_NAME" # <--- REPLACE THIS
5
6# 1. Load Model
7model = WhisperForConditionalGeneration.from_pretrained(
8 model_id,
9 torch_dtype=torch.float16,
10 attn_implementation="sdpa", # Flash Attention
11 device_map="cuda"
12)
13
14# 2. Enable CUDA Graphs (The Magic Step)
15model.generation_config.cache_implementation = "static"
16model = torch.compile(model, mode="reduce-overhead", fullgraph=True)
17
18# 3. Run Inference
19processor = WhisperProcessor.from_pretrained(model_id)
20# ... standard generation code ...