VoltaML/voltaML

⚡VoltaML is a lightweight library to convert and run your ML/DL deep learning models in high performance inference runtimes like TensorRT, TorchScript, ONNX and TVM.

Python

1,177

25 commits

updated Nov 30, 2022

See the code

README

Screenshot 2022-10-19 at 3 55 14 PM

Accelerate your machine learning and deep learning models by upto 10X

🔥UPDATE: Stable-Diffusion/DreamBooth Acceleration. Upto 2.5X speed up in inference🔥

voltaML is an open-source lightweight library to accelerate your machine learning and deep learning models. VoltaML can optimize, compile and deploy your models to your target CPU and GPU devices, with just one line of code.

animated

Out of the box support for

✅ FP16 Quantization

✅ Int8 Quantization*

✅ Hardware specific compilation


Screenshot 2022-10-17 at 12 06 26 PM

voltaML has compilation support for the following:

Screenshot 2022-06-13 at 3 43 03 PM

Installation

Own setup:

Requirements:

  • CUDA Version >11.x
  • TensorRT == 8.4.1.2
  • PyTorch == 1.12 cu11.x
  • NVIDIA Driver version > 510
git clone https://github.com/VoltaML/voltaML.git
cd voltaML
python setup.py install

Docker Container 🐳

docker pull voltaml/voltaml:v0.4
docker run -it --gpus=all -p "8888:8888" voltaml/voltaml:v0.4 \ 
        jupyter lab --port=8888 --no-browser --ip 0.0.0.0 --allow-root

Usage

import torch
from voltaml.compile import VoltaGPUCompiler, VoltaCPUCompiler, TVMCompiler
from voltaml.inference import gpu_performance

model = torch.load("path/to/model/dir")

# compile the model by giving paths
compiler = VoltaGPUCompiler(
        model=model,
        output_dir="destination/path/of/compiled/model",
        input_shape=(1, 3, 224, 224), # example input shape
        precision="fp16" # specify precision[fp32, fp16, int8] - Only for GPU compiler
        target="llvm" # specify target device - Only for TVM compiler
    )

# returns the compiled model
compiled_model = compiler.compile()

# compute and compare performance
gpu_performance(compiled_model, model, input_shape=(1, 3, 224, 224))
cpu_performance(compiled_model, model, compiler="voltaml", input_shape=(1, 3, 224, 224))
cpu_performance(compiled_model, model, compiler="tvm", input_shape=(1, 3, 224, 224))

Notebooks

  1. ResNet-50 image classification
  2. DeeplabV3_MobileNet_v3_Large Segmentation
  3. YOLOv5 Object Detection YOLOv5
  4. YOLOv6 Object Detection YOLOv6
  5. Bert_Base_Uncased Huggingface

Benchmarks

🖼️ Classification Models Inference Latency (on GPU) ⏱️

Classification has been done on Imagenet data, batch size = 1 and imagesize = 224 on NVIDIA RTX 2080Ti. In terms of top 1% and 5% accuracy for int8 models, we have not seen an accuracy drop of more than 1%.

Pytorch (ms), VoltaGPU FP16 (ms) and VoltaGPU int8 (ms)

ModelPytorch (ms)VoltaGPU FP16 (ms)VoltaGPU int8 (ms)Pytorch vs Int8 Speed
squeezenet1_11.60.20.28.4x
resnet182.70.40.39.0x
resnet344.50.70.59.0x
resnet506.60.70.513.2x
resnet10113.61.31.013.6x
densenet12115.72.42.07.9x
densenet16922.04.43.85.8x
densenet20126.86.35.05.4x
vgg112.00.90.54.0x
vgg163.51.20.75.0x

🧐 Object Detection (YOLO) Models Inference Latency (on GPU) ⏱️

Object Detection inference was done on a dummy data with imagesize = 640 and batch size = 1 on NVIDIA RTX 2080Ti.

Pytorch (ms) and VoltaGPU FP16 (ms)

