An innovative library for efficient LLM inference via low-bit quantization
An innovative library for efficient LLM inference via low-bit quantization
This project will no longer be maintained by Intel.
Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project.
Intel no longer accepts patches to this project.
Neural Speed is an innovative library designed to support the efficient inference of large language models (LLMs) on Intel platforms through the state-of-the-art (SOTA) low-bit quantization powered by Intel Neural Compressor. The work is inspired by llama.cpp and further optimized for Intel platforms with our innovations in NeurIPS' 2023
Neural Speed is under active development so APIs are subject to change.
| Hardware | Supported |
|---|---|
| Intel Xeon Scalable Processors | ✔ |
| Intel Xeon CPU Max Series | ✔ |
| Intel Core Processors | ✔ |
Support almost all the LLMs in PyTorch format from Hugging Face such as Llama2, ChatGLM2, Baichuan2, Qwen, Mistral, Whisper, etc. File an issue if your favorite LLM does not work.
Support typical LLMs in GGUF format such as Llama2, Falcon, MPT, Bloom etc. More are coming. Check out the details.
pip install -r requirements.txt
pip install neural-speedpip install .Note: GCC requires version 10+
Install Intel Extension for Transformers to use Transformer-like APIs.
………Neural Speed can be used in Neural Chat Server of Intel Extension for Transformers. You can choose to enable it by adding use_neural_speed: true in config.yaml.
optimization key section to use Neural Speed and its RTN quantization (example).device: "cpu"
# itrex int4 llm runtime optimization
optimization:
use_neural_speed: true
optimization_type: "weight_only"
compute_dtype: "fp32"
weight_dtype: "int4"use_neural_speed and key use_gptq to use Neural Speed and load GPT-Q model (example).device: "cpu"
use_neural_speed: true
use_gptq: trueMore details please refer to Neural Chat.
python scripts/run.py model-path --weight_dtype int4 -p "She opened the door and see"# skip the step if GGUF model is from Hugging Face or generated by llama.cpp
python scripts/convert.py --outtype f32 --outfile ne-f32.bin EleutherAI/gpt-j-6b
# Using the quantize script requires a binary installation of Neural Speed
mkdir build&&cd build
cmake ..&&make -j
cd ..
python scripts/quantize.py --model_name gptj --model_file ne-f32.bin --out_file ne-q4_j.bin --build_dir ./build --weight_dtype int4 --alg sym# Linux and WSL
OMP_NUM_THREADS= numactl -m 0 -C 0- python scripts/inference.py --model_name llama -m ne-q4_j.bin -c 512 -b 1024 -n 256 -t --color -p "She opened the door and see"# Windows
python scripts/inference.py --model_name llama -m ne-q4_j.bin -c 512 -b 1024 -n 256 -t --color -p "She opened the door and see"Please refer to Advanced Usage for more details.
You can consider adding your own models, please follow the document: graph developer document.
Enable NEURAL_SPEED_VERBOSE environment variable for performance profiling.
Available modes:
NS_PROFILING to ON and recompile.NS_PROFILING to ON and recompile.No open issues yet, or sync has not completed.