Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 11 min read How-to mediumAdept

Optimizing Bark using 🤗 Transformers

Bark, Suno's four-stage transformer text-to-speech model, can be made much cheaper to run in 🤗 Transformers with three one-line optimizations: Better Transformer (Flash Attention kernel fusion), fp16 half-precision, and CPU offload of idle sub-models via Accelerate. On a 100-iteration benchmark of bark-large on a TITAN RTX, combining all three cut latency 23% and memory 80% (5 GB to about 1 GB) at batch size 1. At batch size 8, fp16 roughly halves latency and nearly doubles throughput. Better Transformer is effectively free, while offload trades about 10% speed for large memory savings.

Assumes: PyTorch basicsHugging Face TransformersGPU inference

Related posts

  • How Together AI built the world’s fastest speech-to-text stack

    Together AI hardMaster

    Speech-to-text serving is a full-path systems problem, because ASR models are small while audio inputs are large and need heavy CPU preprocessing. Together optimized Parakeet-TDT 0.6B v3 and Whisper Large v3 at each layer of that path. Multi-profile TensorRT engines tune the encoder for real audio shapes instead of padding short chunks. Conditional CUDA graph nodes move the decoder's BLANK-token branch onto the GPU, making the decoder 2-3x faster. Persistent Unix domain sockets, shared memory and fewer process hops cut copy overhead, epoll replaces thread-per-connection streaming to tame GIL contention, and gc.freeze() after startup preallocation removed periodic ~200 ms p95 spikes caused by full Python GC passes.

  • Blazingly fast whisper transcriptions with Inference Endpoints

    Hugging Face easyNovice

    Hugging Face Inference Endpoints now offers a Whisper deployment built on vLLM that delivers up to roughly 8x higher real-time factor (RTFx) than the Transformers implementation, with comparable word error rate. It targets NVIDIA Ada Lovelace GPUs (L4, L40s) and gets its speedup from torch.compile JIT kernels, CUDA graphs that batch GPU kernel launches, and a float8 KV cache that halves cache memory versus bfloat16. Whisper Large V3, V3-Turbo and Distil-Whisper V3.5 were benchmarked for WER on 8 Open ASR Leaderboard datasets and for RTFx on 45+ minute rev16 audio using a single L4. Deployment is one click, and the endpoint is called through an OpenAI-style /audio/transcriptions HTTP API; a FastRTC demo shows real-time transcription.

  • Transcribe speech 100x faster and 100x cheaper with open models

    Modal mediumAdept

    Open-weights ASR models such as NVIDIA's parakeet-tdt-0.6b-v2 and canary-1b-flash, deployed as a batch transcription service on Modal GPUs, transcribed about a week of ESB benchmark audio in roughly a minute for about $1. That works out to over 100x faster or up to 200x cheaper than a popular proprietary API, at matching or slightly lower WER. The gains come from measuring end-to-end throughput including cold starts and data transfer, shuffling files before dealing them into requests to balance load across workers, and sorting audio by duration within each GPU worker so batch lanes finish together. Parallel threaded downloads also help. Sweeping GPU type and worker count produces a Pareto frontier of cost-versus-speed configurations rather than a single optimum.

  • Accelerated Inference with Optimum and Transformers Pipelines

    Hugging Face mediumAdept

    Optimum 1.2 adds inference support via ONNX Runtime with ORTModelForXxx classes that drop into Hugging Face Transformers pipelines in place of AutoModelForXxx. An end-to-end tutorial converts deepset/roberta-base-squad2 to ONNX, applies graph optimization (operator fusion, constant folding) with ORTOptimizer, then dynamic int8 quantization with ORTQuantizer targeting AVX512-VNNI on an m5.xlarge. Quantization shrinks the model from 473MB to 292MB while keeping 99.61% of original accuracy on SQuAD v2 (F1 81.83 vs 82.15), and latency is then benchmarked at sequence length 128.

  • Accelerating PyTorch Transformers with Intel Sapphire Rapids - part 2

    Hugging Face mediumAdept

    Intel Sapphire Rapids CPUs with AMX instructions, combined with Hugging Face Optimum Intel running in bfloat16 with JIT compilation, cut p99 inference latency for DistilBERT, BERT and RoBERTa text classification by roughly 3x compared with vanilla Transformers on Ice Lake. The benchmark uses EC2 c6i.16xlarge and r7iz.16xlarge-metal instances, short (16-token) and long (128-token) inputs, single and batch-of-8 predictions, and libtcmalloc. Optimum needs only a small wrapper around the existing pipeline code, and the results show single-digit millisecond latency on long sequences without a GPU.

The quest for software engineering knowledge.

Look:
Layout: