Skip to content

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

Hugging Face 9 min read How-to hardMaster

Incredibly Fast BLOOM Inference with DeepSpeed and Accelerate

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.

Related posts

  • Optimization story: Bloom inference

    Hugging Face hardMaster

    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.

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

  • Accelerate Large Model Training using DeepSpeed

    Hugging Face mediumAdept

    Hugging Face Accelerate can enable DeepSpeed ZeRO data parallelism, which shards optimizer states, gradients and parameters across GPUs and optionally offloads them to CPU, with no or minimal code changes. On two 24GB Titan RTX GPUs, ZeRO Stage-2 allowed 5x larger batches than DDP for DeBERTa-XL (900M) and gave about a 3.5x training speedup with no accuracy loss. BlenderBot-400M fine-tuning saw 2x batch size and a ~1.44x training speedup. ZeRO Stage-3 with CPU offload made GPT-2 XL (1.5B) trainable at batch size 16 where DDP ran out of memory even at batch size 1. The post includes the accelerate config, DeepSpeed JSON configs, and the DummyOptim/DummyScheduler changes needed when the optimizer and scheduler are defined in the DeepSpeed config.

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