ray/doc/source/serve/tutorials/deployment-graph-patterns/linear_pipeline.md

1,009 B

Pattern: Linear Pipeline

This deployment graph pattern is a linear pipeline of deployments. The request flows from each deployment to the next, getting transformed each time.

pic

Code

:language: python
:start-after: __graph_start__
:end-before: __graph_end__

Execution

This graph has three nodes, which are all instances of the Model deployment. Each Model is constructed with a different weight, and its forward method adds that weight to the input.

The call graph calls each deployment's forward method, one after another, which adds all the Model's weights to the input. The code executes the graph on an input of 0 and after adding all the weights (0, 1, and 2), it gets a final sum of 3:

$ python linear_pipeline.py

3