* add our readme * add live demo video * update README --------- Co-authored-by: syx <yixinsong@sjtu.edu.cn> |
||
---|---|---|
.devops | ||
.github | ||
ci | ||
cmake | ||
common | ||
docs | ||
examples | ||
gguf-py | ||
grammars | ||
media | ||
models | ||
pocs | ||
prompts | ||
scripts | ||
spm-headers | ||
tests | ||
.clang-tidy | ||
.dockerignore | ||
.ecrc | ||
.editorconfig | ||
.flake8 | ||
.gitignore | ||
.pre-commit-config.yaml | ||
build.zig | ||
CMakeLists.txt | ||
codecov.yml | ||
convert-baichuan-hf-to-gguf.py | ||
convert-hf-to-gguf.py | ||
convert-hf-to-powerinfer-gguf.py | ||
convert-llama-ggml-to-gguf.py | ||
convert-lora-to-ggml.py | ||
convert-persimmon-to-gguf.py | ||
convert.py | ||
flake.lock | ||
flake.nix | ||
ggml-alloc.c | ||
ggml-alloc.h | ||
ggml-backend-impl.h | ||
ggml-backend.c | ||
ggml-backend.h | ||
ggml-cuda.cu | ||
ggml-cuda.h | ||
ggml-impl.h | ||
ggml-metal.h | ||
ggml-metal.m | ||
ggml-metal.metal | ||
ggml-mpi.c | ||
ggml-mpi.h | ||
ggml-opencl.cpp | ||
ggml-opencl.h | ||
ggml-quants.c | ||
ggml-quants.h | ||
ggml.c | ||
ggml.h | ||
LICENSE | ||
llama.cpp | ||
llama.h | ||
Makefile | ||
mypy.ini | ||
Package.swift | ||
README.md | ||
requirements.txt | ||
run_with_preset.py | ||
SHA256SUMS | ||
unicode.h |
PowerInfer: Fast Large Language Model Serving with a Consumer-grade GPU
Demo 🔥
https://github.com/hodlen/PowerInfer/assets/34213478/b782ccc8-0a2a-42b6-a6aa-07b2224a66f7
The demo running environment consists of a single 4090 GPU, the model is Falcon (ReLU)-40B, and the precision is FP16.
Abstract
We introduce PowerInfer, a high-speed Large Language Model (LLM) inference engine on a personal computer (PC) equipped with a single consumer-grade GPU. The key underlying the design of PowerInfer is exploiting the high locality inherent in LLM inference, characterized by a power-law distribution in neuron activation. This distribution indicates that a small subset of neurons, termed hot neurons, are consistently activated across inputs, while the majority, cold neurons, vary based on specific inputs. PowerInfer exploits such an insight to design a GPU-CPU hybrid inference engine: hot-activated neurons are preloaded onto the GPU for fast access, while cold-activated neurons are computed on the CPU, thus significantly reducing GPU memory demands and CPU-GPU data transfers. PowerInfer further integrates adaptive predictors and neuron-aware sparse operators, optimizing the efficiency of neuron activation and computational sparsity. Evaluation shows that PowerInfer attains an average token generation rate of 13.20 tokens/s, with a peak of 29.08 tokens/s, across various LLMs (including OPT-175B) on a single NVIDIA RTX 4090 GPU, only 18% lower than that achieved by a top-tier server-grade A100 GPU. This significantly outperforms llama.cpp by up to 11.69x while retaining model accuracy.
Feature
PowerInfer is a fast and easy-to-use inference engine for deploying LLM locally. Interestingly, we observe that in ReLU LLM, every neuron is an expert! And a small subset of neurons consistently contributes to the output. PowerInfer is fast with:
- Exploiting the high locality in LLM infernece
- Neuron-aware hybrid CPU/GPU sparse operator
- Neuron granularity offloading
PowerInfer is flexible and easy to use with:
- Integration with popular ReLU-sparse models
- Low-latency serving locally with single consumer-grade GPU
PowerInfer supports the following models:
- Falcon-40B model
- Llama family models
The SparseLLM Team is currently converting the Mistral-7B model to a sparser version. Stay tuned!
Getting Started
Setup & Installation
Get the Code
git clone https://github.com/hodlen/PowerInfer
cd PowerInfer
Build
In order to build PowerInfer you have two different options.
- Using
make
:- On Linux or MacOS:
make
- On Linux or MacOS:
- Using
CMake
:- If you have one GPU:
mkdir build cd build cmake .. -DLLAMA_CUBLAS=ON cmake --build . --config Release
- If you just CPU:
mkdir build cd build cmake .. cmake --build . --config Release
Model Weights
Base Model | GGUF Format Link | Original Model |
---|---|---|
LLaMA(ReLU)-2-7B | PowerInfer/ReluLLaMA-13B-PowerInfer-GGUF | SparseLLM/ReluLLaMA-7B |
LLaMA(ReLU)-2-13B | PowerInfer/ReluLLaMA-13B-PowerInfer-GGUF | SparseLLM/ReluLLaMA-13B |
Falcon(ReLU)-40B | PowerInfer/ReluLLaMA-13B-PowerInfer-GGUF | SparseLLM/ReluFalcon-40B |
Inference
- If you just have CPU:
./build/bin/main -m /PATH/TO/MODEL -n $(output_token_count) -t $(thread_num) -p $(prompt)
- If you have CPU with one consumer grade GPU:
./build/bin/main -m /PATH/TO/MODEL -n $(output_token_count) -t $(thread_num) -p $(prompt)
Evaluation


PowerInfer achieves up to 11x and 8x speedup for fp16 and int4 model!
TODOs
We will release the code and data in the following order, please stay tuned!
- Release core code of PowerInfer, supporting Llama-2, Falcon-40B.
- Release perplexity evaluation code
- Support Metal for Mac
- Release predictor training code
- Support online split for FFN network
- Support Multi-GPU
Citation
If you find PowerInfer useful or relevant to your project and research, please kindly cite our paper:
Stay Tune
Acknowledgement
We are thankful for the easily modifiable operator library ggml and execution runtime provided by llama.cpp. We also extend our gratitude to THUNLP for their support of ReLU-based sparse models. We also appreciate the research of DejaVu, which inspires PowerInfer.