Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: hello world readme #32

Closed
wants to merge 57 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
9a67e25
updated with skeleton / straw man structure
nnshah1 Jan 15, 2025
44304db
updated
nnshah1 Jan 15, 2025
f4a1ef0
updated
nnshah1 Jan 15, 2025
62b20c5
moving under operators
nnshah1 Jan 15, 2025
7dd83c1
updated skeleton
nnshah1 Jan 16, 2025
aafe096
Merge branch 'main' into nnshah1-hello-world
nnshah1 Jan 16, 2025
cad9d3f
updated with minimal example - not yet tested
nnshah1 Jan 16, 2025
41abd50
Merge branch 'nnshah1-hello-world' of https://github.com/triton-infer…
nnshah1 Jan 16, 2025
97c752d
updated to use deployment
nnshah1 Jan 16, 2025
b0f3464
updating with single_file separate from main
nnshah1 Jan 16, 2025
991358b
updating
nnshah1 Jan 16, 2025
bd57e10
docs: Add descriptions for example and main folder
piotrm-nvidia Jan 16, 2025
1109f65
updating to add operator to operators folder for us in 'deploy'
nnshah1 Jan 16, 2025
d16811c
Merge branch 'nnshah1-hello-world' of https://github.com/triton-infer…
nnshah1 Jan 16, 2025
88de51c
updates to remove operator from deploy
nnshah1 Jan 16, 2025
a7face5
incremental updates
nnshah1 Jan 16, 2025
c52b3ad
removing temporary files
nnshah1 Jan 16, 2025
ff72717
putting more common handling into deployment
nnshah1 Jan 16, 2025
3611828
updating default for single file
nnshah1 Jan 16, 2025
a01fd7b
Merge branch 'main' into nnshah1-hello-world
nnshah1 Jan 16, 2025
958f5f8
updating with deploy app
nnshah1 Jan 16, 2025
c4e6fed
updated with signal handler for exit
nnshah1 Jan 16, 2025
00aedbc
adding parser
nnshah1 Jan 16, 2025
c2dc190
removing gitkeep
nnshah1 Jan 16, 2025
3a74bcb
adding in initial client - still testing
nnshah1 Jan 17, 2025
e7bd20f
updated with working client
nnshah1 Jan 17, 2025
369259f
updated to remove version
nnshah1 Jan 17, 2025
9f56b11
removing version from tests
nnshah1 Jan 17, 2025
dadd9f0
adding basic exit code detection to help with sanity tests
nnshah1 Jan 17, 2025
2da91d7
adding sanity test
nnshah1 Jan 17, 2025
f2673f8
delete unnecessary file
nnshah1 Jan 17, 2025
348b578
adding copyright
nnshah1 Jan 17, 2025
5748a15
removing unnecessary files
nnshah1 Jan 17, 2025
f62b18e
Merge branch 'main' into nnshah1-hello-world
nnshah1 Jan 17, 2025
26fe1d8
updates for static type checks
nnshah1 Jan 17, 2025
9421700
adding sanity test to pre-merge until we have additional triggers ena…
nnshah1 Jan 17, 2025
7298502
reduce number of requests for sanity test
nnshah1 Jan 17, 2025
aac2881
Merge branch 'main' into nnshah1-hello-world
nnshah1 Jan 17, 2025
444a82a
removing version from RemoteOperator calls
nnshah1 Jan 17, 2025
671ce6a
adding copyright
nnshah1 Jan 17, 2025
2d0f1db
updating copyright
nnshah1 Jan 17, 2025
4a5df20
moving new additions to comments to allow for functional merge
nnshah1 Jan 17, 2025
5a4b97f
updating copyright and license
nnshah1 Jan 17, 2025
13d5fee
updated copyright
nnshah1 Jan 17, 2025
4eb9b3c
WIP
nnshah1 Jan 17, 2025
7fe44ce
updates
nnshah1 Jan 17, 2025
0972500
updated
nnshah1 Jan 17, 2025
78e9eb4
update
nnshah1 Jan 17, 2025
e28d586
Update examples/hello_world/README.md
nnshah1 Jan 17, 2025
6e7eee2
Update examples/hello_world/README.md
nnshah1 Jan 17, 2025
c447cc5
Update examples/hello_world/README.md
nnshah1 Jan 17, 2025
8ce4d95
Update examples/hello_world/README.md
nnshah1 Jan 17, 2025
68a335d
updated
nnshah1 Jan 17, 2025
32c819f
Merge branch 'nnshah1-hello-world-readme' of https://github.com/trito…
nnshah1 Jan 17, 2025
d53bde5
updated
nnshah1 Jan 17, 2025
566a7a6
updating default to standard
nnshah1 Jan 17, 2025
aa78878
updating
nnshah1 Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ See the License for the specific language governing permissions and
limitations under the License.
-->


