---
title: "Text-Generation Pipeline on Intel® Gaudi® 2 AI Accelerator"
description: "Optimum Habana's custom GaudiTextGenerationPipeline runs Llama 2 text generation (7b, 13b, 70b) on Intel Gaudi 2 with a few lines of code, handling pre- and post-processing end to end."
url: "https://swe.quest/articles/text-generation-pipeline-on-intel-gaudi-2-ai-accelerator-08fe7776346f5b95"
canonical: "https://huggingface.co/blog/textgen-pipe-gaudi"
source: "Hugging Face"
published: "2024-02-29"
difficulty: "medium"
kind: "How-to"
reading_minutes: 6
tags: ["inference","llms","hardware","python"]
---

# Text-Generation Pipeline on Intel® Gaudi® 2 AI Accelerator

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2024-02-29, 6 min read, How-to. Original: [https://huggingface.co/blog/textgen-pipe-gaudi](https://huggingface.co/blog/textgen-pipe-gaudi)

## Summary

Optimum Habana's custom GaudiTextGenerationPipeline runs Llama 2 text generation (7b, 13b, 70b) on Intel Gaudi 2 with a few lines of code, handling pre- and post-processing end to end. Setup covers gated-model access, pinned versions of optimum-habana and Habana's DeepSpeed fork, and CLI runs with HPU graphs, KV cache and sampling parameters. Llama-2-70b uses DeepSpeed across 8 devices. The pipeline can also be embedded in Python scripts or wrapped by LangChain's HuggingFacePipeline, validated only against LangChain 0.0.191.

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)
- [Hardware](https://swe.quest/tags/hardware.md) (Infrastructure)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- Python ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- Hugging Face transformers basics
- LLM sampling parameters ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))

## Keywords

Intel Gaudi 2, Optimum Habana, Llama 2, DeepSpeed, LangChain, SynapseAI

## Related posts

- [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.
- [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.
- [Hugging Face Text Generation Inference available for AWS Inferentia2](https://swe.quest/articles/hugging-face-text-generation-inference-available-for-aws-inferentia2-4404accc08bd48f1.md): Hugging Face · 2024-02-01 · Medium · 7 min read · Inference & serving, LLMs, Cloud platforms, Python
  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.
- [Optimize and deploy with Optimum-Intel and OpenVINO GenAI](https://swe.quest/articles/optimize-and-deploy-with-optimum-intel-and-openvino-genai-bbd6caef1a74949e.md): Hugging Face · 2024-09-20 · Medium · 6 min read · Inference & serving, LLMs, C & C++, Python
  Hugging Face Transformers LLMs can be exported to OpenVINO IR with Optimum-Intel, quantized with NNCF, and deployed through the lightweight OpenVINO GenAI LLMPipeline from Python or C++.
- [Building Cost-Efficient Enterprise RAG applications with Intel Gaudi 2 and Intel Xeon](https://swe.quest/articles/building-cost-efficient-enterprise-rag-applications-with-intel-gaudi-2-and-b583c6eb9fcf2d2e.md): Hugging Face · 2024-05-09 · Medium · 8 min read · RAG & retrieval, Inference & serving, Hardware, Cost optimization, LLMs
  A RAG chatbot built with LangChain's rag-redis template runs BAAI/bge-base-en-v1.5 embeddings on Intel Granite Rapids Xeon CPUs, Redis as the vector store, and an LLM served by Hugging Face TGI on Gaudi 2.

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)
