• Stars
    star
    147
  • Rank 251,347 (Top 5 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 1 year ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An open-source cloud-native of large multi-modal models (LMMs) serving framework.

☄️ RunGPT

RunGPT: An open-source cloud-native large-scale multimodal model serving framework

"A playful and whimsical vector art of a Stochastic Tigger, wearing a t-shirt with a "GPT" text printed logo, surrounded by colorful geometric shapes. –ar 1:1 –upbeta"

— Prompts and logo art was produced with PromptPerfect & Stable Diffusion X

PyPI PyPI - License

RunGPT is an open-source cloud-native large-scale language models (LLMs) serving framework. It is designed to simplify the deployment and management of large language models, on a distributed cluster of GPUs. We aim to make it a one-stop solution for a centralized and accessible place to gather techniques for optimizing LLM and make them easy to use for everyone.

Table of contents

Features

RunGPT provides the following features to make it easy to deploy and serve large language models (LLMs) at scale:

  • Scalable architecture for handling high traffic loads
  • Optimized for low-latency inference
  • Automatic model partitioning and distribution across multiple GPUs
  • Centralized model management and monitoring
  • REST API for easy integration with existing applications

Updates

  • 2023-08-22: The OpenGPT is now renamed to RunGPT. We have also released the first version v0.1.0 of RunGPT. You can install it with pip install rungpt.
  • 2023-05-12: 🎉We have released the first version v0.0.1 of OpenGPT. You can install it with pip install open_gpt_torch.

Get Started

Installation

Install the package with pip:

pip install rungpt

Quickstart

import run_gpt

model = run_gpt.create_model(
    'stabilityai/stablelm-tuned-alpha-3b', device='cuda', precision='fp16'
)

prompt = "The quick brown fox jumps over the lazy dog."

output = model.generate(
    prompt,
    max_length=100,
    temperature=0.9,
    top_k=50,
    top_p=0.95,
    repetition_penalty=1.2,
    do_sample=True,
    num_return_sequences=1,
)

We use the stabilityai/stablelm-tuned-alpha-3b as the open example model as it is relatively small and fast to download.

Warning In the above example, we use precision='fp16' to reduce the memory usage and speed up the inference with some loss in accuracy on text generation tasks. You can also use precision='fp32' instead as you like for better performance.

Note It usually takes a while (several minutes) for the first time to download and load the model into the memory.

In most cases of large model serving, the model cannot fit into a single GPU. To solve this problem, we also provide a device_map option (supported by accecleate package) to automatically partition the model and distribute it across multiple GPUs:

model = run_gpt.create_model(
    'stabilityai/stablelm-tuned-alpha-3b', precision='fp16', device_map='balanced'
)

In the above example, device_map="balanced" evenly split the model on all available GPUs, making it possible for you to serve large models.

Note The device_map option is supported by the accelerate package.

See examples on how to use rungpt with different models. 🔥

Build a model serving in one line

To do so, you can use the serve command:

rungpt serve stabilityai/stablelm-tuned-alpha-3b --precision fp16 --device_map balanced

💡 Tip: you can inspect the available options with rungpt serve --help.

This will start a gRPC and HTTP server listening on port 51000 and 52000 respectively. Once the server is ready, as shown below:

Click to expand

You can then send requests to the server:

import requests

prompt = "Once upon a time,"

response = requests.post(
    "http://localhost:51000/generate",
    json={
        "prompt": prompt,
        "max_length": 100,
        "temperature": 0.9,
        "top_k": 50,
        "top_p": 0.95,
        "repetition_penalty": 1.2,
        "do_sample": True,
        "num_return_sequences": 1,
    },
)

What's more, we also provide a Python client (inference-client) for you to easily interact with the server:

from run_gpt import Client

client = Client()

# connect to the model server
model = client.get_model(endpoint='grpc://0.0.0.0:51000')

prompt = "Once upon a time,"

output = model.generate(
    prompt,
    max_length=100,
    temperature=0.9,
    top_k=50,
    top_p=0.95,
    repetition_penalty=1.2,
    do_sample=True,
    num_return_sequences=1,
)

The output has the same format as the one from the OpenAI's Python API:

{ "id": "18d92585-7b66-4b7c-b818-71287c122c50", 
  "object": "text_completion", 
  "created": 1692610173, 
  "choices": [{"text": "Once upon a time, there was an old man who lived in the forest. He had no children", 
              "finish_reason": "length", 
              "index": 0.0}], 
  "prompt": "Once upon a time,", 
  "usage": {"completion_tokens": 21, "total_tokens": 27, "prompt_tokens": 6}}

For the streaming output, you can install sseclient-py first:

pip install sseclient-py

And send the request to http://localhost:51000/generate_stream with the same payload.

import sseclient
import requests

prompt = "Once upon a time,"

response = requests.post(
    "http://localhost:51000/generate_stream",
    json={
        "prompt": prompt,
        "max_length": 100,
        "temperature": 0.9,
        "top_k": 50,
        "top_p": 0.95,
        "repetition_penalty": 1.2,
        "do_sample": True,
        "num_return_sequences": 1,
    },
    stream=True,
)
client = sseclient.SSEClient(response)
for event in client.events():
    print(event.data)

And the output will be streamed back to you (only show 3 iterations here):

{ "id": "18d92585-7b66-4b7c-b818-71287c122c51", 
  "object": "text_completion", 
  "created": 1692610173, 
  "choices": [{"text": " there", "finish_reason": None, "index": 0.0}], 
  "prompt": "Once upon a time,", 
  "usage": {"completion_tokens": 1, "total_tokens": 7, "prompt_tokens": 6}},
{ "id": "18d92585-7b66-4b7c-b818-71287c122c52", 
  "object": "text_completion", 
  "created": 1692610173, 
  "choices": [{"text": "was", "finish_reason": None, "index": 0.0}], 
  "prompt": None, 
  "usage": {"completion_tokens": 2, "total_tokens": 9, "prompt_tokens": 7}},
{ "id": "18d92585-7b66-4b7c-b818-71287c122c53", 
  "object": "text_completion", 
  "created": 1692610173, 
  "choices": [{"text": "an", "finish_reason": None, "index": 0.0}], 
  "prompt": None, 
  "usage": {"completion_tokens": 3, "total_tokens": 11, "prompt_tokens": 8}}

We also support chat mode, which is useful for interactive applications. The inputs for chat should be a list of dictionaries which contain role and content. For example:

import requests

messages = [
    {"role": "user", "content": "Hello!"},
]

response = requests.post(
    "http://localhost:51000/chat",
    json={
        "messages": messages,
        "max_length": 100,
        "temperature": 0.9,
        "top_k": 50,
        "top_p": 0.95,
        "repetition_penalty": 1.2,
        "do_sample": True,
        "num_return_sequences": 1,
    },
)

The response will be:

{"id": "18d92585-7b66-4b7c-b818-71287c122c57", 
  "object": "chat.completion", 
  "created": 1692610173, 
  "choices": [{"message": {
                            "role": "assistant",
                            "content": "\n\nHello there, how may I assist you today?",
                        }, 
              "finish_reason": "stop", "index": 0.0}], 
  "prompt": "Hello there!", 
  "usage": {"completion_tokens": 12, "total_tokens": 15, "prompt_tokens": 3}}

You can also replace the chat with chat_stream to get the streaming output.

Cloud-native deployment

You can also deploy the server to a cloud provider like Jina Cloud or AWS. To do so, you can use deploy command:

Jina Cloud

using predefined executor

rungpt deploy stabilityai/stablelm-tuned-alpha-3b --precision fp16 --device_map balanced --cloud jina --replicas 1

It will give you a HTTP url and a gRPC url by default:

https://{random-host-name}-http.wolf.jina.ai
grpcs://{random-host-name}-grpc.wolf.jina.ai

AWS

TBD

Benchmark

We have done some benchmarking on different model architectures and different configurations (whether to use quantization, torch.compile and page attention ...), regards to the latency, throughput (prefill stage && the whole decoding process) and perplexity.

The script for benchmarking locates at scripts/benchmark.py. You can run the scripts to get the benchmarking results.

Environment Setting

We use a single RTX3090 (cuda version is 11.8) for all benchmarking except for Llama-2-13b (2*RTX3090). We use:

torch==2.0.1 (without torch.compile) / torch==2.1.0.dev20230803 (with torch.compile)
bitsandbytes==0.41.0
transformers==4.31.0
triton==2.0.0

Model Candidates

Model_Name
meta-llama/Llama-2-7b-hf
mosaicml/mpt-7b
stabilityai/stablelm-base-alpha-7b
EleutherAI/gpt-j-6B

Benchmarking Results

  • Latency/throughput for different models (precision: fp16)
Model_Name average_prefill_latency(ms/token) average_prefill_throughput(token/s) average_decode_latency(ms/token) average_decode_throughput(token/s)
meta-llama/Llama-2-7b-hf 49 20.619 49.4 20.054
meta-llama/Llama-2-13b-hf 175 5.727 188.27 4.836
mosaicml/mpt-7b 27 37.527 28.04 35.312
stabilityai/stablelm-base-alpha-7b 50 20.09 45.73 21.878
EleutherAI/gpt-j-6B 75 13.301 76.15 11.181
  • Latency/throughput for different models using torch.compile (precision: fp16)

Warning torch.compile doesn't support Flash-Attention based model like MPT. Also, it cannot be used in multi-GPUs environment.

Model_Name average_prefill_latency(ms/token) average_prefill_throughput(token/s) average_decode_latency(ms/token) average_decode_throughput(token/s)
meta-llama/Llama-2-7b-hf 25 40.644 26.54 37.75
meta-llama/Llama-2-13b-hf - - - -
mosaicml/mpt-7b - - - -
stabilityai/stablelm-base-alpha-7b 44 22.522 42.97 21.413
EleutherAI/gpt-j-6B 32 31.488 33.89 25.105
  • Latency/throughput for different models using quantization (precision: fp16 / bit8 / bit4)
prefill latency (ms/token) prefill throughput (tokens/s) decode latency (ms/token) decode throughput (tokens/s)
fp16 bit8 bit4 fp16 bit8 bit4 fp16 bit8 bit4 fp16 bit8 bit4
meta-llama/Llama-2-7b-hf 49 301 125 20.619 3.325 8.015 49.4 256.44 112.22 20.054 3.9 8.918
meta-llama/Llama-2-13b-hf 175 974 376 5.727 1.027 2.662 182.27 796.32 349.93 4.836 1.144 2.662
mosaicml/mpt-7b 27 139 86 37.527 7.222 11.6 28.04 141.04 94.22 35.312 7.021 10.507
stabilityai/stablelm-base-alpha-7b 50 164 156 20.09 6.134 6.408 45.73 148.53 147.56 21.878 6.947 6.994
EleutherAI/gpt-j-6B 75 368 162 13.301 2.724 6.195 76.15 365.51 138.44 11.181 2.327 5.642
  • Perplexity for different models using quantization (precision: fp16 / bit8 / bit4)

Notice From this benchmark we see that quantization doesn't affect the perplexity of the model too much.

wikitext2 ptb c4
fp16 bit8 bit4 fp16 bit8 bit4 fp16 bit8 bit4
meta-llama/Llama-2-7b-hf 5.4721 5.506 5.6437 22.9483 23.8797 25.0556 6.9727 7.0098 7.1623
meta-llama/Llama-2-13b-hf 4.8837 4.9229 4.9811 27.6802 27.9665 28.8417 6.4677 6.4884 6.566
mosaicml/mpt-7b 7.6829 7.7256 7.9869 10.6002 10.6743 10.9486 9.6001 9.6457 9.879
stabilityai/stablelm-base-alpha-7b 14.1886 14.268 15.9817 19.2968 19.4904 21.3513 48.222 48.3384 57.022
EleutherAI/gpt-j-6B 8.8563 8.8786 9.0301 13.5946 13.6137 13.784 11.7114 11.7293 11.8929
  • Latency/throughput for different models using vllm (precision: fp16)

Warning vllm brings a significant improvement in latency and throughput, but it is not compatible with streaming output, so we don't release it yet.

prefill latency (ms/token) prefill throughput (tokens/s) decode latency (ms/token) decode throughput (tokens/s)
using vllm baseline using vllm baseline using vllm baseline using vllm baseline
meta-llama/Llama-2-7b-hf 29 49 34.939 20.619 20.34 49.40 48.67 20.054

Contributing

We welcome contributions from the community! To contribute, please submit a pull request following our contributing guidelines.

License

RunGPT is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.

More Repositories

1

jina

☁️ Build multimodal AI applications with cloud-native stack
Python
20,716
star
2

clip-as-service

🏄 Scalable embedding, reasoning, ranking for images and sentences with CLIP
Python
12,150
star
3

reader

Convert any URL to an LLM-friendly input with a simple prefix https://r.jina.ai/
TypeScript
6,640
star
4

dalle-flow

🌊 A Human-in-the-Loop workflow for creating HD images from text
Python
2,831
star
5

dev-gpt

Your Virtual Development Team
Python
1,756
star
6

langchain-serve

⚡ Langchain apps in production using Jina & FastAPI
Python
1,601
star
7

finetuner

🎯 Task-oriented embedding tuning for BERT, CLIP, etc.
Python
1,455
star
8

thinkgpt

Agent techniques to augment your LLM and push it beyong its limits
Python
1,402
star
9

auto-gpt-web

Set Your Goals, AI Achieves Them.
TypeScript
749
star
10

agentchain

Chain together LLMs for reasoning & orchestrate multiple large models for accomplishing complex tasks
Python
583
star
11

docarray

The data structure for unstructured data
Python
522
star
12

vectordb

A Python vector database you just need - no more, no less.
Python
519
star
13

jcloud

Simplify deploying and managing Jina projects on Jina Cloud
Python
294
star
14

jina-video-chat

Python
266
star
15

jinabox.js

A lightweight, customizable omnibox in Javascript, for use with a Jina backend.
JavaScript
219
star
16

annlite

⚡ A fast embedded library for approximate nearest neighbor search
Python
216
star
17

fastapi-serve

FastAPI to the Cloud, Batteries Included! ☁️🔋🚀
Python
139
star
18

jina-hub

An open-registry for hosting Jina executors via container images
Python
103
star
19

dashboard

Interactive UI for analyzing Jina logs, designing Flows and viewing Hub images
TypeScript
100
star
20

GoldRetriever

Create and host retrieval plugins for ChatGPT in one click
Python
63
star
21

jinaai-py

Python
48
star
22

example-multimodal-fashion-search

Input text or image, get back matching image fashion results, using Jina, DocArray, and CLIP
Python
45
star
23

streamlit-jina

Streamlit component for Jina neural search
Python
37
star
24

docs

Jina V1 Official Documentation. For the latest one, please check out https://docs.jina.ai
HTML
35
star
25

jinaai-js

TypeScript
28
star
26

executors

internal-only
Python
28
star
27

jerboa

LLM finetuning
Python
27
star
28

jina-ai.github.io

Homepage of Jina AI Limited
HTML
27
star
29

example-meme-search

Meme search engine built with Jina neural search framework. Search with captions or image files to find matching memes.
Python
23
star
30

example-app-store

App store search example, using Jina as backend and Streamlit as frontend
Python
21
star
31

docsQA-ui

Web UI for docsQA. Main branch: https://jina-docqa-ui.netlify.app/
TypeScript
20
star
32

example-speech-to-image

An example of building a speech to image generation pipeline with Jina, Whisper and StableDiffusion
Python
20
star
33

workshops

Jupyter Notebook
19
star
34

jina-hubble-sdk

Python API for authentication, resource management with Hubble
Python
19
star
35

product-recommendation-redis-docarray

Python
18
star
36

career

Find out job opportunities at Jina AI
17
star
37

executor-3d-encoder

An executor that wraps 3D mesh models and encodes 3D content documents to d-dimension vector.
Python
16
star
38

client-go

Golang Client for Jina (https://github.com/jina-ai/jina)
Go
16
star
39

benchmark

Benchmark environment and results of different versions of Jina.
Python
14
star
40

action-hub-builder

Simple interface for building & validating Jina Hub executors.
Python
12
star
41

inference-client

Python
12
star
42

executor-hnsw-postgres

A production-ready, scalable Indexer for the Jina neural search framework, based on HNSW and PSQL
Python
12
star
43

now

Python
11
star
44

cookiecutter-jina

Cookiecutter template for a Jina project
Python
10
star
45

simple-jina-examples

Python
9
star
46

executor-simpleindexer

Simple Indexer
Python
9
star
47

executor-clip-encoder

Encoder that embeds documents using either the CLIP vision encoder or the CLIP text encoder, depending on the content type of the document.
Python
9
star
48

cloud-ops

Python
8
star
49

good-first-issues

Issues that don't fit under Jina's other repos!
8
star
50

api

API schema of Jina command line interface exposed as JSON and YAML files.
HTML
8
star
51

inference-client-js

TypeScript
7
star
52

executor-text-transformers-dprreader-ranker

DPRReaderRanker
Python
7
star
53

executor-video-loader

Python
7
star
54

executor-image-clip-encoder

CLIPImageEncoder is an image encoder that wraps the image embedding functionality using the CLIP
Python
7
star
55

.github

This repository stores github actions templates as described https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
7
star
56

GSoC

Google Summer of Code
7
star
57

example-wikipedia-recommendation

An example of graph embeddings for wikipedia page recommendations
Jupyter Notebook
6
star
58

executor-U100KIndexer

An Indexer that works out-of-the-box when you have less than 100K stored Documents
Python
6
star
59

devrel-heartmaker

Heart mosaics of your GitHub contributors
Python
6
star
60

executor-text-transformers-torch-encoder

**TransformerTorchEncoder** wraps the torch-version of transformers from huggingface. It encodes text data into dense vectors.
Python
6
star
61

executor-cases

Summarize all Executor patterns for Hubble
Python
5
star
62

executor-normalizer

Jina executor package normalizer
Python
5
star
63

auth

deprecated, use `jina-hubble-sdk`
Python
5
star
64

jina-commons

A collection of shared function for Jina Executor
Python
5
star
65

tutorial-notebooks

Jupyter Notebook
5
star
66

jina-paddle-hackathon

极纳 x 百度飞桨 黑客马拉松
Python
5
star
67

executor-image-preprocessor

An executor that performs standard pre-processing and normalization on images.
Python
5
star
68

jina-hackathon

Support repo for Jina X Hackathon - Sep 2020
5
star
69

executor-featurehasher

FeatureHasher
Python
4
star
70

jina-sagemaker

Jina Embedding Models on AWS SageMaker
Jupyter Notebook
4
star
71

stress-test

A collection of stress tests of Jina infrastructure
Python
4
star
72

executor-image-clip-classifier

Python
4
star
73

executor-text-transformerqa

**TransformerQAExecutor* wraps a question-answering model from huggingface and return relevant answers given questions and contexts/paragraphs.
Python
4
star
74

executor-faissindexer

A similarity search indexer based on Faiss. https://hub.jina.ai/executor/8gsd0tts
Python
4
star
75

hub-integration

Integration test for hub
Python
4
star
76

example-audio-search

Python
3
star
77

example-video-qa

This is an example of building a video QA with jina
TypeScript
3
star
78

jinad

Management of Jina on remote
Python
3
star
79

executor-indexers

Indexer Executors for Jina
Python
3
star
80

executor-text-dpr-encoder

Encode text into embeddings using the DPR model.
Python
3
star
81

legacy-examples

Unmaintained examples for Jina
Python
3
star
82

executor-clip-image

Executor for the pre-trained clip model. https://openai.com/blog/clip/
Python
3
star
83

executor-weaviate-indexer

Python
3
star
84

executor-doc2query

Python
3
star
85

executor-image-paddle-encoder

Python
3
star
86

jupyter-notebooks

Jupyter Notebook
3
star
87

executor-evaluator-ranking

Python
3
star
88

executor-yolov5

Python
3
star
89

executor-lightgbm-ranker

Python
3
star
90

terraform-jina-jinad-aws

Module for deploying JinaD on AWS
HCL
3
star
91

encoder-image-torch

The ImageTorchEncoder encodes Document content from a ndarray to an d-dimensional vector.
Python
3
star
92

example-odqa

Roff
2
star
93

executor-text-clip-encoder

Encode text into embeddings using the CLIP model.
Python
2
star
94

jina-ui

Monorepo for JinaJS and frontend projects
TypeScript
2
star
95

executor-audio-clip-encoder

Wraps the AudioCLIP model for generating embeddings for audio data for the Jina framework
Python
2
star
96

executor-matchmerger

**MatchMerger** Merges the results of shards by appending all matches.
Python
2
star
97

executor-image-niireader

Python
2
star
98

executor-image-normalizer

Executor that reads, resizes, crops and normalizes images.
Python
2
star
99

executor-vgg-audio-encoder

Python
2
star
100

executor-image-hasher

An executor to encode images using comparable hashing techniques. Useful for duplicate detection
Python
2
star