---
title: "Hugging Face Text Generation Inference available for AWS Inferentia2"
description: "Text Generation Inference (TGI) is now generally available on AWS Inferentia2 through Amazon SageMaker, offering an alternative to GPUs for serving open LLMs such as Llama and Mistral."
url: "https://swe.quest/articles/hugging-face-text-generation-inference-available-for-aws-inferentia2-4404accc08bd48f1"
canonical: "https://huggingface.co/blog/text-generation-inference-on-inferentia2"
source: "Hugging Face"
published: "2024-02-01"
difficulty: "medium"
kind: "How-to"
reading_minutes: 7
tags: ["inference","llms","cloud","python"]
---

# Hugging Face Text Generation Inference available for AWS Inferentia2

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2024-02-01, 7 min read, How-to. Original: [https://huggingface.co/blog/text-generation-inference-on-inferentia2](https://huggingface.co/blog/text-generation-inference-on-inferentia2)

## Summary

Text Generation Inference (TGI) is now generally available on AWS Inferentia2 through Amazon SageMaker, offering an alternative to GPUs for serving open LLMs such as Llama and Mistral. A walkthrough deploys Zephyr 7B on an ml.inf2.8xlarge using the TGI Neuronx container. Because Inferentia2 lacks dynamic shapes, batch size, sequence length, core count and cast type must be fixed at compile time. A neuron model cache provides pre-compiled configurations; compiling an uncached one with optimum-cli can take up to 45 minutes. The deployment environment variables (HF\_NUM\_CORES, HF\_BATCH\_SIZE, HF\_SEQUENCE\_LENGTH, MAX\_TOTAL\_TOKENS) must match those compile-time settings.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Cloud platforms](https://swe.quest/tags/cloud.md) (Infrastructure)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- Amazon SageMaker basics
- LLM inference concepts ([easy posts on Inference & serving](https://swe.quest/tags/inference.md?difficulty=easy))
- Python ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))

## Keywords

Text Generation Inference, AWS Inferentia2, Amazon SageMaker, Zephyr 7B, Optimum Neuron, AWS Neuron

## Related posts

- [Make your llama generation time fly with AWS Inferentia2](https://swe.quest/articles/make-your-llama-generation-time-fly-with-aws-inferentia2-bc8b5e1981a590c0.md): Hugging Face · 2023-11-07 · Medium · 7 min read · Inference & serving, LLMs, Hardware, Cloud platforms, Performance engineering
  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.
- [Introducing the Hugging Face LLM Inference Container for Amazon SageMaker](https://swe.quest/articles/introducing-the-hugging-face-llm-inference-container-for-amazon-sagemaker-49df0e101e3d8d72.md): Hugging Face · 2023-05-31 · Medium · 8 min read · Inference & serving, LLMs, Cloud platforms, Python
  Hugging Face's LLM Inference Deep Learning Container for Amazon SageMaker is built on Text Generation Inference (TGI), which provides tensor parallelism, continuous batching, flash-attention, bitsandbytes quantization, safetensors loading and SSE token streaming.
- [Accelerating Hugging Face Transformers with AWS Inferentia2](https://swe.quest/articles/accelerating-hugging-face-transformers-with-aws-inferentia2-732d2daf15bc9874.md): Hugging Face · 2023-04-17 · Easy · 5 min read · Inference & serving, Hardware, Performance engineering, Cloud platforms
  Hugging Face benchmarked popular Transformer models on AWS Inferentia2 (inf2.xlarge) against Inferentia1 (inf1.2xlarge) and an NVIDIA A10G GPU (g5.2xlarge), running 144 p95-latency experiments at batch size 1 across six architectures and sequence lengths from 8 to 512.
- [How to deploy and fine-tune DeepSeek models on AWS](https://swe.quest/articles/how-to-deploy-and-fine-tune-deepseek-models-on-aws-e64f345de2597515.md): Hugging Face · 2025-01-30 · Medium · 8 min read · Inference & serving, Cloud platforms, LLMs, Python
  DeepSeek-R1's distilled Llama and Qwen models can be deployed on AWS through Hugging Face Inference Endpoints, Bedrock Marketplace, SageMaker with Hugging Face LLM DLCs (TGI v3) on GPUs or Neuron, and EC2 Inferentia via the Hugging Face Neuron AMI.
- [Inference for PROs](https://swe.quest/articles/inference-for-pros-8849074774f039ec.md): Hugging Face · 2023-09-22 · Medium · 10 min read · Inference & serving, LLMs, API design, Python
  Hugging Face PRO subscribers get curated, rate-limit-boosted HTTP inference endpoints served by text-generation-inference for models such as Llama 3, Mixtral 8x7B, Zephyr, Code Llama, Stable Diffusion XL and Bark, intended for prototyping rather than heavy production (Inference Endpoints is recommended for that).

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)
