---
title: "Incredibly Fast BLOOM Inference with DeepSpeed and Accelerate"
description: "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."
url: "https://swe.quest/articles/incredibly-fast-bloom-inference-with-deepspeed-and-accelerate-7d1957ba474cbad5"
canonical: "https://huggingface.co/blog/bloom-inference-pytorch-scripts"
source: "Hugging Face"
published: "2022-09-16"
difficulty: "hard"
kind: "How-to"
reading_minutes: 9
tags: ["inference","llms","performance","hardware"]
---

# Incredibly Fast BLOOM Inference with DeepSpeed and Accelerate

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2022-09-16, 9 min read, How-to. Original: [https://huggingface.co/blog/bloom-inference-pytorch-scripts](https://huggingface.co/blog/bloom-inference-pytorch-scripts)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Hardware](https://swe.quest/tags/hardware.md) (Infrastructure)

## Prerequisites

- transformer LLM inference ([easy posts on Inference & serving](https://swe.quest/tags/inference.md?difficulty=easy))
- multi-GPU parallelism ([easy posts on Hardware](https://swe.quest/tags/hardware.md?difficulty=easy))
- CUDA GPUs

## Keywords

BLOOM, DeepSpeed-Inference, DeepSpeed ZeRO, HuggingFace Accelerate, BitsAndBytes, A100, tensor parallelism

## Related posts

- [Optimization story: Bloom inference](https://swe.quest/articles/optimization-story-bloom-inference-d6344942eb1d22f2.md): Hugging Face · 2022-10-12 · Hard · 22 min read · Inference & serving, LLMs, Performance engineering, Python
  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".
- [Fast Inference on Large Language Models: BLOOMZ on Habana Gaudi2 Accelerator](https://swe.quest/articles/fast-inference-on-large-language-models-bloomz-on-habana-gaudi2-accelerator-b18b18c9b1b881f4.md): Hugging Face · 2023-03-28 · Medium · 8 min read · Inference & serving, LLMs, Hardware, Performance engineering
  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.
- [Accelerate Large Model Training using DeepSpeed](https://swe.quest/articles/accelerate-large-model-training-using-deepspeed-d18dbe7623c821c0.md): Hugging Face · 2022-06-28 · Medium · 8 min read · Model training, Python, Performance engineering
  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.
- [The Technology Behind BLOOM Training](https://swe.quest/articles/the-technology-behind-bloom-training-8acc1cff08e9a54f.md): Hugging Face · 2022-07-14 · Hard · 25 min read · Model training, LLMs, Distributed systems, Hardware
  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.
- [Optimizing your LLM in production](https://swe.quest/articles/optimizing-your-llm-in-production-aa5bbb901928fa57.md): Hugging Face · 2023-09-15 · Medium · 31 min read · Inference & serving, LLMs, Performance engineering, Python
  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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
