No project description provided
Project description
Torchpipe
torchpipe is an alternative choice for Triton Inference Server, mainly featuring similar functionalities such as Shared-momory, Ensemble, and BLS mechanism.
For serving scenarios, TorchPipe is designed to support multi-instance deployment, pipeline parallelism, adaptive batching, GPU-accelerated operators, and reduced head-of-line (HOL) blocking.It acts as a bridge between lower-level acceleration libraries (e.g., TensorRT, OpenCV, CVCUDA) and RPC frameworks (e.g., Thrift). At its core, it is an engine that enables programmable scheduling.
update
- [20260104] We switched to tvm_ffi to provide clearer C++-Python interaction.
Usage
Below are some usage examples, for more check out the examples.
Initialize and Prepare Pipeline
from torchpipe import pipe
import torch
from torchvision.models.resnet import resnet101
# create some regular pytorch model...
model = resnet101(pretrained=True).eval().cuda()
# create example model
model_path = f"./resnet101.onnx"
x = torch.ones((1, 3, 224, 224)).cuda()
torch.onnx.export(model, x, model_path, opset_version=17,
input_names=['input'], output_names=['output'],
dynamic_axes={'input': {0: 'batch_size'},
'output': {0: 'batch_size'}})
thread_safe_pipe = pipe({
"preprocessor": {
"backend": "S[DecodeTensor,ResizeTensor,CvtColorTensor,SyncTensor]",
# "backend": "S[DecodeMat,ResizeMat,CvtColorMat,Mat2Tensor,SyncTensor]",
'instance_num': 2,
'color': 'rgb',
'resize_h': '224',
'resize_w': '224',
'next': 'model',
},
"model": {
"backend": "SyncTensor[TensorrtTensor]",
"model": model_path,
"model::cache": model_path.replace(".onnx", ".trt"),
"max": '4',
'batching_timeout': 4, # ms, timeout for batching
'instance_num': 2,
'mean': "123.675, 116.28, 103.53",
'std': "58.395, 57.120, 57.375", # merged into trt
}}
)
Execute
We can execute the returned thread_safe_pipe just like the original PyTorch model, but in a thread-safe manner.
data = {'data': open('/path/to/img.jpg', 'rb').read()}
thread_safe_pipe(data) # <-- this is thread-safe
result = data['result']
Installation
The library can be installed simply via:
pip install torch>=2.3 torchpipe
However, the backends it introduces will be JIT-compiled and cached:
python -c "import torchpipe"
There are one core backend group(torchpipe_core) and three optional groups (torchpipe_opencv, torchpipe_nvjpeg, and torchpipe_tensorrt) with different dependencies. For details, see here.
Dependencies such as OpenCV and TensorRT can be provided in the following ways:
- Via NGC Docker containers (recommended):
test on 25.05, 25.06,
24.05, 23.05, and 22.12
img_name=nvcr.io/nvidia/pytorch:25.05-py3
docker run --rm --gpus all -it --network host \
-v $(pwd):/workspace/ --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 \
-w /workspace/ \
$img_name \
bash
pip install torchpipe
python -c "import torchpipe"
-
By providing environment variables (WIP):
Users can specify paths via the following environment variables:
OPENCV_INCLUDE,OPENCV_LIB,TENSORRT_INCLUDE,TENSORRT_LIB. -
Automatic download (WIP):
The build system can attempt to download required dependencies automatically, but this may be slow or fail due to network issues.
How does it work?
See Basic Usage.
How to add (or override) a backend
WIP
Version Migration Notes
TorchPipe (v1, this version) is a collection of deep learning computation backends built on Omniback library. Not all computation backends from TorchPipe (v0) have been ported to TorchPipe (v1) yet.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file omniback-0.1.19.tar.gz.
File metadata
- Download URL: omniback-0.1.19.tar.gz
- Upload date:
- Size: 943.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05af7d5ee320b1bf92522ec2e3cb26df43ad67ce2d3fea89600c9b8c1a991621
|
|
| MD5 |
e5c28de8f1765db5ac525af4e1923f78
|
|
| BLAKE2b-256 |
cefb2c9569b04194f667b8f684d48e40645ce8da1264d61e267228fab046fe20
|
File details
Details for the file omniback-0.1.19-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: omniback-0.1.19-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 6.3 MB
- Tags: Python 3, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89f9a93e1a0094c54aaa7beb68e2639976b30f5cb2147ffebd404b7d6421dac8
|
|
| MD5 |
ef1e681e1d0683b5b358c2033595bc49
|
|
| BLAKE2b-256 |
ae749ce38754bef5d5c1c3321ca923dace77a50fa4b5d8663af7658135eafe7a
|
File details
Details for the file omniback-0.1.19-py3-none-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: omniback-0.1.19-py3-none-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 6.1 MB
- Tags: Python 3, manylinux: glibc 2.26+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
332d84bc38f54e9ad8c906424ac6bce249ca21549fd2726507a5c1a1fdfdab3c
|
|
| MD5 |
972b6a534bb1ea22c319beb0f8dae86a
|
|
| BLAKE2b-256 |
317f7476772ff3b7f5fa7ff69b20817771377da359bd05862c0e26a0ed22194d
|
File details
Details for the file omniback-0.1.19-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: omniback-0.1.19-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 6.6 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a322ccf39a6b6678dff2ce381a5664916b3c91ee0d19f4ab7c425204351378f1
|
|
| MD5 |
855045c78ee49db945a2cac0659ad1de
|
|
| BLAKE2b-256 |
ae6f22f3815ac92b08687f8d553e04f083afba86d9875e45b1d458471fc102a3
|
File details
Details for the file omniback-0.1.19-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl.
File metadata
- Download URL: omniback-0.1.19-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
- Upload date:
- Size: 6.4 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88acbc63a7bc9f31236e828a2218d6251747b588fa0f63f04cdccfcce86ac140
|
|
| MD5 |
d59af214be25fed7c128142362cd5927
|
|
| BLAKE2b-256 |
eac968fcc5a1f9778143296d1a8067b3088426739c4fd1db3fd37ac80857b105
|