Skip to content

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

Hugging Face 22 min read Case study hardMaster

Optimization story: Bloom inference

Hugging Face's BLOOM (176B parameters, 352GB in bf16) inference server reached 5x lower latency and 50x higher throughput over several weeks, starting from 0.3 req/s and 350ms/token on 16xA100 40GB with pipeline parallelism via Accelerate's device_map="auto". A FLOPs estimate (~17 TFLOP per forward pass, a theoretical floor of about 3ms/token) showed how far off that baseline was. The team weighed tensor parallelism against pipeline parallelism and tried a JAX/Flax port on TPUs, ONNX/TensorRT and DeepSpeed. Lessons include using small test models and fixed greedy-generation prompt suites to catch numerical drift, and staying within PyTorch for flexibility after DeepSpeed proved unstable under webserver load.

Related posts

  • Incredibly Fast BLOOM Inference with DeepSpeed and Accelerate

    Hugging Face hardMaster

    Running the 176B-parameter BLOOM model (352GB in bf16) for inference is benchmarked across HuggingFace Accelerate, DeepSpeed-Inference and DeepSpeed ZeRO-Inference on an 8x80GB A100 node, with 8-bit quantized variants via BitsAndBytes and DeepSpeed. DeepSpeed-Inference reaches under 1 ms per token at batch size 128, thanks to tensor parallelism and fused CUDA kernels, and its pre-sharded checkpoints load in about a minute. Accelerate's naive pipeline parallelism leaves most GPUs idle but works with almost any model, and it offloads to CPU or disk when GPU memory runs out. ZeRO can run independent streams on each GPU, and int8 halves the memory needed (4 GPUs suffice) at a modest throughput cost. Setup and run commands for each approach are included.

  • Fast Inference on Large Language Models: BLOOMZ on Habana Gaudi2 Accelerator

    Hugging Face mediumAdept

    BLOOMZ (176B parameters, 352 GB in 16-bit) runs inference on a single 8-HPU Habana Gaudi2 server using Optimum Habana with Habana's DeepSpeed-inference fork, HPU graphs and a KV cache. In batch-1 greedy generation of 100 tokens, Gaudi2 is 1.42x faster than an 8x A100 80GB setup on the 176B model (3.1 s vs 4.4 s) and 2.89x faster on BLOOMZ-7B. Unlike A100, Gaudi2 benefits from model parallelism on the 7B model. First-gen Gaudi (AWS DL1, about $13/hr) offers better price-performance than A100 for the 7B checkpoint, and the post includes commands to reproduce the benchmark or run generation over any Hugging Face dataset.

  • 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.

  • The Technology Behind BLOOM Training

    Hugging Face hardMaster

    BLOOM, a 176B-parameter multilingual GPT-3-style model, was trained over 3.5 months on 384 A100 80GB GPUs on the Jean Zay supercomputer using Megatron-DeepSpeed's 3D parallelism. ZeRO data parallelism shards parameters, gradients and optimizer states across GPUs. Megatron-LM tensor parallelism splits GEMMs column-wise then row-wise, needing two all-reduces per layer, so it should stay within a single node's fast interconnect. Pipeline parallelism uses micro-batches (chunks/GAS) to shrink the idle bubble, with global batch size computed as mbs*chunks*dp_degree. Hardware, checkpoint sizes (2.3TB full, 329GB bf16 weights) and dataset details are also covered.

  • Optimizing your LLM in production

    Hugging Face mediumAdept

    Serving billion-parameter LLMs efficiently comes down to three levers: lower precision, Flash Attention, and inference-friendly architectures such as ALiBi, rotary embeddings, Multi-Query Attention and Grouped-Query Attention. Weights need roughly 2 GB of VRAM per billion parameters in bfloat16, and measurements on OctoCoder (~15B parameters) show peak memory dropping from about 29 GB in bfloat16 to 15 GB with 8-bit and 9.5 GB with 4-bit bitsandbytes quantization, with little output change but slightly slower inference. Flash Attention addresses self-attention's quadratic memory growth with sequence length by restructuring the computation to make better use of GPU memory. Code examples in Hugging Face Transformers accompany each technique.

The quest for software engineering knowledge.

Look:
Layout: