이 프로젝트는 더 이상 Intel에 의해 유지 관리되지 않습니다.
Intel은 유지 관리, 버그 수정, 새로운 릴리스 또는 업데이트를 포함하되 이에 국한되지 않는 이 프로젝트에 대한 개발 및 기여를 중단했습니다.
Intel은 더 이상 이 프로젝트에 대한 패치(patches)를 받지 않습니다.
Neural Speed는 Intel Neural Compressor를 통해 구동되는 최첨단 (SOTA) 저비트 양자화 (low-bit quantization)를 통해 Intel 플랫폼에서 대규모 언어 모델 (LLMs)의 효율적인 추론 (inference)을 지원하도록 설계된 혁신적인 라이브러리입니다. 이 작업은 llama.cpp에서 영감을 받았으며, 2023년 NeurIPS에서의 혁신을 통해 Intel 플랫폼에 맞게 더욱 최적화되었습니다.
- N-비트 가중치 (int1, int2, int3, int4, int5, int6, int7 및 int8)를 위해 ISA (AMX, VNNI, AVX512F, AVX_VNNI 및 AVX2)를 갖춘 CPU 상의 고도로 최적화된 커널 (kernels). 상세 내용 참조
- llama.cpp와 비교하여 인기 있는 LLM에서 최대 40배의 성능 향상. 상세 내용 참조
- CPU 상의 소켓/노드 간 텐서 병렬화 (Tensor parallelism). 상세 내용 참조
Neural Speed는 활발히 개발 중이므로 API는 변경될 수 있습니다.
| 하드웨어 | 지원 여부 |
|---|
| Intel Xeon Scalable Processors | ✔ |
| ... | |
Llama2, ChatGLM2, Baichuan2, Qwen, Mistral, Whisper 등 Hugging Face의 PyTorch 형식으로 된 거의 모든 LLM을 지원합니다. 선호하는 LLM이 작동하지 않으면 이슈(issue)를 제출해 주세요.
Llama2, Falcon, MPT, Bloom 등 GGUF 형식의 일반적인 LLM을 지원합니다. 더 많은 모델이 추가될 예정입니다. 상세 내용을 확인하세요.
pip install -r requirements.txt
pip install neural-speed
pip install .
참고: GCC는 버전 10 이상이 필요합니다.
Transformer와 유사한 API를 사용하려면 Intel Extension for Transformers를 설치하세요.
from transformers import AutoTokenizer, TextStreamer
from intel_extension_for_transformers.transformers import AutoModelForCausalLM
model_name = "Intel/neural-chat-7b-v3-1" # Hugging Face model_id 또는 로컬 모델
...
from transformers import AutoTokenizer, TextStreamer
from intel_extension_for_transformers.transformers import AutoModelForCausalLM
# Hugging Face의 GGUF 리포지토리를 지정하세요
...
from transformers import TextStreamer
from modelscope import AutoTokenizer
from intel_extension_for_transformers.transformers import AutoModelForCausalLM
...
Neural Speed는
Intel Extension for Transformers의 Neural Chat Server에서 사용될 수 있습니다.
config.yaml에 use_neural_speed: true를 추가하여 활성화할 수 있습니다.
Neural Speed 및 그 RTN 양자화 (quantization) (예시)를 사용하려면 optimization 키 섹션을 추가하세요.
device: "cpu"
# itrex int4 llm runtime optimization
optimization:
...
Neural Speed를 사용하고 GPT-Q 모델을 로드하려면 (예시) use_neural_speed 키와 use_gptq 키를 추가하세요.
device: "cpu"
use_neural_speed: true
use_gptq: true
더 자세한 내용은 Neural Chat을 참조하세요.
python scripts/run.py model-path --weight_dtype int4 -p "She opened the door and see"
# GGUF 모델이 Hugging Face에서 가져온 것이거나 llama.cpp에 의해 생성된 경우 이 단계를 건너뛰세요
python scripts/convert.py --outtype f32 --outfile ne-f32.bin EleutherAI/gpt-j-6b
# 양자화 (quantize) 스크립트를 사용하려면 Neural Speed의 바이너리 설치가 필요합니다
...
# Linux 및 WSL
OMP_NUM_THREADS=<physic_cores> numactl -m 0 -C 0-<physic_cores-1> python scripts/inference.py --model_name llama -m ne-q4_j.bin -c 512 -b 1024 -n 256 -t <physic_cores> --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 <physic_cores|P-cores> --color -p "She opened the door and see"
자세한 내용은 Advanced Usage를 참조하세요.
자신만의 모델을 추가하는 것을 고려할 수 있으며, 다음 문서를 따르시기 바랍니다: graph developer document.
성능 프로파일링 (performance profiling)을 위해 NEURAL_SPEED_VERBOSE 환경 변수를 활성화하세요.
사용 가능한 모드:
- 0: 전체 정보 출력: 평가 시간 및 연산자 프로파일링 (operator profiling).
NS_PROFILING을 설정해야 합니다.
를 ON으로 설정하고 다시 컴파일합니다. - 1: 평가 시간 출력. 각 평가에 소요된 시간.
- 2: 개별 연산자 (operator) 프로파일링. 모델 내의 성능 병목 지점 (performance bottleneck) 식별.
NS_PROFILING을 ON으로 설정하고 다시 컴파일해야 합니다.