Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

serve

> DevOps
Open source

Serve, optimize and scale PyTorch models in production

4.3K stars0 likes2 views
WebsiteGitHub

About

Serve, optimize and scale PyTorch models in production

⚠️ Notice: Limited Maintenance

This project is no longer actively maintained. While existing releases remain available, there are no planned updates, bug fixes, new features, or security patches. Users should be aware that vulnerabilities may not be addressed.

❗ANNOUNCEMENT: Security Changes❗

TorchServe now enforces token authorization enabled and model API control disabled by default. These security features are intended to address the concern of unauthorized API calls and to prevent potential malicious code from being introduced to the model server. Refer the following documentation for more information: Token Authorization, Model API control

TorchServe

TorchServe is a flexible and easy-to-use tool for serving and scaling PyTorch models in production.

Requires python >= 3.8

bash
curl http://127.0.0.1:8080/predictions/bert -T input.txt

Quick start with TorchServe

bash
# Install dependencies
python ./ts_scripts/install_dependencies.py

# Include dependencies for accelerator support with the relevant optional flags
python ./ts_scripts/install_dependencies.py --rocm=rocm61
python ./ts_scripts/install_dependencies.py --cuda=cu121

# Latest release
pip install torchserve torch-model-archiver torch-workflow-archiver

# Nightly build
pip install torchserve-nightly torch-model-archiver-nightly torch-workflow-archiver-nightly

Quick start with TorchServe (conda)

bash
# Install dependencies
python ./ts_scripts/install_dependencies.py

# Include depeendencies for accelerator support with the relevant optional flags
python ./ts_scripts/install_dependencies.py --rocm=rocm61
python ./ts_scripts/install_dependencies.py --cuda=cu121

# Latest release
conda install -c pytorch torchserve torch-model-archiver torch-workflow-archiver

# Nightly build
conda install -c pytorch-nightly torchserve torch-model-archiver torch-workflow-archiver

Getting started guide

Quick Start with Docker

bash
# Latest release
docker pull pytorch/torchserve

# Nightly build
docker pull pytorch/torchserve-nightly

Refer to torchserve docker for details.

Quick Start LLM Deployment

VLLM Engine

bash
# Make sure to install torchserve with pip or conda as described above and login with `huggingface-cli login`
python -m ts.llm_launcher --model_id meta-llama/Llama-3.2-3B-Instruct --disable_token_auth

# Try it out
curl -X POST -d '{"model":"meta-llama/Llama-3.2-3B-Instruct", "prompt":"Hello, my name is", "max_tokens": 200}' --header "Content-Type: application/json" "http://localhost:8080/predictions/model/1.0/v1/completions"

TRT-LLM Engine

bash
# Make sure to install torchserve with python venv as described above and login with `huggingface-cli login`
# pip install -U --use-deprecated=legacy-resolver -r requirements/trt_llm.txt
python -m ts.llm_launcher --model_id meta-llama/Meta-Llama-3.1-8B-Instruct --engine trt_llm --disable_token_auth

# Try it out
curl -X POST -d '{"prompt":"count from 1 to 9 in french ", "max_tokens": 100}' --header "Content-Type: application/json" "http://localhost:8080/predictions/model"

Quick Start LLM Deployment with Docker

bash
#export token=<HUGGINGFACE_HUB_TOKEN>
docker build --pull . -f docker/Dockerfile.vllm -t ts/vllm

docker run --rm -ti --shm-size 10g --gpus all -e HUGGING_FACE_HUB_TOKEN=$token -p 8080:8080 -v data:/data ts/vllm --model_id meta-llama/Meta-Llama-3-8B-Instruct --disable_token_auth

# Try it out
curl -X POST -d '{"model":"meta-llama/Meta-Llama-3-8B-Instruct", "prompt":"Hello, my name is", "max_tokens": 200}' --header "Content-Type: application/json" "http://localhost:8080/predictions/model/1.0/v1/completions"

Refer to LLM deployment for details and other methods.

