# Case Study: Millisecond Latency using Hugging Face Infinity and modern CPUs

huggingface.co · Philipp Schmid, Jeff Boudier, Morgan Funtowicz · Jan 13, 2022

**Type:** Benchmark

## Summary

Deploying large Transformer models at scale often faces severe prediction latency bottlenecks, driving up infrastructure costs and limiting real-time production use cases. To address this challenge, Hugging Face evaluated Infinity, a containerized hardware-optimized inference solution paired with the Infinity Multiverse model optimization service. Testing covered 192 configurations on Amazon EC2 C6i instances powered by 3rd generation Intel Xeon Scalable processors across varying CPU cores, sequence lengths, and batch sizes. The benchmarks demonstrated that an Ice Lake-optimized DistilBERT container achieved up to 800% higher throughput than vanilla Transformers and delivered 1 to 4 millisecond end-to-end latencies for sequence lengths up to 64 tokens. Although Infinity was later discontinued in favor of Inference Endpoints and Optimum libraries, the results demonstrated substantial efficiency gains on modern CPU hardware.

## Context

Deploying complex, large Transformer models in production at scale is constrained by prediction latency bottlenecks, which makes large deployments expensive and real-time use cases impractical.

## Approach / What changed

Hugging Face deployed Infinity, a containerized inference architecture consisting of the Infinity Container and Infinity Multiverse optimization service. They benchmarked an end-to-end pipeline (pre-processing, prediction, post-processing) using a DistilBERT sequence classification model on Amazon EC2 C6i instances with 3rd generation Intel Xeon Scalable processors (Ice Lake). Testing evaluated 192 configurations across physical CPU cores (1, 2, 4, 8), sequence lengths (8 to 512), and batch sizes (1 to 32).

## Takeaways

- The Ice Lake-optimized Infinity Container achieved up to 800% higher throughput and lower latency than vanilla Transformers on Ice Lake, and up to 34% improvement compared to Cascade Lake instances.
- When running on 2 physical cores with batch size 1, Infinity achieved throughput ranging from 248 requests per second at sequence length 8 to 12 requests per second at sequence length 512.
- Infinity achieved 1 to 4 millisecond latencies for sequence lengths up to 64 tokens and maintained minimal deviation between average latency and p95, p99, or maximum latency percentiles.

**Tags:** [AWS](https://yomu.fyi/topic/aws), [Docker](https://yomu.fyi/topic/docker), [Machine Learning](https://yomu.fyi/topic/machine-learning), [Performance](https://yomu.fyi/topic/performance)

[Read original post](https://huggingface.co/blog/infinity-cpu-performance)
