ipex-llm/python/llm/dev/benchmark/all-in-one
Wang, Jian4 9df70d95eb
Refactor bigdl.llm to ipex_llm (#24)
* Rename bigdl/llm to ipex_llm

* rm python/llm/src/bigdl

* from bigdl.llm to from ipex_llm
2024-03-22 15:41:21 +08:00
..
prompt Arc stress test (#9795) 2023-12-27 21:02:41 +08:00
config.yaml LLM: Add speculative benchmark on CPU/XPU (#10464) 2024-03-21 09:51:06 +08:00
README.md LLM: add int4+fp16 benchmark script for windows benchmarking (#10449) 2024-03-19 11:11:25 +08:00
run-arc.sh LLM: add benchmark scripts on GPU (#8916) 2023-09-07 18:08:17 +08:00
run-deepspeed-arc.sh LLM: add benchmark script for deepspeed autotp on gpu (#10380) 2024-03-12 15:19:57 +08:00
run-deepspeed-pvc.sh LLM: add benchmark script for deepspeed autotp on gpu (#10380) 2024-03-12 15:19:57 +08:00
run-deepspeed-spr.sh fix llm-init on deepspeed missing lib (#9419) 2023-11-10 13:51:24 +08:00
run-hbm.sh Add run-hbm.sh & add user guide for spr and hbm (#10357) 2024-03-12 16:15:27 +08:00
run-max-gpu.sh Enhance LLM GPU installation document (#9828) 2024-01-09 16:30:50 +08:00
run-spr.sh LLM: decoupling bigdl-llm and bigdl-nano (#9306) 2023-11-01 11:00:54 +08:00
run-stress-test.py Refactor bigdl.llm to ipex_llm (#24) 2024-03-22 15:41:21 +08:00
run.py Refactor bigdl.llm to ipex_llm (#24) 2024-03-22 15:41:21 +08:00
save.py Refactor bigdl.llm to ipex_llm (#24) 2024-03-22 15:41:21 +08:00

All in One Benchmark Test

All in one benchmark test allows users to test all the benchmarks and record them in a result CSV. Users can provide models and related information in config.yaml.

Before running, make sure to have bigdl-llm.

Dependencies

pip install omegaconf
pip install pandas

Install gperftools to use libtcmalloc.so for MAX GPU to get better performance:

conda install -c conda-forge -y gperftools=2.10

Config

Config YAML file has following format

repo_id:
  - 'THUDM/chatglm-6b'
  - 'THUDM/chatglm2-6b'
  - 'meta-llama/Llama-2-7b-chat-hf'
  # - 'liuhaotian/llava-v1.5-7b' # requires a LLAVA_REPO_DIR env variables pointing to the llava dir; added only for gpu win related test_api now
local_model_hub: 'path to your local model hub'
warm_up: 1
num_trials: 3
num_beams: 1 # default to greedy search
low_bit: 'sym_int4' # default to use 'sym_int4' (i.e. symmetric int4)
batch_size: 1 # default to 1
in_out_pairs:
  - '32-32'
  - '1024-128'
test_api:
  - "transformer_int4"
  - "native_int4"
  - "optimize_model"
  - "pytorch_autocast_bf16"
  # - "transformer_autocast_bf16"
  # - "ipex_fp16_gpu" # on Intel GPU
  # - "bigdl_fp16_gpu" # on Intel GPU
  # - "transformer_int4_gpu"  # on Intel GPU
  # - "optimize_model_gpu"  # on Intel GPU
  # - "deepspeed_transformer_int4_cpu" # on Intel SPR Server
  # - "transformer_int4_gpu_win" # on Intel GPU for Windows
  # - "transformer_int4_fp16_gpu_win" # on Intel GPU for Windows, use fp16 for non-linear layer
  # - "transformer_int4_loadlowbit_gpu_win" # on Intel GPU for Windows using load_low_bit API. Please make sure you have used the save.py to save the converted low bit model
cpu_embedding: False # whether put embedding to CPU (only avaiable now for gpu win related test_api)
streaming: False # whether output in streaming way (only avaiable now for gpu win related test_api)

(Optional) Save model in low bit

If you choose the transformer_int4_loadlowbit_gpu_win test API, you will need to save the model in low bit first.

Run python save.py will save all models declared in repo_id list into low bit models under local_model_hub folder.

Run

run python run.py, this will output results to results.csv.

For SPR performance, run bash run-spr.sh.

Note

The value of OMP_NUM_THREADS should be the same as the cpu cores specified by numactl -C.

Note

Please install torch nightly version to avoid Illegal instruction (core dumped) issue, you can follow the following command to install: pip install --pre --upgrade torch --index-url https://download.pytorch.org/whl/nightly/cpu

For ARC performance, run bash run-arc.sh.

For MAX GPU performance, run bash run-max-gpu.sh.