ModelPytorch (ms)VoltaGPU FP16 (ms)Pytorch vs FP16 Speed
YOLOv5n5.21.24.3x
YOLOv5s5.11.63.2x
YOLOv5m9.13.22.8x
YOLOv5l15.35.13.0x
YOLOv5x30.86.44.8x
YOLOv6s8.83.02.9x
YOLOv6l_relu23.45.54.3x
YOLOv6l18.14.14.4x
YOLOv6n9.11.65.7x
YOLOv6t8.62.43.6x
YOLOv5m15.53.54.4x

🎨 Segmentation Models Inference Latency (on GPU) ⏱️

Segmentation inference was done on a dummy data with imagesize = 224 and batch size = 1 on NVIDIA RTX 2080Ti.

Pytorch (ms), VoltaGPU FP16 (ms) and VoltaGPU Int8 (ms)(1)

ModelPytorch (ms)VoltaGPU FP16 (ms)VoltaGPU Int8 (ms)Speed Up (X)
FCN_Resnet508.32.31.83.6x
FCN_Resnet10114.73.52.55.9x
DeeplabV3_Resnet5012.12.51.39.3x
DeeplabV3_Resnet10118.73.62.09.4x
DeeplabV3_MobileNetV3_Large6.11.50.87.6x
DeeplabV3Plus_ResNet506.11.10.87.6x
DeeplabV3Plus_ResNet344.70.90.85.9x
UNet_ResNet506.21.316.2x
UNet_ResNet344.31.10.85.4x
FPN_ResNet505.51.215.5x
FPN_ResNet344.21.114.2x

🤗 Accelerating Huggingface Models using voltaML

We're adding support to accelerate Huggingface NLP models with voltaML. This work has been inspired from ELS-RD's work. This is still in the early stages and only few models listed in the below table are supported. We're working to add more models soon.

from voltaml.compile import VoltaNLPCompile
from voltaml.inference import nlp_performance


model='bert-base-cased'
backend=["tensorrt","onnx"] 
seq_len=[1, 1, 1] 
task="classification"
batch_size=[1,1,1]

VoltaNLPCompile(model=model, device='cuda', backend=backend, seq_len=seq_len)

nlp_performance(model=model, device='cuda', backend=backend, seq_len=seq_len)

Pytorch (ms) and VoltaML FP16 (ms)

ModelPytorch (ms)VoltaML FP16 (ms)SpeedUp
bert-base-uncased6.416.4x
Jean-Baptiste/camembert-ner6.316.3x
gpt26.61.25.5x
xlm-roberta-base6.41.085.9x
roberta-base6.61.096.1x
bert-base-cased6.20.96.9x
distilbert-base-uncased3.50.65.8x
roberta-large11.92.45.0x
deepset/xlm-roberta-base-squad26.21.085.7x
cardiffnlp/twitter-roberta-base-sentiment61.075.6x
sentence-transformers/all-MiniLM-L6-v23.20.427.6x
bert-base-chinese6.30.976.5x
distilbert-base-uncased-finetuned-sst-2-english3.40.65.7x
albert-base-v26.716.7x

voltaTrees ⚡🌴 -> Link

A LLVM-based compiler for XGBoost and LightGBM decision trees.

voltatrees converts trained XGBoost and LightGBM models to optimized machine code, speeding-up prediction by ≥10x.

Example

import voltatrees as vt

model = vt.XGBoostRegressor.Model(model_file="NYC_taxi/model.txt")
model.compile()
model.predict(df)

Installation

git clone git clone https://github.com/VoltaML/volta-trees.git
cd volta-trees/
pip install -e .

Benchmarks

On smaller datasets, voltaTrees is 2-3X faster than Treelite by DMLC. Testing on large scale dataset is yet to be conducted.

Enterpise Platform 🛣️

Any enterprise customers who would like a fully managed solution hosted on your own cloud, please contact us at [email protected]

  • Fully managed and cloud-hosted optimization engine.
  • Hardware targeted optimised dockers for maximum performance.
  • One-click deployment of the compiled models.
  • Cost-benefit analysis dashboard for optimal deployment.
  • NVIDIA Triton optimzed dockers for large-scale GPU deployment.
  • Quantization-Aware-Training (QAT)

VoltaML/voltaML

⚡VoltaML is a lightweight library to convert and run your ML/DL deep learning models in high performance inference runtimes like TensorRT, TorchScript, ONNX and TVM.

