preemo_text-generation-infe.../README.md

86 lines
2.0 KiB
Markdown
Raw Normal View History

# Text Generation Inference
2022-10-08 04:30:12 -06:00
2022-10-18 07:19:03 -06:00
<div align="center">
2022-10-18 07:19:03 -06:00
![architecture](assets/architecture.jpg)
</div>
A Rust and gRPC server for text generation inference.
2022-10-18 07:19:03 -06:00
2022-10-27 06:25:29 -06:00
## Features
2022-10-27 06:25:29 -06:00
- [Dynamic bathing of incoming requests](https://github.com/huggingface/text-generation-inference/blob/main/router/src/batcher.rs#L88) for increased total throughput
- Quantization with [bitsandbytes](https://github.com/TimDettmers/bitsandbytes)
2022-10-27 06:25:29 -06:00
- [Safetensors](https://github.com/huggingface/safetensors) weight loading
- 45ms per token generation for BLOOM with 8xA100 80GB
## Supported models
2022-10-27 06:25:29 -06:00
- BLOOM
- BLOOM-560m
## Load Tests for BLOOM
2022-10-27 06:25:29 -06:00
See `k6/load_test.js`
2022-10-18 07:19:03 -06:00
| | avg | min | med | max | p(90) | p(95) | RPS |
|--------------------------------------------------------------|-----------|--------------|-----------|------------|-----------|-----------|----------|
| [Original code](https://github.com/huggingface/transformers_bloom_parallel) | 8.9s | 1s | 9.12s | 16.69s | 13.7s | 14.26s | 5.9 |
2022-10-27 06:25:29 -06:00
| New batching logic | **5.44s** | **959.53ms** | **5.28s** | **13.12s** | **7.78s** | **8.92s** | **9.08** |
2022-10-08 04:30:12 -06:00
## Install
```shell
2022-10-18 07:19:03 -06:00
make install
2022-10-08 04:30:12 -06:00
```
2022-10-18 07:19:03 -06:00
## Run
2022-10-08 04:30:12 -06:00
2022-10-27 06:25:29 -06:00
### BLOOM 560-m
2022-10-08 04:30:12 -06:00
```shell
2022-10-18 07:19:03 -06:00
make run-bloom-560m
2022-10-08 04:30:12 -06:00
```
2022-10-27 06:25:29 -06:00
### BLOOM
First you need to download the weights:
```shell
make download-bloom
```
```shell
make run-bloom # Requires 8xA100 80GB
```
You can also quantize the weights with bitsandbytes to reduce the VRAM requirement:
```shell
make run-bloom-quantize # Requires 8xA100 40GB
```
2022-10-18 07:19:03 -06:00
## Test
2022-10-08 04:30:12 -06:00
```shell
2022-10-18 07:19:03 -06:00
curl 127.0.0.1:3000/generate \
-v \
2022-10-18 07:19:03 -06:00
-X POST \
-d '{"inputs":"Testing API","parameters":{"max_new_tokens":9}}' \
-H 'Content-Type: application/json'
2022-10-08 04:30:12 -06:00
```
## Develop
```shell
make server-dev
make router-dev
```
2022-10-08 04:30:12 -06:00
## TODO:
- [ ] Support AutoModelForSeq2SeqLM
- [ ] Add tests for the `server/model` logic
- [ ] Backport custom CUDA kernels to Transformers
- [ ] Install safetensors with pip