Skip to main content

LightSeq: A High Performance Library for Sequence Processing and Generation

logo

[2021/06/18] :tada: :tada: :tada: LightSeq supports fast training for models in the Transformer family now, please check out here for details.


LightSeq is a high performance training and inference library for sequence processing and generation implemented in CUDA. It enables highly efficient computation of modern NLP models such as BERT, GPT, Transformer, etc. It is therefore best useful for Machine Translation, Text Generation, Dialog, Language Modelling, Sentiment Analysis, and other related tasks with sequence data.

The library is built on top of CUDA official library(cuBLAS, Thrust, CUB) and custom kernel functions which are specially fused and optimized for Transformer model family. In addition to model components, the inference library also provide easy-to deploy model management and serving backend based on TensorRT Inference Server. With LightSeq, one can easily develop modified Transformer architecture with little additional code.

Features

>>> Training

The following is a support matrix of LightSeq training library compared with DeepSpeed.

features

>>> Inference

The following is a support matrix of LightSeq inference library compared with TurboTransformers and FasterTransformer.

support

Performance

>>> Training

Here we present the experimental results on WMT14 English to German translation task based on Transformer-big models. We train Transformer models of different sizes on eight NVIDIA Tesla V100/NVIDIA Tesla A100 GPUs with data parallel and fp16 mixed precision. Fairseq with Apex is choosed as our baseline.

We compute speedup on different batch size using the WPS (real words per second) metric.

More results is available here

>>> Inference

Here we present the experimental results on neural machine translation based on Transformer-base models using beam search methods. We choose Tensorflow and FasterTransformer as a comparison. The implementation from tensor2tensor was used as the benchmark of Tensorflow.

More results is available here.

Quick Start

Complete user guide is available here.

Installation

You can install LightSeq from PyPI:

$ pip install lightseq

LightSeq installation from PyPI only supports Python 3.6 to 3.8 on Linux for now. Consider compiling from source if you have other environments:

$ PATH=/usr/local/hdf5/:$PATH ENABLE_FP32=0 ENABLE_DEBUG=0 pip install -e $PROJECT_DIR

Detailed building introduction is available here.

Fast training from Fairseq

You can experience lightning fast training by running following commands, Firstly install these requirements.

$ pip install lightseq fairseq sacremoses

Then you can train a translation task on wmt14 en2de dataset by running the following script

$ sh examples/training/fairseq/ls_fairseq_wmt14en2de.sh

To compare lightseq with fairseq, delete the arguments with ls_ prefix to using the original fairseq implementation

More usage is available here.

Fast inference from HuggingFace bart

We provide an end2end bart-base example to see how fast Lightseq is compared to HuggingFace. First you should install these requirements.

$ pip install torch tensorflow transformers lightseq
$ cd examples/inference/python

then you can check the performance by simply running following commands. hf_bart_export.py is used to transform pytorch weights to LightSeq protobuffer.

$ python export/huggingface/hf_bart_export.py
$ python test/ls_bart.py

More usage is available here.

Fast deploy inference server

We provide a docker image which contains tritonserver and lightseq's dynamic link library, and you can deploy a inference server by simply replace the model file with your own model file.

$ sudo docker pull hexisyztem/tritonserver_lightseq:22.01-1

More usage is available here.

Cite Us

If you use LightSeq in your research, please cite the following paper.

@InProceedings{wang2021lightseq,
    title = "{L}ight{S}eq: A High Performance Inference Library for Transformers",
    author = "Wang, Xiaohui and Xiong, Ying and Wei, Yang and Wang, Mingxuan and Li, Lei",
    booktitle = "Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies: Industry Papers (NAACL-HLT)",
    month = jun,
    year = "2021",
    publisher = "Association for Computational Linguistics",
    pages = "113--120",
}

@article{wang2021lightseq2,
  title={LightSeq2: Accelerated Training for Transformer-based Models on GPUs},
  author={Wang, Xiaohui and Xiong, Ying and Qian, Xian and Wei, Yang and Li, Lei and Wang, Mingxuan},
  journal={arXiv preprint arXiv:2110.05722},
  year={2021}
}

Contact

Any questions or suggestions, please feel free to contact us at wangxiaohui.neo@bytedance.com, xiongying.taka@bytedance.com, qian.xian@bytedance.com, weiyang.god@bytedance.com, wangmingxuan.89@bytedance.com, lilei@cs.ucsb.edu

Hiring

The LightSeq team is hiring Interns/FTEs with backgrounds in deep learning system/natural language processing/computer vision/speech. We are based in Beijing and Shanghai. If you are interested, please send your resume to wangxiaohui.neo@bytedance.com.

Metadata