Python

1,177

25 commits

updated Nov 30, 2022

See the code

README

Screenshot 2022-10-19 at 3 55 14 PM

Accelerate your machine learning and deep learning models by upto 10X

🔥UPDATE: Stable-Diffusion/DreamBooth Acceleration. Upto 2.5X speed up in inference🔥

voltaML is an open-source lightweight library to accelerate your machine learning and deep learning models. VoltaML can optimize, compile and deploy your models to your target CPU and GPU devices, with just one line of code.

animated

Out of the box support for

✅ FP16 Quantization

✅ Int8 Quantization*

✅ Hardware specific compilation


Screenshot 2022-10-17 at 12 06 26 PM

voltaML has compilation support for the following:

Screenshot 2022-06-13 at 3 43 03 PM

Installation

Own setup:

Requirements:

  • CUDA Version >11.x
  • TensorRT == 8.4.1.2
  • PyTorch == 1.12 cu11.x
  • NVIDIA Driver version > 510
git clone https://github.com/VoltaML/voltaML.git
cd voltaML
python setup.py install

Docker Container 🐳

docker pull voltaml/voltaml:v0.4
docker run -it --gpus=all -p "8888:8888" voltaml/voltaml:v0.4 \ 
        jupyter lab --port=8888 --no-browser --ip 0.0.0.0 --allow-root

Usage

import torch
from voltaml.compile import VoltaGPUCompiler, VoltaCPUCompiler, TVMCompiler
from voltaml.inference import gpu_performance

model = torch.load("path/to/model/dir")

# compile the model by giving paths
compiler = VoltaGPUCompiler(
        model=model,
        output_dir="destination/path/of/compiled/model",
        input_shape=(1, 3, 224, 224), # example input shape
        precision="fp16" # specify precision[fp32, fp16, int8] - Only for GPU compiler
        target="llvm" # specify target device - Only for TVM compiler
    )

# returns the compiled model
compiled_model = compiler.compile()

# compute and compare performance
gpu_performance(compiled_model, model, input_shape=(1, 3, 224, 224))
cpu_performance(compiled_model, model, compiler="voltaml", input_shape=(1, 3, 224, 224))
cpu_performance(compiled_model, model, compiler="tvm", input_shape=(1, 3, 224, 224))

Notebooks

  1. ResNet-50 image classification
  2. DeeplabV3_MobileNet_v3_Large Segmentation
  3. YOLOv5 Object Detection YOLOv5
  4. YOLOv6 Object Detection YOLOv6
  5. Bert_Base_Uncased Huggingface

Benchmarks

🖼️ Classification Models Inference Latency (on GPU) ⏱️

Classification has been done on Imagenet data, batch size = 1 and imagesize = 224 on NVIDIA RTX 2080Ti. In terms of top 1% and 5% accuracy for int8 models, we have not seen an accuracy drop of more than 1%.

Pytorch (ms), VoltaGPU FP16 (ms) and VoltaGPU int8 (ms)

ModelPytorch (ms)VoltaGPU FP16 (ms)VoltaGPU int8 (ms)Pytorch vs Int8 Speed
squeezenet1_11.60.20.28.4x
resnet182.70.40.39.0x
resnet344.50.70.59.0x
resnet506.60.70.513.2x
resnet10113.61.31.013.6x
densenet12115.72.42.07.9x
densenet16922.04.43.85.8x
densenet20126.86.35.05.4x
vgg112.00.90.54.0x
vgg163.51.20.75.0x

🧐 Object Detection (YOLO) Models Inference Latency (on GPU) ⏱️

Object Detection inference was done on a dummy data with imagesize = 640 and batch size = 1 on NVIDIA RTX 2080Ti.

Pytorch (ms) and VoltaGPU FP16 (ms)

ModelPytorch (ms)VoltaGPU FP16 (ms)Pytorch vs FP16 Speed
YOLOv5n5.21.24.3x
YOLOv5s5.11.63.2x
YOLOv5m9.13.22.8x
YOLOv5l15.35.13.0x
YOLOv5x30.86.44.8x
YOLOv6s8.83.02.9x
YOLOv6l_relu23.45.54.3x
YOLOv6l18.14.14.4x
YOLOv6n9.11.65.7x
YOLOv6t8.62.43.6x
YOLOv5m15.53.54.4x