# Triton Distributed

<h4> A Datacenter Scale Distributed Inference Serving Framework </h4>
Expand Down Expand Up @@ -48,9 +47,9 @@ We provide 3 types of builds:
2. `TENSORRTLLM` which includes our TRT-LLM backend
3. `VLLM` which includes our VLLM backend

For example, if you want to build a container for the `VLLM` backend you can run
For example, if you want to build a container for the `STANDARD` backends you can run

`./container/build.sh --framework VLLM`
`./container/build.sh`
nnshah1 marked this conversation as resolved.
Show resolved Hide resolved

Please see the instructions in the corresponding example for specific build instructions.

Expand Down Expand Up @@ -85,13 +84,22 @@ HF_TOKEN```) and mounts common directories such as ```/tmp:/tmp```,
Please see the instructions in the corresponding example for specific
deployment instructions.

## Hello World

<!--
[Hello World](./examples/hello_world)

A basic example demonstrating the new interfaces and concepts of
triton distributed. In the hello world example, you can deploy a set
of simple workers to load balance requests from a local work queue.

## Goals
# Disclaimers

## Concepts
> [!NOTE]
> This project is currently in the alpha / experimental /
> rapid-prototyping stage and we will be adding new features incrementally.

## Examples
1. The `TENSORRTLLM` and `VLLM` containers are WIP and not expected to
work out of the box.

-->
2. Testing has primarily been on single node systems with processes
launched within a single container.
2 changes: 1 addition & 1 deletion container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ COPY . /workspace
RUN /workspace/icp/protos/gen_python.sh

# Sets pythonpath for python modules
ENV PYTHONPATH="${PYTHONPATH}:/workspace/icp/src/python:/workspace/worker/src/python"
ENV PYTHONPATH="${PYTHONPATH}:/workspace/icp/src/python:/workspace/worker/src/python:/workspace/examples"

# Command and Entrypoint
CMD []
Expand Down
274 changes: 274 additions & 0 deletions examples/hello_world/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
<!--
SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# Hello World

A basic example demonstrating the new interfaces and concepts of
triton distributed. In the hello world example, you can deploy a set
of simple workers to load balance requests from a local work queue.

The example demonstrates:

1. How to incorporate an existing Triton Core Model into a triton distributed worker.
2. How to incorporate a standalone python class into a triton distributed worker.
3. How deploy a set of workers
4. How to send requests to the triton distributed deployment
5. Requests over the Request Plane and Data movement over the Data
Plane.

## Building the Hello World Environment

The hello world example is designed to be deployed in a containerized
environment and to work with and without GPU support.

To get started build the "STANDARD" triton distributed development
environment.

Note: "STANDARD" is the default framework
rmccorm4 marked this conversation as resolved.
Show resolved Hide resolved

```
./container/build.sh
```


## Starting the Deployment

```
./container/run.sh -it -- python3 -m hello_world.deploy --initialize-request-plane
```

#### Expected Output


```
Starting Workers
17:17:09 deployment.py:115[triton_distributed.worker.deployment] INFO:

Starting Worker:

Config:
WorkerConfig(request_plane=<class 'triton_distributed.icp.nats_request_plane.NatsRequestPlane'>,
data_plane=<function UcpDataPlane at 0x7f477eb5d580>,
request_plane_args=([], {}),
data_plane_args=([], {}),
log_level=1,
operators=[OperatorConfig(name='encoder',
implementation=<class 'triton_distributed.worker.triton_core_operator.TritonCoreOperator'>,
repository='/workspace/examples/hello_world/operators/triton_core_models',
version=1,
max_inflight_requests=1,
parameters={'config': {'instance_group': [{'count': 1,
'kind': 'KIND_CPU'}],
'parameters': {'delay': {'string_value': '0'},
'input_copies': {'string_value': '1'}}}},
log_level=None)],
triton_log_path=None,
name='encoder.0',
log_dir='/workspace/examples/hello_world/logs',
metrics_port=50000)
<SpawnProcess name='encoder.0' parent=1 initial>

17:17:09 deployment.py:115[triton_distributed.worker.deployment] INFO:

Starting Worker:

