Skip to content

Commit 6d20feb

Browse files
authored
Merge branch 'master' into master
2 parents bea187d + 7884a39 commit 6d20feb

19 files changed

+112
-35
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ dist/
1212
frontend/server/src/main/java/org/pytorch/serve/grpc/
1313
*.pem
1414
*.backup
15+
docs/sphinx/src/
1516

1617
# Postman files
1718
test/artifacts/

benchmarks/benchmark-ab.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def benchmark(test_plan, url, gpus, exec_env, concurrency, requests, batch_size,
104104
docker_torchserve_start()
105105

106106
check_torchserve_health()
107+
warm_up()
107108
run_benchmark()
108109
generate_report()
109110

@@ -123,12 +124,18 @@ def check_torchserve_health():
123124
time.sleep(3)
124125
failure_exit("Could not connect to Tochserve instance at " + execution_params['inference_url'])
125126

126-
127-
def run_benchmark():
127+
def warm_up():
128128
register_model()
129129

130-
click.secho("\n\nExecuting Apache Bench tests ...", fg='green')
131-
click.secho("*Executing inference performance test...", fg='green')
130+
click.secho("\n\nExecuting warm-up ...", fg='green')
131+
ab_cmd = f"ab -c {execution_params['concurrency']} -n {execution_params['requests']/10} -k -p {TMP_DIR}/benchmark/input -T " \
132+
f"{execution_params['content_type']} {execution_params['inference_url']}/{execution_params['inference_model_url']} > {result_file}"
133+
134+
execute(ab_cmd, wait=True)
135+
136+
137+
def run_benchmark():
138+
click.secho("\n\nExecuting inference perfromance tests ...", fg='green')
132139
ab_cmd = f"ab -c {execution_params['concurrency']} -n {execution_params['requests']} -k -p {TMP_DIR}/benchmark/input -T " \
133140
f"{execution_params['content_type']} {execution_params['inference_url']}/{execution_params['inference_model_url']} > {result_file}"
134141

@@ -480,4 +487,4 @@ def failure_exit(msg):
480487

481488

482489
if __name__ == '__main__':
483-
benchmark()
490+
benchmark()

docs/README.md

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,51 @@
11
# TorchServe
22

3-
TorchServe is a flexible and easy to use tool for serving PyTorch models.
3+
TorchServe is a performant, flexible and easy to use tool for serving PyTorch eager mode and torschripted models.
44

55
## Basic Features
66

77
* [Serving Quick Start](https://github.com/pytorch/serve/blob/master/README.md#serve-a-model) - Basic server usage tutorial
88
* [Model Archive Quick Start](https://github.com/pytorch/serve/tree/master/model-archiver#creating-a-model-archive) - Tutorial that shows you how to package a model archive file.
99
* [Installation](https://github.com/pytorch/serve/blob/master/README.md#install-torchserve) - Installation procedures
10-
* [Serving Models](server.md) - Explains how to use torchserve
11-
* [REST API](rest_api.md) - Specification on the API endpoint for TorchServe
10+
* [Serving Models](server.md) - Explains how to use TorchServe
11+
* [REST API](rest_api.md) - Specification on the API endpoint for TorchServe
12+
* [gRPC API](grpc_api.md) - TorchServe supports gRPC APIs for both inference and management calls
1213
* [Packaging Model Archive](https://github.com/pytorch/serve/tree/master/model-archiver#torch-model-archiver-for-torchserve) - Explains how to package model archive file, use `model-archiver`.
1314
* [Inference API](inference_api.md) - How to check for the health of a deployed model and get inferences
1415
* [Management API](management_api.md) - How to manage and scale models
1516
* [Logging](logging.md) - How to configure logging
1617
* [Metrics](metrics.md) - How to configure metrics
17-
* [Metrics API](metrics_api.md) - How to configure metrics API
18+
* [Prometheus and Grafana metrics](metrics_api.md) - How to configure metrics API with Prometheus formatted metrics in a Grafana dashboard
19+
* [Captum Explanations](https://github.com/pytorch/serve/blob/master/captum/Captum_visualization_for_bert.ipynb) - Built in support for Captum explanations for both text and images
1820
* [Batch inference with TorchServe](batch_inference_with_ts.md) - How to create and serve a model with batch inference in TorchServe
1921
* [Workflows](workflows.md) - How to create workflows to compose Pytorch models and Python functions in sequential and parallel pipelines
20-
* [Model Zoo](model_zoo.md) - List of pre-trained model archives ready to be served for inference with TorchServe.
21-
* [Examples](https://github.com/pytorch/serve/tree/master/examples) - Many examples of how to package and deploy models and workflows with TorchServe
2222

23-
## Advanced Features
2423

25-
* [Advanced configuration](configuration.md) - Describes advanced TorchServe configurations.
26-
* [Custom Service](custom_service.md) - Describes how to develop custom inference services.
27-
* [Unit Tests](https://github.com/pytorch/serve/tree/master/ts/tests#testing-torchserve) - Housekeeping unit tests for TorchServe.
28-
* [Benchmark](https://github.com/pytorch/serve/tree/master/benchmarks#torchserve-model-server-benchmarking) - Use JMeter to run TorchServe through the paces and collect benchmark data.
29-
* [TorchServe on Kubernetes](https://github.com/pytorch/serve/blob/master/kubernetes/README.md#torchserve-on-kubernetes) - Demonstrates a Torchserve deployment in Kubernetes using Helm Chart.
3024

3125
## Default Handlers
3226

3327
* [Image Classifier](https://github.com/pytorch/serve/blob/master/ts/torch_handler/image_classifier.py) - This handler takes an image and returns the name of object in that image
3428
* [Text Classifier](https://github.com/pytorch/serve/blob/master/ts/torch_handler/text_classifier.py) - This handler takes a text (string) as input and returns the classification text based on the model vocabulary
3529
* [Object Detector](https://github.com/pytorch/serve/blob/master/ts/torch_handler/object_detector.py) - This handler takes an image and returns list of detected classes and bounding boxes respectively
3630
* [Image Segmenter](https://github.com/pytorch/serve/blob/master/ts/torch_handler/image_segmenter.py)- This handler takes an image and returns output shape as [CL H W], CL - number of classes, H - height and W - width
31+
32+
## Examples
33+
34+
* [HuggingFace Language Model](https://github.com/pytorch/serve/blob/master/examples/Huggingface_Transformers/Transformer_handler_generalized.py) - This handler takes an input sentence and can return sequence classifications, token classifications or Q&A answers
35+
* [Multi Modal Framework](https://github.com/pytorch/serve/blob/master/examples/MMF-activity-recognition/handler.py) - Build and deploy a classifier that combines text, audio and video input data
36+
* [Dual Translation Workflow](https://github.com/pytorch/serve/tree/master/examples/Workflows/nmt_tranformers_pipeline) -
37+
* [Model Zoo](model_zoo.md) - List of pre-trained model archives ready to be served for inference with TorchServe.
38+
* [Examples](https://github.com/pytorch/serve/tree/master/examples) - Many examples of how to package and deploy models with TorchServe
39+
* [Workflow Examples](https://github.com/pytorch/serve/tree/master/examples/Workflows) - Examples of how to compose models in a workflow with TorchServe
40+
41+
## Advanced Features
42+
43+
* [Advanced configuration](configuration.md) - Describes advanced TorchServe configurations.
44+
* [A/B test models](https://github.com/pytorch/serve/blob/master/docs/use_cases.md#serve-models-for-ab-testing) - A/B test your models for regressions before shipping them to production
45+
* [Custom Service](custom_service.md) - Describes how to develop custom inference services.
46+
* [Encrypted model serving](management_api.md/encrypted-model-serving) - S3 server side model encryption via KMS
47+
* [Snapshot serialization](https://github.com/pytorch/serve/blob/master/plugins/docs/ddb_endpoint.md) - Serialize model artifacts to AWS Dynamo DB
48+
* [Benchmarking and Profiling](https://github.com/pytorch/serve/tree/master/benchmarks#torchserve-model-server-benchmarking) - Use JMeter or Apache Bench to benchmark your models and TorchServe itself
49+
* [TorchServe on Kubernetes](https://github.com/pytorch/serve/blob/master/kubernetes/README.md#torchserve-on-kubernetes) - Demonstrates a Torchserve deployment in Kubernetes using Helm Chart supported in both Azure Kubernetes Service and Google Kubernetes service
50+
* [mlflow-torchserve](https://github.com/mlflow/mlflow-torchserve) - Deploy mlflow pipeline models into TorchServe
51+
* [Kubeflow pipelines](https://github.com/kubeflow/pipelines/tree/master/samples/contrib/pytorch-samples) - Kubeflow pipelines and Google Vertex AI Managed pipelines

docs/Troubleshooting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Troubleshooting guide.
1+
## Troubleshooting Guide
22
Refer to this section for common issues faced while deploying your Pytorch models using Torchserve and their corresponding troubleshooting steps.
33

44
* [Deployment and config issues](#deployment-and-config-issues)

docs/apis.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. toctree::
2+
:caption: APIs:
3+
4+
grpc_api
5+
inference_api
6+
management_api
7+
metrics_api
8+
rest_api
9+
workflow_inference_api
10+
workflow_management_api

docs/code_coverage.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Code Coverage
2+
13
## To check branch stability run the sanity suite as follows
24
- Install dependencies (if not already installed)
35
For CPU:

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878

7979

8080
# The master toctree document.
81-
master_doc = 'index'
81+
master_doc = 'contents'
8282

8383
# General information about the project.
8484
project = 'PyTorch/Serve'
@@ -129,7 +129,7 @@
129129
#
130130
html_theme_options = {
131131
'pytorch_project': 'audio',
132-
'collapse_navigation': False,
132+
'collapse_navigation': True,
133133
'display_version': True,
134134
'logo_only': True,
135135
}

docs/contents.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.. toctree::
2+
:maxdepth: 0
3+
:numbered:
4+
:caption: Contents:
5+
:titlesonly:
6+
7+
index
8+
Troubleshooting
9+
batch_inference_with_ts
10+
code_coverage
11+
configuration
12+
custom_service
13+
default_handlers
14+
logging
15+
metrics
16+
model_zoo
17+
request_envelopes
18+
server
19+
snapshot
20+
sphinx/requirements
21+
torchserve_on_win_native
22+
torchserve_on_wsl
23+
use_cases
24+
workflows
25+
26+
.. toctree::
27+
:maxdepth: 0
28+
:caption: APIs
29+
30+
apis

docs/custom_service.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Custom Service
2+
13
## Contents of this Document
24

35
* [Custom handlers](#custom-handlers)
@@ -380,7 +382,7 @@ class ModelHandler(object):
380382
self.device = torch.device("cuda:" + str(properties.get("gpu_id")) if torch.cuda.is_available() else "cpu")
381383
```
382384

383-
# Installing model specific python dependencies
385+
## Installing model specific python dependencies
384386

385387
Custom models/handlers may depend on different python packages which are not installed by-default as a part of `TorchServe` setup.
386388

docs/default_handlers.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ For more details see [examples](https://github.com/pytorch/serve/tree/master/exa
3838

3939
For a more comprehensive list of available handlers make sure to check out the [examples page](https://github.com/pytorch/serve/tree/master/examples)
4040

41-
# Common features
41+
## Common features
4242

43-
## index_to_name.json
43+
### index_to_name.json
4444

4545
`image_classifier`, `text_classifier` and `object_detector` can all automatically map from numeric classes (0,1,2...) to friendly strings. To do this, simply include in your model archive a file, `index_to_name.json`, that contains a mapping of class number (as a string) to friendly name (also as a string). You can see some examples here:
4646
- [image_classifier](https://github.com/pytorch/serve/tree/master/examples/image_classifier/index_to_name.json)
4747
- [text_classifier](https://github.com/pytorch/serve/tree/master/examples/text_classification/index_to_name.json)
4848
- [object_detector](https://github.com/pytorch/serve/tree/master/examples/object_detector/index_to_name.json)
4949

50-
# Contributing
50+
### Contributing
5151
We welcome new contributed handlers, if your usecase isn't covered by one of the existing default handlers please follow the below steps to contribute it
5252
1. Write a new class derived from [BaseHandler](https://github.com/pytorch/serve/blob/master/ts/torch_handler/base_handler.py). Add it as a separate file in `ts/torch_handler/`
5353
2. Update `model-archiver/model_packaging.py` to add in your classes name

0 commit comments

Comments
 (0)