🎨 Segmentation Models Inference Latency (on GPU) ⏱️

Segmentation inference was done on a dummy data with imagesize = 224 and batch size = 1 on NVIDIA RTX 2080Ti.

Pytorch (ms), VoltaGPU FP16 (ms) and VoltaGPU Int8 (ms)(1)

ModelPytorch (ms)VoltaGPU FP16 (ms)VoltaGPU Int8 (ms)Speed Up (X)
FCN_Resnet508.32.31.83.6x
FCN_Resnet10114.73.52.55.9x
DeeplabV3_Resnet5012.12.51.39.3x
DeeplabV3_Resnet10118.73.62.09.4x
DeeplabV3_MobileNetV3_Large6.11.50.87.6x
DeeplabV3Plus_ResNet506.11.10.87.6x
DeeplabV3Plus_ResNet344.70.90.85.9x
UNet_ResNet506.21.316.2x
UNet_ResNet344.31.10.85.4x
FPN_ResNet505.51.215.5x
FPN_ResNet344.21.114.2x

🤗 Accelerating Huggingface Models using voltaML

We're adding support to accelerate Huggingface NLP models with voltaML. This work has been inspired from ELS-RD's work. This is still in the early stages and only few models listed in the below table are supported. We're working to add more models soon.

from voltaml.compile import VoltaNLPCompile
from voltaml.inference import nlp_performance


model='bert-base-cased'
backend=["tensorrt","onnx"] 
seq_len=[1, 1, 1] 
task="classification"
batch_size=[1,1,1]

VoltaNLPCompile(model=model, device='cuda', backend=backend, seq_len=seq_len)

nlp_performance(model=model, device='cuda', backend=backend, seq_len=seq_len)

Pytorch (ms) and VoltaML FP16 (ms)

ModelPytorch (ms)VoltaML FP16 (ms)SpeedUp
bert-base-uncased6.416.4x
Jean-Baptiste/camembert-ner6.316.3x
gpt26.61.25.5x
xlm-roberta-base6.41.085.9x
roberta-base6.61.096.1x
bert-base-cased6.20.96.9x
distilbert-base-uncased3.50.65.8x
roberta-large11.92.45.0x
deepset/xlm-roberta-base-squad26.21.085.7x
cardiffnlp/twitter-roberta-base-sentiment61.075.6x
sentence-transformers/all-MiniLM-L6-v23.20.427.6x
bert-base-chinese6.30.976.5x
distilbert-base-uncased-finetuned-sst-2-english3.40.65.7x
albert-base-v26.716.7x

voltaTrees ⚡🌴 -> Link

A LLVM-based compiler for XGBoost and LightGBM decision trees.

voltatrees converts trained XGBoost and LightGBM models to optimized machine code, speeding-up prediction by ≥10x.

Example

import voltatrees as vt

model = vt.XGBoostRegressor.Model(model_file="NYC_taxi/model.txt")
model.compile()
model.predict(df)

Installation

git clone git clone https://github.com/VoltaML/volta-trees.git
cd volta-trees/
pip install -e .

Benchmarks

On smaller datasets, voltaTrees is 2-3X faster than Treelite by DMLC. Testing on large scale dataset is yet to be conducted.

Enterpise Platform 🛣️

Any enterprise customers who would like a fully managed solution hosted on your own cloud, please contact us at [email protected]

  • Fully managed and cloud-hosted optimization engine.
  • Hardware targeted optimised dockers for maximum performance.
  • One-click deployment of the compiled models.
  • Cost-benefit analysis dashboard for optimal deployment.
  • NVIDIA Triton optimzed dockers for large-scale GPU deployment.
  • Quantization-Aware-Training (QAT)

Significant stargazers

Sanbu 散步

1,109 followers · starred Jan 2025

stefnotch

116 followers · starred Dec 2022

Erik Dunteman

157 followers · starred Jan 2023

Andrew Maguire

143 followers · starred Oct 2022