Config:
WorkerConfig(request_plane=<class 'triton_distributed.icp.nats_request_plane.NatsRequestPlane'>,
data_plane=<function UcpDataPlane at 0x7f477eb5d580>,
request_plane_args=([], {}),
data_plane_args=([], {}),
log_level=1,
operators=[OperatorConfig(name='decoder',
implementation=<class 'triton_distributed.worker.triton_core_operator.TritonCoreOperator'>,
repository='/workspace/examples/hello_world/operators/triton_core_models',
version=1,
max_inflight_requests=1,
parameters={'config': {'instance_group': [{'count': 1,
'kind': 'KIND_CPU'}],
'parameters': {'delay': {'string_value': '0'},
'input_copies': {'string_value': '1'}}}},
log_level=None)],
triton_log_path=None,
name='decoder.0',
log_dir='/workspace/examples/hello_world/logs',
metrics_port=50001)
<SpawnProcess name='decoder.0' parent=1 initial>

17:17:09 deployment.py:115[triton_distributed.worker.deployment] INFO:

Starting Worker:

Config:
WorkerConfig(request_plane=<class 'triton_distributed.icp.nats_request_plane.NatsRequestPlane'>,
data_plane=<function UcpDataPlane at 0x7f477eb5d580>,
request_plane_args=([], {}),
data_plane_args=([], {}),
log_level=1,
operators=[OperatorConfig(name='encoder_decoder',
implementation='EncodeDecodeOperator',
repository='/workspace/examples/hello_world/operators',
version=1,
max_inflight_requests=1,
parameters={},
log_level=None)],
triton_log_path=None,
name='encoder_decoder.0',
log_dir='/workspace/examples/hello_world/logs',
metrics_port=50002)
<SpawnProcess name='encoder_decoder.0' parent=1 initial>

Workers started ... press Ctrl-C to Exit
```

## Sending Requests

From a separate terminal run the sample client.

```
./container/run.sh -it -- python3 -m hello_world.client
```

#### Expected Output

```

Client: 0 Received Response: 42 From: 39491f06-d4f7-11ef-be96-047bcba9020e Error: None: 43%|███████▋ | 43/100 [00:04<00:05, 9.83request/s]

Throughput: 9.10294484748811 Total Time: 10.985455989837646
Clients Stopped Exit Code 0


```

## Behind the Scenes

The hello world example is designed to demonstrate and allow
experimenting with different mixtures of compute and memory loads and
different numbers of workers for different parts of the hello world
workflow.

### Hello World Workflow

The hello world workflow is a simple two stage pipeline with an
encoding stage and a decoding stage plus an encoder-decoder stage to
orchestrate the overall workflow.

```
client <-> encoder_decoder <-> encoder
|
-----<-> decoder
```


#### Encoder

The encoder follows the simple procedure:

1. copy the input x times (x is configurable via parameter)
2. invert the input
3. delay * size of output

#### Decoder

The decoder follows the simple procedure:

1. remove the extra copies
2. invert the input
3. delay * size of output

#### Encoder - Decoder

The encoder-decoder operator controls the overall workflow.

It first sends a request for an encoder. Once it receives the response
it sends the output from the encoder as an input to the decoder. Note
in this step memory is transferred directly between the encoder and
decoder workers - and does not pass through the encoder-decoder.

### Operators

Operators are responsible for actually doing work and responding to
requests. Operators are supported in two main flavors and are hosted
by a common Worker class.

#### Triton Core Operator

The triton core operator makes a triton model (following the [standard
model
repo](https://github.com/triton-inference-server/server/blob/main/docs/user_guide/model_repository.md)
and backend structure of the tritonserver) available on the request
plane. Both the encoder and decoder are implemented as triton python
backend models.

#### Generic Operator

The encoder-decoder operator is a python class that implements the
Operator interface. Internally it makes remote requests to other
workers. Generally a operator can make use of other operators for its
work but isn't required to.

### Workers

Workers host one or more operators and pull requests from the request
plane and forward them to a local operator.

### Request Plane

The current triton distributed framework leverages a distributed work
queue for its request plane implementation. The request plane ensures
that requests for operators are forwarded and serviced by a single
worker.

### Data Plane

The triton distributed framework leverages point to point data
transfers using the UCX library to provide optimized primitives for
device to device transfers.

Data sent over the data plane is only pulled by the worker that needs
to perform work on it. Requests themselves contain data descriptors
and can be referenced and shared with other workers.

Note: there is also a provision for sending data in the request
contents when the message size is small enough that UCX transfer is
not needed.

### Components

Any process which communicates with one or more of the request or data
planes is considered a "component". While this example only uses
"Workers" future examples will also include api servers, routers, and
other types of components.

### Deployment

The final piece is a deployment. A deployment is a set of components
deployed across a cluster. Components may be added and removed from
deployments.


## Limitations and Caveats

The example is a rapidly evolving prototype and shouldn't be used in
production. Limited testing has been done and it is meant to help
flesh out the triton distributed concepts, architecture, and
interfaces.

1. No multi-node testing / support has been done

2. No performance tuning / measurement has been done

14 changes: 14 additions & 0 deletions examples/hello_world/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Loading