Release files for lightseq 3.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lightseq 3.0.1
File Size Uploaded
lightseq-3.0.1.tar.gz 1.0 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for lightseq 3.0.1
File
lightseq-3.0.1-py3-none-any.whl Python 3 none any Details
lightseq-3.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl PyPy 3.9 PyPy 3.9 7.3 Linux glibc 2.17+ x86-64 Details
lightseq-3.0.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl PyPy 3.8 PyPy 3.8 7.3 Linux glibc 2.17+ x86-64 Details
lightseq-3.0.1-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl PyPy 3.7 PyPy 3.7 7.3 Linux glibc 2.17+ x86-64 Details
lightseq-3.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
lightseq-3.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
lightseq-3.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details
lightseq-3.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 Details
lightseq-3.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.17+ x86-64 Details

Total release size: 2.0 GB

Release files / lightseq-3.0.1.tar.gz

Download URL lightseq-3.0.1.tar.gz
Size 1.0 MB
Tags Source
SHA-256 checksum
How to use checksums
3c4da116d240a49538ec6e67d95aab51c55a918ede0736d0da43ca0b64e4507d
BLAKE2b-256 checksum
How to use checksums
92c3ca4ed0027fb97a4fb6f0cf30010f7e0111bf688975c97daee297d1de0e51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release files / lightseq-3.0.1-py3-none-any.whl

Download URL lightseq-3.0.1-py3-none-any.whl
Size 1.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
7bdaddcd01942a3408ee187905f01e8d639b0cd0fd0bfdde0a3a8752832f5ecd
BLAKE2b-256 checksum
How to use checksums
80eab62cb67b2a8950c1dd752cce107e519216fd4d0ad64618a8af0730bf2534
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release files / lightseq-3.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL lightseq-3.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 243.6 MB
Tags Linux glibc 2.17+ x86-64 PyPy 3.9 PyPy 3.9 7.3
SHA-256 checksum
How to use checksums
c2631a59c26cd2073173c1b6bdb5d909fd17e984be3cb9523be737a316507749
BLAKE2b-256 checksum
How to use checksums
752e12752e2307449c81e2853d90ea93bfed836eb4aea9f02e21806b55168d25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release files / lightseq-3.0.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL lightseq-3.0.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 243.6 MB
Tags Linux glibc 2.17+ x86-64 PyPy 3.8 PyPy 3.8 7.3
SHA-256 checksum
How to use checksums
909bac65d635c91187e3c4eb1bb13187cceefcd25b56176b425686ba9f0ddd71
BLAKE2b-256 checksum
How to use checksums
19846d5d6644d7432c427d8efc0fce85c3b1f80e5933813f2e4281ebd72c5757
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release files / lightseq-3.0.1-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL lightseq-3.0.1-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 243.6 MB
Tags Linux glibc 2.17+ x86-64 PyPy 3.7 PyPy 3.7 7.3
SHA-256 checksum
How to use checksums
b591167c2d817e72e5120e32781fcb1cf7e9b59f078ed60963e8ee2d6efbbb77
BLAKE2b-256 checksum
How to use checksums
8cdf065153aed100cb8b3aa776ed055e4c2dc40ae4f9335ee711e6e4d2ee7883
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release files / lightseq-3.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL lightseq-3.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 243.6 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
9b21dbc542e54f7d37b088a5f6da75540c76a15fe85b772bb6972f69d3ab3ae1
BLAKE2b-256 checksum
How to use checksums
91982b66df68b2e2da98dbb02b7cc6bf5a89cb46a641ef44cbeda2e51ad86f18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release files / lightseq-3.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL lightseq-3.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 243.6 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
a9de4f630d66b0e99c62ccdced9e4afc6903a6430e173abe367771a03417bd3d
BLAKE2b-256 checksum
How to use checksums
ad9cf9c459169c35dc1f0c1031c95005e9f846dac20c931adcae300564adabb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release files / lightseq-3.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL lightseq-3.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 243.6 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
6413091fffff567982fb5559c1ce803e2ef7855ae6bab04d16c22b129fd870f7
BLAKE2b-256 checksum
How to use checksums
c4b59a8c1eb6fe228cf568a89ddf2d84205f5e575cc72963fc287f71117d0a7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release files / lightseq-3.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL lightseq-3.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 243.6 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
9faeb8f294822503190bba526ae96049988402f9c348ae91bc9874fd4ea71ac2
BLAKE2b-256 checksum
How to use checksums
adb3a433f415b0b25868e72485cf7102b81ebf6085a5e477032f8317d384a16f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release files / lightseq-3.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL lightseq-3.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 243.6 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
558e4a76fcdd1fcb7b8f15cde9cf4857e9e7b79e3e6b357c9abbb37bfde2808b
BLAKE2b-256 checksum
How to use checksums
c01d9abdafa205ec2b2cad42602e5972a7e7adb8571e3394e65037140ca4d34d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page