Skip to main content

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

  • [20260123] Available on Pypi: pip install torchpipe
  • [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

  • 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"

The backends it introduces will be JIT-compiled and cached.

or you can try

pip install torch>=2.3 torchpipe

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:

  • providing environment variables:
    Users can specify paths via the following environment variables:
    OPENCV_INCLUDE, OPENCV_LIB, TENSORRT_INCLUDE, TENSORRT_LIB.

Other installation options

How does it work?

See Basic Usage.

How to add (or override) a backend

WIP

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

omniback-0.1.22.tar.gz (898.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

omniback-0.1.22-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (6.3 MB view details)

Uploaded Python 3manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

omniback-0.1.22-py3-none-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (6.1 MB view details)

Uploaded Python 3manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

omniback-0.1.22-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (6.6 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

omniback-0.1.22-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (6.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

File details

Details for the file omniback-0.1.22.tar.gz.

File metadata

  • Download URL: omniback-0.1.22.tar.gz
  • Upload date:
  • Size: 898.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for omniback-0.1.22.tar.gz
Algorithm Hash digest
SHA256 3839762002424098be432f8f62a0662f79eb86bce289b08ebbafcaac71ba0812
MD5 f3e077a9603f5ad0cc8ac041b7d9aa38
BLAKE2b-256 abca0b0119deecfce82446cd2ba0a5b9ef37eab6f579ead75470a3d4e85bf953

See more details on using hashes here.

File details

Details for the file omniback-0.1.22-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for omniback-0.1.22-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ce8018cf408df1994c2f2487d17939aa389809d82e6bafa4fe598f65f48c7db5
MD5 d6fa32f584cc081ea130932274f56e58
BLAKE2b-256 3504f7eb71ba215a17a2eb85771cfbfeb490a546bc30476ca97edb559d4de0b9

See more details on using hashes here.

File details

Details for the file omniback-0.1.22-py3-none-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for omniback-0.1.22-py3-none-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 471ab9e2c83727943e3a6760e01a940aaeec33d692bf9f369638936d2ee18b89
MD5 4aa6674d95b38286bbcd74cc20fb99ce
BLAKE2b-256 dd46718fbea00aff54e209766583b7cbbd0f65feb0afda1a87c5d02b2f386aa0

See more details on using hashes here.

File details

Details for the file omniback-0.1.22-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for omniback-0.1.22-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 815ee67487879131508260d2157ad5939a8faf7c7643e8f38803dfa215f03b16
MD5 092a6090b4fe515ae3dba2801dacf0fe
BLAKE2b-256 ff23fc214c38f9bb96d0a485af1c13ecbf9e81fae53cc07bee8a76819ce7b2d6

See more details on using hashes here.

File details

Details for the file omniback-0.1.22-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for omniback-0.1.22-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 cbbf49d2d63f4591253ce8054827392852d7b134620cce8c6eba29777dc76142
MD5 5e89c160188c43aaf83385cf243d42bd
BLAKE2b-256 d64c25096a3f9ccb857351f0eb341f6ec8035d56668c0651b12437c46a956166

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page