Skip to content

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

Hugging Face 10 min read How-to mediumAdept

Benchmarking Text Generation Inference

Text Generation Inference ships a benchmarking tool that profiles LLM serving across batch sizes, plotting throughput against latency separately for prefill and decode so deployments can be tuned for a workload such as RAG or chat. Using a duplicable Hugging Face Space bundling TGI with JupyterLab, the walkthrough shows how to read the charts. Vertical regions mean added batch size buys throughput at no latency cost. Horizontal regions mean the server is compute bound: in the example, decode latency stayed flat near 5.3s up to batch 32, while prefill beyond 32 doubled TTFT with no throughput gain. The recommended loop is to benchmark on hardware matching production, adjust TGI launch settings, and repeat, checking real user token patterns in TGI logs.

Related posts

  • Boost your throughput with dynamic batching

    Modal mediumAdept

    Modal added a `@modal.batched()` decorator that groups incoming requests into batches flushed when either `max_batch_size` is reached or `wait_ms` elapses, avoiding the unbounded waits of fixed-size batching. Batching helps GPU inference because model weights (over 6 GB for Whisper large v3) must be moved from memory to compute units per pass, and inference is usually memory-bandwidth bound. On an A10G, batching Whisper with a max batch size of 64 raised throughput from about 1.2 to 3.3 requests per second per container, cutting inference cost by roughly 65%. The function only needs to accept and return lists.

  • Optimizing inference speed and costs: Lessons learned from large-scale deployments

    Together AI easyNovice

    Lower LLM inference latency and cost come mainly from how inference runs rather than from buying more GPUs. The levers covered are FP8/FP4 quantization (claimed 20–40% throughput gains), distilled models like DeepSeek-R1 variants (2–5× lower cost), regional proxies that cut 50–100 ms of TTFT, removing GPU stalls via kernel fusion, MoE execution and scheduling, and speculative decoding or MTP (20–50% faster decode). It also covers Blackwell-class hardware with tensor or expert parallelism and dynamically shifting GPU capacity between endpoints. A starting checklist: measure TTFT, decode TPS and network RTT, then add proxies, continuous batching and decoding optimizations.

  • Benchmarking inference at scale: coding agents

    Together AI hardMaster

    On a long-context, high-concurrency coding agent workload (prompts ~45k–200k tokens, ~450-token outputs, EAGLE speculative decoding) running Kimi K2.5 on B200 GPUs, Together Inference Engine delivers 31% more per-user TPS than TensorRT-LLM at 2.5M TPM. It holds p50 TTFT at 0.71s, versus 1.1s for TensorRT-LLM and 5.1s for SGLang, which needed 8 GPUs instead of 4 due to EAGLE memory overhead. The gains are attributed to ThunderMLA, a fused megakernel for Multi-head Latent Attention reported as 20–35% faster than FlashMLA, plus custom kernels found through end-to-end profiling. The post argues that prefill-heavy, concurrent long-context load and TTFT under saturation matter more than single-user benchmarks, and closes with vendor cost comparisons against Claude Opus.

  • Prefill and Decode for Concurrent Requests - Optimizing LLM Performance

    Hugging Face mediumAdept

    LLM token generation splits into a compute-bound prefill phase, which processes all prompt tokens in parallel to produce the first token, and a memory-bandwidth-bound decode phase, which produces later tokens one at a time. These map to time to first token and time per output token. Static batching leaves the GPU underutilized and delays new requests. Prefill-first continuous batching (vLLM, TGI) minimizes time to first token but pauses running decodes. Chunked prefill interleaves prefill chunks with decode steps, trading a small time-to-first-token increase for smoother decoding. At TNG it raised total throughput by about 50%, and the default chunk size is recommended when load patterns are unpredictable.

  • Make your llama generation time fly with AWS Inferentia2

    Hugging Face mediumAdept

    optimum-neuron can now compile and export Llama 2 models for text generation on AWS Inferentia2, using static input shapes (batch size, 2048 sequence length that also bounds the KV cache) and a configurable core count and fp16 precision. Compiled models can be saved or pushed to the Hub and used via transformers-style generate() or optimum-neuron pipelines, supporting greedy search and top-k/top-p sampling. Benchmarks on inf2.48xlarge show Llama 2 7B encoding 256 tokens in about 0.5s, with throughput up to 750 tokens/s at batch size 4, while a 2-core 'budget' config on inf2.xlarge manages about 22–32 tokens/s. Latency is fairly insensitive to batch size, but throughput is capped by device memory and the static sequence length limits long contexts.

The quest for software engineering knowledge.

Look:
Layout: