char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
6861f6509
char/aliceai-t5-moe
llama.cpp for CANN
- Background
- News
- OS
- Hardware
- Model Supports
- DataType Supports
- Docker
- Linux
- Environment variable setup
- TODO
Background
Ascend NPU is a range of AI processors using Neural Processing Unit. It will efficiently handle matrix-matrix multiplication, dot-product and scalars.
CANN (Compute Architecture for Neural Networks) is a heterogeneous computing architecture for AI scenarios, providing support for multiple AI frameworks on the top and serving AI processors and programming at the bottom. It plays a crucial role in bridging the gap between upper and lower layers, and is a key platform for improving the computing efficiency of Ascend AI processors. Meanwhile, it offers a highly efficient and easy-to-use programming interface for diverse application scenarios, allowing users to rapidly build AI applications and services based on the Ascend platform.
Llama.cpp + CANN
The llama.cpp CANN backend is designed to support Ascend NPU. It utilize the ability of AscendC and ACLNN which are integrated to CANN Toolkit and kernels to using Ascend NPU directly.
News
- 2024.11
- Support F16 and F32 data type model for Ascend 310P NPU.
- 2024.8
- Support
Q4_0andQ8_0data type for Ascend NPU.
- Support
- 2024.7
- Create CANN backend for Ascend NPU.
OS
| OS | Status | Verified |
|---|---|---|
| Linux | Support | Ubuntu 22.04, OpenEuler22.03 |
Hardware
Ascend NPU
You can retrieve your Ascend device IDs using the following command:
lspci -n | grep -Eo '19e5:d[0-9a-f]{3}' | cut -d: -f2
Devices
| Device Id | Product Series | Product Models | Chip Model | Verified Status |
|---|---|---|---|---|
| d803 | Atlas A3 Train | 910C | ||
| d803 | Atlas A3 Infer | 910C | ||
| d802 | Atlas A2 Train | 910B | ||
| d802 | Atlas A2 Infer | Atlas 300I A2 | 910B | Support |
| d801 | Atlas Train | 910 | ||
| d500 | Atlas Infer | Atlas 300I Duo | 310P | Support |
Notes:
- If you have trouble with Ascend NPU device, please create a issue with [CANN] prefix/tag.
- If you run successfully with your Ascend NPU device, please help update the upper table.
Model Supports
<details> <summary>Text-only</summary>| Model Name | FP16 | Q4_0 | Q8_0 |
|---|---|---|---|
| Llama-2 | √ | √ | √ |
| Llama-3 | √ | √ | √ |
| Mistral-7B | √ | √ | √ |
| Mistral MOE | √ | √ | √ |
| DBRX | - | - | - |
| Falcon | √ | √ | √ |
| Chinese LLaMA/Alpaca | √ | √ | √ |
| Vigogne(French) | √ | √ | √ |
| BERT | x | x | x |
| Koala | √ | √ | √ |
| Baichuan | √ | √ | √ |
| Aquila 1 & 2 | √ | √ | √ |
| Starcoder models | √ | √ | √ |
| Refact | √ | √ | √ |
| MPT | √ | √ | √ |
| Bloom | √ | √ | √ |
| Yi models | √ | √ | √ |
| stablelm models | √ | √ | √ |
| DeepSeek models | x | x | x |
| Qwen models | √ | √ | √ |
| PLaMo-13B | √ | √ | √ |
| Phi models | √ | √ | √ |
| PhiMoE | √ | √ | √ |
| GPT-2 | √ | √ | √ |
| Orion | √ | √ | √ |
| InternlLM2 | √ | √ | √ |
| CodeShell | √ | √ | √ |
| Gemma | √ | √ | √ |
| Mamba | √ | √ | √ |
| Xverse | √ | √ | √ |
| command-r models | √ | √ | √ |
| Grok-1 | - | - | - |
| SEA-LION | √ | √ | √ |
| GritLM-7B | √ | √ | √ |
| OLMo | √ | √ | √ |
| OLMo 2 | √ | √ | √ |
| OLMoE | √ | √ | √ |
| Granite models | √ | √ | √ |
| GPT-NeoX | √ | √ | √ |
| Pythia | √ | √ | √ |
| Snowflake-Arctic MoE | - | - | - |
| Smaug | √ | √ | √ |
| Poro 34B | √ | √ | √ |
| Bitnet b1.58 models | √ | x | x |
| Flan-T5 | √ | √ | √ |
| Open Elm models | x | √ | √ |
| chatGLM3-6B + ChatGLM4-9b + GLMEdge-1.5b + GLMEdge-4b | √ | √ | √ |
| GLM-4-0414 | √ | √ | √ |
| SmolLM | √ | √ | √ |
| EXAONE-3.0-7.8B-Instruct | √ | √ | √ |
| FalconMamba Models | √ | √ | √ |
| Jais Models | - | x | x |
| Bielik-11B-v2.3 | √ | √ | √ |
| RWKV-6 | - | √ | √ |
| QRWKV-6 | √ | √ | √ |
| GigaChat-20B-A3B | x | x | x |
| Trillion-7B-preview | √ | √ | √ |
| Ling models | √ | √ | √ |
| Model Name | FP16 | Q4_0 | Q8_0 |
|---|---|---|---|
| LLaVA 1.5 models, LLaVA 1.6 models | x | x | x |
| BakLLaVA | √ | √ | √ |
| Obsidian | √ | - | - |
| ShareGPT4V | x | - | - |
| MobileVLM 1.7B/3B models | - | - | - |
| Yi-VL | - | - | - |
| Mini CPM | √ | √ | √ |
| Moondream | √ | √ | √ |
| Bunny | √ | - | - |
| GLM-EDGE | √ | √ | √ |
| Qwen2-VL | √ | √ | √ |
DataType Supports
| DataType | 910B | 310P |
|---|---|---|
| FP16 | Support | Support |
| Q8_0 | Support | Partial |
| Q4_0 | Support | Partial |
| BF16 | Support |
310P note
Q8_0: data transform / buffer path is implemented, andGET_ROWSis supported, but quantizedMUL_MAT/MUL_MAT_IDare not supported.Q4_0: data transform / buffer path is implemented, but quantizedMUL_MAT/MUL_MAT_IDare not supported.
Docker
Build Images
You can get a image with llama.cpp in one command.
docker build-t llama-cpp-cann-f .devops/llama-cli-cann.Dockerfile .
Run container
# Find all cards. npu-smi info# Select the cards that you want to use, make sure these cards are not used by someone. # Following using cards of device0. docker run--name llamacpp \--device /dev/davinci0 \--device /dev/davinci_manager \--device /dev/devmm_svm \--device /dev/hisi_hdc \-v /usr/local/dcmi:/usr/local/dcmi \-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \-v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \-v /PATH_TO_YOUR_MODELS/:/app/models \-it llama-cpp-cann \-m /app/models/MODEL_PATH \-ngl 32 \-p "Building a website can be done in 10 simple steps:"
Notes:
- You may need to install Ascend Driver and firmware on the host machine (Please refer to the Linux configuration for details).
Linux
I. Setup Environment
-
Configure Ascend user and group
sudo groupadd HwHiAiUsersudo useradd-g HwHiAiUser-d /home/HwHiAiUser-m HwHiAiUser-s /bin/bashsudo usermod-aG HwHiAiUser$ USER -
Install dependencies
Ubuntu/Debian:
sudo apt-get updatesudo apt-get install-y gcc python3 python3-pip linux-headers-$( uname -r ) RHEL/CentOS:
sudo yum makecachesudo yum install-y gcc python3 python3-pip kernel-headers-$( uname -r ) kernel-devel-$( uname -r ) -
Install CANN (driver + toolkit)
The
Ascend-cannpackage includes both the driver and toolkit.$ARCHcan bex86_64oraarch64,$CHIPcan be910bor310p.wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%208.5.T63/Ascend-cann_8.5.0_linux-$ ARCH .runsudo bash ./Ascend-cann_8.5.0_linux-$ ARCH .run--install wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%208.5.T63/Ascend-cann-$ CHIP -ops_8.5.0_linux-$ ARCH.runsudo bash ./Ascend-cann-$ CHIP -ops_8.5.0_linux-$ ARCH.run--install -
Verify installation
npu-smi infoIf device information is displayed correctly, the driver is functioning properly.
# Set environment variables (adjust path if needed) source /usr/local/Ascend/cann/set_env.shpython3 -c "import acl; print(acl.get_soc_name())" If the command outputs the chip model, the installation was successful.
II. Build llama.cpp
cmake -B build-DGGML_CANN=on -DCMAKE_BUILD_TYPE=release cmake --build build--config release
III. Run the inference
-
Retrieve and prepare model
You can refer to the general Obtaining and quantizing models guide for model prepration.
Notes:
- CANN backend only supports FP16/Q4_0/Q8_0 models currently.
-
Launch inference
There are two device selection modes:
- Single device: Use one device target specified by the user.
- Multiple devices: Automatically choose the devices with the same backend.
Device selection Parameter Single device --split-mode none --main-gpu DEVICE_ID Multiple devices --split-mode layer (default) Examples:
- Use device 0:
./build/bin/llama-cli -m path_to_model-p "Building a website can be done in 10 simple steps:" -n 400-e -ngl 33-sm none-mg 0- Use multiple devices:
./build/bin/llama-cli -m path_to_model-p "Building a website can be done in 10 simple steps:" -n 400-e -ngl 33-sm layer
GitHub contribution:
Please add the [CANN] prefix/tag in issues/PRs titles to help the CANN-team check/address them without delay.
Updates
Basic Flash Attention Support
The basic FA kernel with aclnnops has been added in aclnn_ops.cpp. Currently, the FA only supports the cases with FP16 KV tensors and NO logit softcap. Since the aclnn interface for flash attention cannot support the logit softcap, we will only update the quantized version in the future.
Authors from Peking University: Bizhao Shi (bshi@pku.edu.cn), Yuxin Yang (yxyang@pku.edu.cn), Ruiyang Ma (ruiyang@stu.pku.edu.cn), and Guojie Luo (gluo@pku.edu.cn).
We would like to thank Tuo Dai, Shanni Li, and all of the project maintainers from Huawei Technologies Co., Ltd for their help during the code development and pull request.
Environment variable setup
GGML_CANN_MEM_POOL
Specifies the memory pool management strategy, Default is vmm.
-
vmm: Utilizes a virtual memory manager pool. If hardware support for VMM is unavailable, falls back to the legacy (leg) memory pool.
-
prio: Employs a priority queue-based memory pool management.
-
leg: Uses a fixed-size buffer pool.
GGML_CANN_DISABLE_BUF_POOL_CLEAN
Controls automatic cleanup of the memory pool. This option is only effective when using the prio or leg memory pool strategies.
GGML_CANN_WEIGHT_NZ
Converting the matmul weight format from ND to NZ to improve performance. Enabled by default.
GGML_CANN_ACL_GRAPH
Operators are executed using ACL graph execution, rather than in op-by-op (eager) mode. Enabled by default. This option is only effective if USE_ACL_GRAPH was enabled at compilation time. To enable it, recompile using:
cmake -B build-DGGML_CANN=on -DCMAKE_BUILD_TYPE=release -DUSE_ACL_GRAPH=ON cmake --build build--config release
GGML_CANN_GRAPH_CACHE_CAPACITY
Maximum number of compiled CANN graphs kept in the LRU cache, default is 12. When the number of cached graphs exceeds this capacity, the least recently used graph will be evicted.
GGML_CANN_PREFILL_USE_GRAPH
Enable ACL graph execution during the prefill stage, default is false. This option is only effective when FA is enabled.
GGML_CANN_OPERATOR_FUSION
Enable operator fusion during computation, default is false. This option fuses compatible operators (e.g., ADD + RMS_NORM) to reduce overhead and improve performance.
1# llama.cpp for CANN 2 3- [Background](#background) 4- [News](#news) 5- [OS](#os) 6- [Hardware](#hardware) 7- [Model Supports](#model-supports) 8- [DataType Supports](#datatype-supports) 9- [Docker](#docker) 10- [Linux](#linux) 11- [Environment variable setup](#environment-variable-setup) 12- [TODO](#todo) 13 14 15## Background 16 17**Ascend NPU** is a range of AI processors using Neural Processing Unit. It will efficiently handle matrix-matrix multiplication, dot-product and scalars. 18 19**CANN** (Compute Architecture for Neural Networks) is a heterogeneous computing architecture for AI scenarios, providing support for multiple AI frameworks on the top and serving AI processors and programming at the bottom. It plays a crucial role in bridging the gap between upper and lower layers, and is a key platform for improving the computing efficiency of Ascend AI processors. Meanwhile, it offers a highly efficient and easy-to-use programming interface for diverse application scenarios, allowing users to rapidly build AI applications and services based on the Ascend platform. 20 21**Llama.cpp + CANN** 22 23The llama.cpp CANN backend is designed to support Ascend NPU. It utilize the ability of AscendC and ACLNN which are integrated to CANN Toolkit and kernels to using Ascend NPU directly. 24 25## News 26 27- 2024.11 28- Support F16 and F32 data type model for Ascend 310P NPU. 29- 2024.8 30- Support `Q4_0` and `Q8_0` data type for Ascend NPU. 31- 2024.7 32- Create CANN backend for Ascend NPU. 33 34## OS 35 36| OS | Status | Verified | 37|:-------:|:-------:|:----------------------------------------------:| 38| Linux | Support | Ubuntu 22.04, OpenEuler22.03 | 39 40 41## Hardware 42 43### Ascend NPU 44 45You can retrieve your Ascend device IDs using the following command: 46 47``` sh 48lspci -n | grep -Eo '19e5:d[0-9a-f]{3}' | cut -d: -f2 49``` 50 51**Devices** 52 53| Device Id | Product Series | Product Models | Chip Model | Verified Status | 54|:---------:|----------------|----------------|:----------:|:---------------:| 55| d803 | Atlas A3 Train | | 910C | | 56| d803 | Atlas A3 Infer | | 910C | | 57| d802 | Atlas A2 Train | | 910B | | 58| d802 | Atlas A2 Infer | Atlas 300I A2 | 910B | Support | 59| d801 | Atlas Train | | 910 | | 60| d500 | Atlas Infer | Atlas 300I Duo | 310P | Support | 61 62*Notes:* 63 64- If you have trouble with Ascend NPU device, please create a issue with **[CANN]** prefix/tag. 65- If you run successfully with your Ascend NPU device, please help update the upper table. 66 67 68## Model Supports 69 70< details > 71< summary >Text-only</ summary > 72 73| Model Name | FP16 | Q4_0 | Q8_0 | 74|:----------------------------|:-----:|:----:|:----:| 75| Llama-2 | √ | √ | √ | 76| Llama-3 | √ | √ | √ | 77| Mistral-7B | √ | √ | √ | 78| Mistral MOE | √ | √ | √ | 79| DBRX | - | - | - | 80| Falcon | √ | √ | √ | 81| Chinese LLaMA/Alpaca | √ | √ | √ | 82| Vigogne(French) | √ | √ | √ | 83| BERT | x | x | x | 84| Koala | √ | √ | √ | 85| Baichuan | √ | √ | √ | 86| Aquila 1 & 2 | √ | √ | √ | 87| Starcoder models | √ | √ | √ | 88| Refact | √ | √ | √ | 89| MPT | √ | √ | √ | 90| Bloom | √ | √ | √ | 91| Yi models | √ | √ | √ | 92| stablelm models | √ | √ | √ | 93| DeepSeek models | x | x | x | 94| Qwen models | √ | √ | √ | 95| PLaMo-13B | √ | √ | √ | 96| Phi models | √ | √ | √ | 97| PhiMoE | √ | √ | √ | 98| GPT-2 | √ | √ | √ | 99| Orion | √ | √ | √ | 100| InternlLM2 | √ | √ | √ | 101| CodeShell | √ | √ | √ | 102| Gemma | √ | √ | √ | 103| Mamba | √ | √ | √ | 104| Xverse | √ | √ | √ | 105| command-r models | √ | √ | √ | 106| Grok-1 | - | - | - | 107| SEA-LION | √ | √ | √ | 108| GritLM-7B | √ | √ | √ | 109| OLMo | √ | √ | √ | 110| OLMo 2 | √ | √ | √ | 111| OLMoE | √ | √ | √ | 112| Granite models | √ | √ | √ | 113| GPT-NeoX | √ | √ | √ | 114| Pythia | √ | √ | √ | 115| Snowflake-Arctic MoE | - | - | - | 116| Smaug | √ | √ | √ | 117| Poro 34B | √ | √ | √ | 118| Bitnet b1.58 models | √ | x | x | 119| Flan-T5 | √ | √ | √ | 120| Open Elm models | x | √ | √ | 121| chatGLM3-6B + ChatGLM4-9b + GLMEdge-1.5b + GLMEdge-4b | √ | √ | √ | 122| GLM-4-0414 | √ | √ | √ | 123| SmolLM | √ | √ | √ | 124| EXAONE-3.0-7.8B-Instruct | √ | √ | √ | 125| FalconMamba Models | √ | √ | √ | 126| Jais Models | - | x | x | 127| Bielik-11B-v2.3 | √ | √ | √ | 128| RWKV-6 | - | √ | √ | 129| QRWKV-6 | √ | √ | √ | 130| GigaChat-20B-A3B | x | x | x | 131| Trillion-7B-preview | √ | √ | √ | 132| Ling models | √ | √ | √ | 133 134</details> 135 136< details > 137< summary >Multimodal</ summary > 138 139| Model Name | FP16 | Q4_0 | Q8_0 | 140|:----------------------------|:-----:|:----:|:----:| 141| LLaVA 1.5 models, LLaVA 1.6 models | x | x | x | 142| BakLLaVA | √ | √ | √ | 143| Obsidian | √ | - | - | 144| ShareGPT4V | x | - | - | 145| MobileVLM 1.7B/3B models | - | - | - | 146| Yi-VL | - | - | - | 147| Mini CPM | √ | √ | √ | 148| Moondream | √ | √ | √ | 149| Bunny | √ | - | - | 150| GLM-EDGE | √ | √ | √ | 151| Qwen2-VL | √ | √ | √ | 152 153</details> 154 155 156 157## DataType Supports 158 159| DataType | 910B | 310P | 160|:----------------------:|:-------:|:-------:| 161| FP16 | Support | Support | 162| Q8_0 | Support | Partial | 163| Q4_0 | Support | Partial | 164| BF16 | Support | | 165 166> **310P note** 167> - `Q8_0`: data transform / buffer path is implemented, and `GET_ROWS` is supported, but quantized `MUL_MAT` / `MUL_MAT_ID` are not supported. 168> - `Q4_0`: data transform / buffer path is implemented, but quantized `MUL_MAT` / `MUL_MAT_ID` are not supported. 169 170## Docker 171 172### Build Images 173You can get a image with llama.cpp in one command. 174``` sh 175docker build -t llama-cpp-cann -f .devops/llama-cli-cann.Dockerfile . 176``` 177 178### Run container 179 180``` sh 181# Find all cards. 182npu-smi info 183 184# Select the cards that you want to use, make sure these cards are not used by someone. 185# Following using cards of device0. 186docker run --name llamacpp \ 187--device /dev/davinci0 \ 188--device /dev/davinci_manager \ 189--device /dev/devmm_svm \ 190--device /dev/hisi_hdc \ 191-v /usr/local/dcmi:/usr/local/dcmi \ 192-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \ 193-v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \ 194-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \ 195-v /PATH_TO_YOUR_MODELS/:/app/models \ 196-it llama-cpp-cann \ 197-m /app/models/MODEL_PATH \ 198-ngl 32 \ 199-p "Building a website can be done in 10 simple steps:" 200``` 201 202*Notes:* 203 204- You may need to install Ascend Driver and firmware on the **host** machine *(Please refer to the [Linux configuration](#linux) for details)*. 205 206## Linux 207 208### I. Setup Environment 209 2101. **Configure Ascend user and group** 211 212```sh 213sudo groupadd HwHiAiUser 214sudo useradd -g HwHiAiUser -d /home/HwHiAiUser -m HwHiAiUser -s /bin/bash 215sudo usermod -aG HwHiAiUser $USER 216``` 217 2182. **Install dependencies** 219 220**Ubuntu/Debian:** 221```sh 222sudo apt-get update 223sudo apt-get install -y gcc python3 python3-pip linux-headers-$(uname -r) 224``` 225 226**RHEL/CentOS:** 227```sh 228sudo yum makecache 229sudo yum install -y gcc python3 python3-pip kernel-headers-$(uname -r) kernel-devel-$(uname -r) 230``` 231 2323. **Install CANN (driver + toolkit)** 233 234> The `Ascend-cann` package includes both the driver and toolkit. 235> `$ARCH` can be `x86_64` or `aarch64`, `$CHIP` can be `910b` or `310p`. 236 237```sh 238wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%208.5.T63/Ascend-cann_8.5.0_linux-$ARCH.run 239sudo bash ./Ascend-cann_8.5.0_linux-$ARCH.run --install 240 241wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%208.5.T63/Ascend-cann-$CHIP-ops_8.5.0_linux-$ARCH.run 242sudo bash ./Ascend-cann-$CHIP-ops_8.5.0_linux-$ARCH.run --install 243``` 244 2454. **Verify installation** 246 247```sh 248npu-smi info 249``` 250 251If device information is displayed correctly, the driver is functioning properly. 252 253```sh 254# Set environment variables (adjust path if needed) 255source /usr/local/Ascend/cann/set_env.sh 256 257python3 -c "import acl; print(acl.get_soc_name())" 258``` 259 260If the command outputs the chip model, the installation was successful. 261 262### II. Build llama.cpp 263 264``` sh 265cmake -B build -DGGML_CANN=on -DCMAKE_BUILD_TYPE=release 266cmake --build build --config release 267``` 268 269### III. Run the inference 270 2711. **Retrieve and prepare model** 272 273You can refer to the general [*Obtaining and quantizing models*](../../README.md#obtaining-and-quantizing-models) guide for model prepration. 274 275**Notes**: 276 277- CANN backend only supports FP16/Q4_0/Q8_0 models currently. 278 2792. **Launch inference** 280 281There are two device selection modes: 282 283- Single device: Use one device target specified by the user. 284- Multiple devices: Automatically choose the devices with the same backend. 285 286| Device selection | Parameter | 287|:----------------:|:--------------------------------------:| 288| Single device | --split-mode none --main-gpu DEVICE_ID | 289| Multiple devices | --split-mode layer (default) | 290 291Examples: 292 293- Use device 0: 294 295```sh 296./build/bin/llama-cli -m path_to_model -p "Building a website can be done in 10 simple steps:" -n 400 -e -ngl 33 -sm none -mg 0 297``` 298 299- Use multiple devices: 300 301```sh 302./build/bin/llama-cli -m path_to_model -p "Building a website can be done in 10 simple steps:" -n 400 -e -ngl 33 -sm layer 303``` 304 305### **GitHub contribution**: 306Please add the **[CANN]** prefix/tag in issues/PRs titles to help the CANN-team check/address them without delay. 307 308## Updates 309### Basic Flash Attention Support 310The basic FA kernel with aclnnops has been added in aclnn_ops.cpp. 311Currently, the FA only supports the cases with FP16 KV tensors and NO logit softcap. 312Since the aclnn interface for flash attention cannot support the logit softcap, we will only update the quantized version in the future. 313 314Authors from Peking University: Bizhao Shi (bshi@pku.edu.cn), Yuxin Yang (yxyang@pku.edu.cn), Ruiyang Ma (ruiyang@stu.pku.edu.cn), and Guojie Luo (gluo@pku.edu.cn). 315 316We would like to thank Tuo Dai, Shanni Li, and all of the project maintainers from Huawei Technologies Co., Ltd for their help during the code development and pull request. 317 318## Environment variable setup 319 320### GGML_CANN_MEM_POOL 321 322Specifies the memory pool management strategy, Default is vmm. 323 324- vmm: Utilizes a virtual memory manager pool. If hardware support for VMM is unavailable, falls back to the legacy (leg) memory pool. 325 326- prio: Employs a priority queue-based memory pool management. 327 328- leg: Uses a fixed-size buffer pool. 329 330### GGML_CANN_DISABLE_BUF_POOL_CLEAN 331 332Controls automatic cleanup of the memory pool. This option is only effective when using the prio or leg memory pool strategies. 333 334### GGML_CANN_WEIGHT_NZ 335 336Converting the matmul weight format from ND to NZ to improve performance. Enabled by default. 337 338### GGML_CANN_ACL_GRAPH 339 340Operators are executed using ACL graph execution, rather than in op-by-op (eager) mode. Enabled by default. This option is only effective if `USE_ACL_GRAPH` was enabled at compilation time. To enable it, recompile using: 341 342``` sh 343cmake -B build -DGGML_CANN=on -DCMAKE_BUILD_TYPE=release -DUSE_ACL_GRAPH=ON 344cmake --build build --config release 345``` 346 347### GGML_CANN_GRAPH_CACHE_CAPACITY 348 349Maximum number of compiled CANN graphs kept in the LRU cache, default is 12. When the number of cached graphs exceeds this capacity, the least recently used graph will be evicted. 350 351### GGML_CANN_PREFILL_USE_GRAPH 352 353Enable ACL graph execution during the prefill stage, default is false. This option is only effective when FA is enabled. 354 355### GGML_CANN_OPERATOR_FUSION 356 357Enable operator fusion during computation, default is false. This option fuses compatible operators (e.g., ADD + RMS_NORM) to reduce overhead and improve performance.