⚡ Why TorchServe

  • Write once, run anywhere, on-prem, on-cloud, supports inference on CPUs, GPUs, AWS Inf1/Inf2/Trn1, Google Cloud TPUs, Nvidia MPS
  • Model Management API: multi model management with optimized worker to model allocation
  • Inference API: REST and gRPC support for batched inference
  • TorchServe Workflows: deploy complex DAGs with multiple interdependent models
  • Default way to serve PyTorch models in
    • Sagemaker
    • Vertex AI
    • Kubernetes with support for autoscaling, session-affinity, monitoring using Grafana works on-prem, AWS EKS, Google GKE, Azure AKS
    • Kserve: Supports both v1 and v2 API, autoscaling and canary deployments for A/B testing
    • Kubeflow
    • MLflow
  • Export your model for optimized inference. Torchscript out of the box, PyTorch Compiler preview, ORT and ONNX, IPEX, TensorRT, FasterTransformer, FlashAttention (Better Transformers)
  • Performance Guide: builtin support to optimize, benchmark, and profile PyTorch and TorchServe performance
  • Expressive handlers: An expressive handler architecture that makes it trivial to support inferencing for your use case with many supported out of the box
  • Metrics API: out-of-the-box support for system-level metrics with Prometheus exports, custom metrics,
  • Large Model Inference Guide: With support for GenAI, LLMs including
    • SOTA GenAI performance using torch.compile
    • Fast Kernels with FlashAttention v2, continuous batching and streaming response
    • PyTorch Tensor Parallel preview, Pipeline Parallel
    • Microsoft DeepSpeed, DeepSpeed-Mii
    • Hugging Face Accelerate, Diffusers
    • Running large models on AWS Sagemaker and Inferentia2
    • Running Meta Llama Chatbot locally on Mac
  • Monitoring using Grafana and Datadog

How does TorchServe work

  • Model Server for PyTorch Documentation: Full documentation
  • TorchServe internals: How TorchServe was built
  • Contributing guide: How to contribute to TorchServe

Highlighted Examples

  • Serving Meta Llama with TorchServe
  • Chatbot with Meta Llama on Mac
  • HuggingFace Transformers with a Better Transformer Integration/ Flash Attention & Xformer Memory Efficient
  • Stable Diffusion
  • Model parallel inference
  • MultiModal models with MMF combining text, audio and video
  • Dual Neural Machine Translation for a complex workflow DAG
  • TorchServe Integrations
  • TorchServe Internals
  • TorchServe UseCases

For more examples

️ TorchServe Security Policy

SECURITY.md

Learn More

https://pytorch.org/serve

Contributing

We welcome all contributions!

To learn more about how to contribute, see the contributor guide here.

News

  • High performance Llama 2 deployments with AWS Inferentia2 using TorchServe
  • Naver Case Study: Transition From High-Cost GPUs to Intel CPUs and oneAPI powered Software with performance
  • Run multiple generative AI models on GPU using Amazon SageMaker multi-model endpoints with TorchServe and save up to 75% in inference costs
  • Deploying your Generative AI model in only four steps with Vertex AI and PyTorch
  • PyTorch Model Serving on Google Cloud TPU v5
  • Monitoring using Datadog
  • Torchserve Performance Tuning, Animated Drawings Case-Study
  • Walmart Search: Serving Models at a Scale on TorchServe
  • Scaling inference on CPU with TorchServe
  • TorchServe C++ backend
  • Grokking Intel CPU PyTorch performance from first principles: a TorchServe case study
  • Grokking Intel CPU PyTorch performance from first principles( Part 2): a TorchServe case study
  • Case Study: Amazon Ads Uses PyTorch and AWS Inferentia to Scale Models for Ads Processing
  • Optimize your inference jobs using dynamic batch inference with TorchServe on Amazon SageMaker
  • Using AI to bring children's drawings to life
  • Model Serving in PyTorch
  • Evolution of Cresta's machine learning architecture: Migration to AWS and PyTorch
  • Explain Like I’m 5: TorchServe
  • How to Serve PyTorch Models with TorchServe
  • [How to deploy PyTorch models on Vertex AI](https://cloud.google.com/blog/topics/developers-practitioners/pytorch-google-

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Javacpudeep-learningdockergpu

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理