char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
b6b003d2c
char/aliceai-t5-moe
llama.cpp for SYCL
- Background
- Recommended Release
- News
- OS
- Hardware
- Performance Reference
- Docker
- Linux
- Windows
- Environment Variable
- Design Rule
- Known Issue
- Q&A
- TODO
Background
SYCL is a high-level parallel programming model designed to improve developers productivity writing code across various hardware accelerators such as CPUs, GPUs, and FPGAs. It is a single-source language designed for heterogeneous computing and based on standard C++17.
oneAPI is an open ecosystem and a standard-based specification, supporting multiple architectures including but not limited to Intel CPUs, GPUs and FPGAs. The key components of the oneAPI ecosystem include:
- DPCPP (Data Parallel C++): The primary oneAPI SYCL implementation, which includes the icpx/icx Compilers.
- oneAPI Libraries: A set of highly optimized libraries targeting multiple domains (e.g. Intel oneMKL, oneMath and oneDNN).
- oneAPI LevelZero: A high performance low level interface for fine-grained control over Intel iGPUs and dGPUs.
Llama.cpp + SYCL
The llama.cpp SYCL backend is primarily designed for Intel GPUs. SYCL cross-platform capabilities enable support for other vendor GPUs as well.
Recommended Release
Windows
The following releases are verified and recommended:
| Commit ID | Tag | Release | Verified Platform | Update date |
|---|---|---|---|---|
| 24e86cae7219b0f3ede1d5abdf5bf3ad515cccb8 | b5377 | llama-b5377-bin-win-sycl-x64.zip | Arc B580/Linux/oneAPI 2025.1<br>LNL Arc GPU/Windows 11/oneAPI 2025.1.1 | 2025-05-15 |
| 3bcd40b3c593d14261fb2abfabad3c0fb5b9e318 | b4040 | llama-b4040-bin-win-sycl-x64.zip | Arc A770/Linux/oneAPI 2024.1<br>MTL Arc GPU/Windows 11/oneAPI 2024.1 | 2024-11-19 |
| fb76ec31a9914b7761c1727303ab30380fd4f05c | b3038 | llama-b3038-bin-win-sycl-x64.zip | Arc A770/Linux/oneAPI 2024.1<br>MTL Arc GPU/Windows 11/oneAPI 2024.1 |
Ubuntu 24.04
The release packages for Ubuntu 24.04 x64 (FP32/FP16) only include the binary files of the llama.cpp SYCL backend. They require the target machine to have pre-installed Intel GPU drivers and oneAPI packages that are the same version as the build package. To get the version and installation info, refer to .github/workflows/release.yml#L713: ubuntu-24-sycl -> Download & Install oneAPI.
It is recommended to use them with Intel Docker.
The packages for FP32 and FP16 would have different accuracy and performance on LLMs. Please choose it according to the test result.
News
-
2026.04-05
- Optimize mul_mat by reorder feature for data type: Q4_K, Q5_K, Q6_K, Q8_0.
- Fused MoE.
- Upgrate CI and built package for oneAPI 2025.3.3, support Ubuntu 24.04 built package.
-
2026.03
- Support Flash-Attention: less memory usage, performance impact depends on LLM.
-
2026.02
- Remove support for Nvidia & AMD GPU, because the oneAPI plugin for Nvidia & AMD GPU is unavailable: download/installation channels are out of work. User can't build up the software for Nvidia & AMD GPU.
-
2025.11
- Support malloc memory on device more than 4GB.
-
2025.2
- Optimize MUL_MAT Q4_0 on Intel GPU for all dGPUs and built-in GPUs since MTL. Increase the performance of LLM (llama-2-7b.Q4_0.gguf) 21%-87% on Intel GPUs (MTL, ARL-H, Arc, Flex, PVC).
GPU Base tokens/s Increased tokens/s Percent PVC 1550 39 73 +87% Flex 170 39 50 +28% Arc A770 42 55 +30% MTL 13 16 +23% ARL-H 14 17 +21%
- Optimize MUL_MAT Q4_0 on Intel GPU for all dGPUs and built-in GPUs since MTL. Increase the performance of LLM (llama-2-7b.Q4_0.gguf) 21%-87% on Intel GPUs (MTL, ARL-H, Arc, Flex, PVC).
-
2024.11
- Use syclcompat to improve the performance on some platforms. This requires to use oneAPI 2025.0 or newer.
-
2024.8
- Use oneDNN as the default GEMM library, improve the compatibility for new Intel GPUs.
-
2024.5
- Performance is increased: 34 -> 37 tokens/s of llama-2-7b.Q4_0 on Arc A770.
- Arch Linux is verified successfully.
-
2024.4
- Support data types: GGML_TYPE_IQ4_NL, GGML_TYPE_IQ4_XS, GGML_TYPE_IQ3_XXS, GGML_TYPE_IQ3_S, GGML_TYPE_IQ2_XXS, GGML_TYPE_IQ2_XS, GGML_TYPE_IQ2_S, GGML_TYPE_IQ1_S, GGML_TYPE_IQ1_M.
-
2024.3
- Release binary files of Windows.
- A blog is published: Run LLM on all Intel GPUs Using llama.cpp: intel.com or medium.com.
- New base line is ready: tag b2437.
- Support multiple cards: --split-mode: [none|layer]; not support [row], it's on developing.
- Support to assign main GPU by --main-gpu, replace $GGML_SYCL_DEVICE.
- Support detecting all GPUs with level-zero and same top Max compute units.
- Support OPs
- hardsigmoid
- hardswish
- pool2d
-
2024.1
- Create SYCL backend for Intel GPU.
- Support Windows build
OS
| OS | Status | Verified |
|---|---|---|
| Linux | Support | Ubuntu 22.04, Fedora Silverblue 39, Arch Linux |
| Windows | Support | Windows 11 |
Hardware
Intel GPU
SYCL backend supports Intel GPU Family:
- Intel Data Center Max Series
- Intel Flex Series, Arc Series
- Intel Built-in Arc GPU
- Intel iGPU in Core CPU (11th Generation Core CPU and newer, refer to oneAPI supported GPU).
On older Intel GPUs, you may try OpenCL although the performance is not optimal, and some GPUs may not support OpenCL nor have any GPGPU capabilities.
Verified devices
| Intel GPU | Status | Verified Model |
|---|---|---|
| Intel Data Center Max Series | Support | Max 1550, 1100 |
| Intel Data Center Flex Series | Support | Flex 170 |
| Intel Arc A-Series | Support | Arc A770, Arc A730M, Arc A750 |
| Intel Arc B-Series | Support | Arc B580 |
| Intel built-in Arc GPU | Support | built-in Arc GPU in Meteor Lake, Arrow Lake, Lunar Lake |
| Intel iGPU | Support | iGPU in 13700k, 13400, i5-1250P, i7-1260P, i7-1165G7 |
Notes:
-
Memory
- The device memory is a limitation when running a large model. The loaded model size,
llm_load_tensors: buffer_size, is displayed in the log when running./bin/llama-completion. - Please make sure the GPU shared memory from the host is large enough to account for the model's size. For e.g. the llama-2-7b.Q4_0 requires at least 8.0GB for integrated GPU and 4.0GB for discrete GPU.
- The device memory is a limitation when running a large model. The loaded model size,
-
Execution Unit (EU)
- If the iGPU has less than 80 EUs, the inference speed will likely be too slow for practical use.
Other Vendor GPU
NA
Performance Reference
To get the supported LLMs, GPUs, and performance reference, please check Performance of llama.cpp on Intel GPU with SYCL backend.
You could update your test result in it directly.
Docker
Please refer to Docker with SYCL for details.
Quick Development WOW
This chapter is for quick development & try with SYCL backend on Intel GPU.
You need to install following sofeware before development:
- Intel GPU driver
- oneAPI package
- other development tools.
Please refer to Linux or Windows for above installation and resolve the trouble in usage. There are the detailed guide.
- Linux
## build from source code ./examples/sycl/build.sh ## run CONV_2D_DW unit test cases ./build/bin/test-backend-ops -b SYCL0 -o CONV_2D_DW ## run all unit test cases ./build/bin/test-backend-ops -b SYCL0 ## run with LLM on the first GPU ./examples/sycl/test.sh -mg 0 -m xxxx.gguf ## run service with LLM on the first GPU export ONEAPI_DEVICE_SELECTOR="level_zero:0" ./examples/sycl/start-svr.sh -m xxxx.gguf ## update the docs/ops.md for new/update OPs ./examples/sycl/update-ops-doc.sh
- Windows
## build from source code examples\sycl\win-build-sycl.bat ## run CONV_2D_DW unit test cases build\bin\test-backend-ops.exe -b SYCL0 -o CONV_2D_DW ## run all unit test cases build\bin\test-backend-ops.exe -b SYCL0 ## run LLM on the first GPU examples\sycl\win-test.bat -mg 0 -m xxxx.gguf ## run service with LLM on the first GPU set ONEAPI_DEVICE_SELECTOR="level_zero:0" examples\sycl\win-start-svr.bat -m xxxx.gguf ## update the docs/ops.md for new/update OPs examples\sycl\win-update-ops-doc.bat
Linux
I. Setup Environment
- Install GPU drivers
- Intel GPU
Intel data center GPUs drivers installation guide and download page can be found here: Get Intel dGPU Drivers.
Note: for client GPUs (iGPU & Arc A-Series), please refer to the client iGPU driver installation.
Once installed, add the user(s) to the video and render groups.
sudo usermod-aG render$ USER sudo usermod-aG video$ USER
Note: logout/re-login for the changes to take effect.
Verify installation through clinfo:
sudo apt install clinfosudo clinfo-l
Sample output:
Platform #0: Intel(R) OpenCL Graphics ` -- Device #0: Intel(R) Arc(TM) A770 Graphics Platform #0: Intel(R) OpenCL HD Graphics ` -- Device#0: Intel(R) Iris(R) Xe Graphics [0x9a49]
- Install Intel® oneAPI Base toolkit
SYCL backend depends on:
-
Intel® oneAPI DPC++/C++ compiler/running-time.
-
Intel® oneAPI DPC++/C++ library (oneDPL).
-
Intel® oneAPI Deep Neural Network Library (oneDNN).
-
Intel® oneAPI Math Kernel Library (oneMKL).
-
For Intel GPU
All above are included in both Intel® oneAPI Base toolkit and Intel® Deep Learning Essentials packages.
It's recommended to install Intel® Deep Learning Essentials which only provides the necessary libraries with less size.
The Intel® oneAPI Base toolkit and Intel® Deep Learning Essentials can be obtained from the official Intel® oneAPI Base Toolkit page.
Please follow the instructions for downloading and installing the Toolkit for Linux, and preferably keep the default installation values unchanged, notably the installation path (/opt/intel/oneapi by default).
Following guidelines/code snippets assume the default installation values. Otherwise, please make sure the necessary changes are reflected where applicable.
Upon a successful installation, SYCL is enabled for the available Intel devices, along with relevant libraries such as oneAPI oneDNN for Intel GPUs.
| Verified release |
|---|
| 2025.3.3 |
| 2025.2.1 |
| 2025.1 |
| 2024.1 |
- Verify installation and environment
In order to check the available SYCL devices on the machine, please use the sycl-ls command.
source /opt/intel/oneapi/setvars.shsycl-ls
- Intel GPU
When targeting an intel GPU, the user should expect one or more devices among the available SYCL devices. Please make sure that at least one GPU is present via sycl-ls, for instance [level_zero:gpu] in the sample output below:
[level_zero:gpu][level_zero:0] Intel(R) oneAPI Unified Runtime over Level-Zero, Intel(R) Arc(TM) A770 Graphics 12.55.8 [1.3.29735+27] [level_zero:gpu][level_zero:1] Intel(R) oneAPI Unified Runtime over Level-Zero, Intel(R) UHD Graphics 730 12.2.0 [1.3.29735+27] [opencl:cpu][opencl:0] Intel(R) OpenCL, 13th Gen Intel(R) Core(TM) i5-13400 OpenCL 3.0 (Build 0) [2025.20.8.0.06_160000] [opencl:gpu][opencl:1] Intel(R) OpenCL Graphics, Intel(R) Arc(TM) A770 Graphics OpenCL 3.0 NEO [24.39.31294] [opencl:gpu][opencl:2] Intel(R) OpenCL Graphics, Intel(R) UHD Graphics 730 OpenCL 3.0 NEO [24.39.31294]
II. Build llama.cpp
Intel GPU
# Uses FP32, consider using FP16 for better performance in most cases ./examples/sycl/build.sh
or
# Export relevant ENV variables source /opt/intel/oneapi/setvars.sh# Option 1: Use FP16 (recommended for better performance in most cases) cmake -B build-DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DGGML_SYCL_F16=ON # Option 2: Use FP32 cmake -B build-DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx # build all binary cmake --build build--config Release-j -v
It is possible to come across some precision issues when running tests that stem from using faster
instructions, which can be circumvented by setting the environment variable SYCL_PROGRAM_COMPILE_OPTIONS
as -cl-fp32-correctly-rounded-divide-sqrt
III. Run the inference
Retrieve and prepare model
You can refer to the general Obtaining and quantizing models guide for model preparation, or download an already quantized model like llama-2-7b.Q4_0.gguf or Meta-Llama-3-8B-Instruct-Q4_0.gguf.
Check device
- Enable oneAPI running environment
source /opt/intel/oneapi/setvars.sh
- List devices information
Similar to the native sycl-ls, available SYCL devices can be queried as follow:
./build/bin/llama-ls-sycl-device
This command will only display the selected backend that is supported by SYCL. The default backend is level_zero. For example, in a system with 2 Intel GPU it would look like the following:
found 2 SYCL devices: | | | |Compute |Max compute|Max work|Max sub| | |ID| Device Type| Name|capability|units |group |group |Global mem size| |--|------------------|---------------------------------------------|----------|-----------|--------|-------|---------------| | 0|[level_zero:gpu:0]| Intel(R) Arc(TM) A770 Graphics| 1.3| 512| 1024| 32| 16225243136| | 1|[level_zero:gpu:1]| Intel(R) UHD Graphics 770| 1.3| 32| 512| 32| 53651849216|
Choose level-zero devices
| Chosen Device ID | Setting |
|---|---|
| 0 | export ONEAPI_DEVICE_SELECTOR="level_zero:0" or no action |
| 1 | export ONEAPI_DEVICE_SELECTOR="level_zero:1" |
| 0 & 1 | export ONEAPI_DEVICE_SELECTOR="level_zero:0;level_zero:1" |
Execute
Choose one of following methods to run.
- Script
- Use device 0:
./examples/sycl/test.sh -mg 0
- Use multiple devices:
./examples/sycl/test.sh
- Run llama-server:
./examples/sycl/start-svr.sh -m PATH/MODEL_FILE
- Command line Launch inference
There are two device selection modes:
- Single device: Use one device assigned by user. Default device id is 0.
- Multiple devices: Automatically choose the devices with the same backend.
In two device selection modes, the default SYCL backend is level_zero, you can choose other backend supported by SYCL by setting environment variable ONEAPI_DEVICE_SELECTOR.
| Device selection | Parameter |
|---|---|
| Single device | --split-mode none --main-gpu DEVICE_ID |
| Multiple devices | --split-mode layer (default) |
| Multiple devices | --split-mode tensor (tensor parallelism) |
--split-mode tensor (tensor parallelism) shards each layer across the selected
GPUs. It requires flash attention, which is auto-enabled when --flash-attn is
left at its default auto, so --split-mode tensor works out of the box.
Passing --flash-attn off together with --split-mode tensor is rejected at
context creation. The default f16 KV cache is recommended. Tensor parallelism
is currently optimized for 2 GPUs; other device counts fall back to a generic
all-reduce.
Examples:
- Use device 0:
ZES_ENABLE_SYSMAN =1./build/bin/llama-completion -no-cnv -m models/llama-2-7b.Q4_0.gguf-p "Building a website can be done in 10 simple steps:" -n 400-e -ngl 99-sm none-mg 0--load-mode auto
- Use multiple devices:
ZES_ENABLE_SYSMAN =1./build/bin/llama-completion -no-cnv -m models/llama-2-7b.Q4_0.gguf-p "Building a website can be done in 10 simple steps:" -n 400-e -ngl 99-sm layer--load-mode auto
Notes:
- Upon execution, verify the selected device(s) ID(s) in the output log, which can for instance be displayed as follow:
detect 1 SYCL GPUs: [0] with top Max compute units:512
Or
use 1 SYCL GPUs: [0] with Max compute units:512
User can use the device management in docs/multi-gpu.md, like parameter --device SYCL0,SYCL1 to assign one or more devices.
Windows
Install GPU driver
Intel GPU drivers instructions guide and download page can be found here: Get Intel GPU Drivers.
Option 1: download the binary package directly
Download the binary package for Windows from: https://github.com/ggml-org/llama.cpp/releases.
Extract the package to local folder, run the llama tools directly. Refer to Run the inference.
Note, the package includes the SYCL running time and all depended dll files, no need to install oneAPI package and activte them.
Option 2: build locally from the source code.
I. Setup environment
- Install Visual Studio
If you already have a recent version of Microsoft Visual Studio, you can skip this step. Otherwise, please refer to the official download page for Microsoft Visual Studio.
- Install Intel® oneAPI Base toolkit
SYCL backend depends on:
- Intel® oneAPI DPC++/C++ compiler/running-time.
- Intel® oneAPI DPC++/C++ library (oneDPL).
- Intel® oneAPI Deep Neural Network Library (oneDNN).
- Intel® oneAPI Math Kernel Library (oneMKL).
All above are included in both Intel® oneAPI Base toolkit and Intel® Deep Learning Essentials packages.
It's recommended to install Intel® Deep Learning Essentials which only provides the necessary libraries with less size.
The Intel® oneAPI Base toolkit and Intel® Deep Learning Essentials can be obtained from the official Intel® oneAPI Base Toolkit page.
Please follow the instructions for downloading and installing the Toolkit for Windows, and preferably keep the default installation values unchanged, notably the installation path (C:\Program Files (x86)\Intel\oneAPI by default).
Following guidelines/code snippets assume the default installation values. Otherwise, please make sure the necessary changes are reflected where applicable.
b. Enable oneAPI running environment:
-
Type "oneAPI" in the search bar, then open the
Intel oneAPI command prompt for Intel 64 for Visual Studio 2022App. -
On the command prompt, enable the runtime environment with the following:
"C:\Program Files (x86)\Intel\oneAPI\setvars.bat" intel64
- if you are using Powershell, enable the runtime environment with the following:
cmd.exe "/K" '"C:\Program Files (x86)\Intel\oneAPI\setvars.bat" && powershell'
c. Verify installation
In the oneAPI command line, run the following to print the available SYCL devices:
sycl-ls.exe
There should be one or more level-zero GPU devices displayed as [ext_oneapi_level_zero:gpu]. Below is example of such output detecting an Intel Iris Xe GPU as a Level-zero SYCL device:
Output (example):
[opencl:acc:0] Intel(R) FPGA Emulation Platform for OpenCL(TM), Intel(R) FPGA Emulation Device OpenCL 1.2 [2023.16.10.0.17_160000] [opencl:cpu:1] Intel(R) OpenCL, 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz OpenCL 3.0 (Build 0) [2023.16.10.0.17_160000] [opencl:gpu:2] Intel(R) OpenCL Graphics, Intel(R) Iris(R) Xe Graphics OpenCL 3.0 NEO [31.0.101.5186] [ext_oneapi_level_zero:gpu:0] Intel(R) Level-Zero, Intel(R) Iris(R) Xe Graphics 1.3 [1.3.28044]
- Install build tools
a. Download & install cmake for Windows: https://cmake.org/download/ (CMake can also be installed from Visual Studio Installer) b. The new Visual Studio will install Ninja as default. (If not, please install it manually: https://ninja-build.org/)
II. Build llama.cpp
You could download the release package for Windows directly, which including binary files and depended oneAPI dll files.
Choose one of following methods to build from source code.
Option 1: Script
# Uses FP32, consider using FP16 for better performance in most cases .\examples\sycl\win-build-sycl.bat
Option 2: CMake
On the oneAPI command line window, step into the llama.cpp main directory and run the following:
@call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" intel64 --force # Option 1: Use FP16 (recommended for better performance in most cases) cmake -B build -G "Ninja" -DGGML_SYCL=ON -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=icx -DCMAKE_BUILD_TYPE=Release -DGGML_SYCL_F16=ON # Option 2: Or FP32 cmake -B build -G "Ninja" -DGGML_SYCL=ON -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=icx -DCMAKE_BUILD_TYPE=Release cmake --build build --config Release -j
Or, use CMake presets to build:
cmake -DGGML_SYCL_F16=ON --preset x64-windows-sycl-releasecmake --build build-x64-windows-sycl-release-j --target llama-completioncmake --preset x64-windows-sycl-releasecmake --build build-x64-windows-sycl-release-j --target llama-completioncmake --preset x64-windows-sycl-debugcmake --build build-x64-windows-sycl-debug-j --target llama-completion
Option 3: Visual Studio
You have two options to use Visual Studio to build llama.cpp:
- As CMake Project using CMake presets.
- Creating a Visual Studio solution to handle the project.
Note:
All following commands are executed in PowerShell.
- Open as a CMake Project
You can use Visual Studio to open the llama.cpp folder directly as a CMake project. Before compiling, select one of the SYCL CMake presets:
-
x64-windows-sycl-release -
x64-windows-sycl-debug
Notes:
-
For a minimal experimental setup, you can build only the inference executable using:
cmake --build build --config Release -j --target llama-completion
- Generating a Visual Studio Solution
You can use Visual Studio solution to build and work on llama.cpp on Windows. You need to convert the CMake Project into a .sln file.
If you want to use the Intel C++ Compiler for the entire llama.cpp project, run the following command:
cmake -B build -G"Visual Studio 17 2022" -T"Intel C++ Compiler 2025" -A x64 -DGGML_SYCL=ON- DCMAKE_BUILD_TYPE=Release
If you prefer to use the Intel C++ Compiler only for ggml-sycl, ensure that ggml and its backend libraries are built as shared libraries ( i.e. -DBUILD_SHARED_LIBRARIES=ON, this is default behaviour):
cmake -B build -G"Visual Studio 17 2022" -A x64 -DGGML_SYCL=ON- DCMAKE_BUILD_TYPE=Release\ - DSYCL_INCLUDE_DIR="C:\Program Files (x86 )\ Intel\ oneAPI\ compiler\ latest\ include"\ - DSYCL_LIBRARY_DIR="C:\ Program Files (x86 )\ Intel\ oneAPI\ compiler\ latest\ lib"
If successful the build files have been written to: path/to/llama.cpp/build Open the project file build/llama.cpp.sln with Visual Studio.
Once the Visual Studio solution is created, follow these steps:
-
Open the solution in Visual Studio.
-
Right-click on
ggml-sycland select Properties. -
In the left column, expand C/C++ and select DPC++.
-
In the right panel, find Enable SYCL Offload and set it to
Yes. -
Apply the changes and save.
Navigation Path:
Properties -> C/C++ -> DPC++ -> Enable SYCL Offload (Yes)
Now, you can build llama.cpp with the SYCL backend as a Visual Studio project.
To do it from menu: Build -> Build Solution.
Once it is completed, final results will be in build/Release/bin
Additional Note
-
You can avoid specifying
SYCL_INCLUDE_DIRandSYCL_LIBRARY_DIRin the CMake command by setting the environment variables:-
SYCL_INCLUDE_DIR_HINT -
SYCL_LIBRARY_DIR_HINT
-
-
Above instruction has been tested with Visual Studio 17 Community edition and oneAPI 2025.0. We expect them to work also with future version if the instructions are adapted accordingly.
III. Run the inference
Retrieve and prepare model
You can refer to the general Obtaining and quantizing models guide for model preparation, or download an already quantized model like llama-2-7b.Q4_0.gguf or Meta-Llama-3-8B-Instruct-Q4_0.gguf.
Check device
- Enable oneAPI running environment
On the oneAPI command line window, run the following and step into the llama.cpp directory:
"C:\Program Files (x86)\Intel\oneAPI\setvars.bat" intel64
- List devices information
Similar to the native sycl-ls, available SYCL devices can be queried as follow:
build\bin\llama-ls-sycl-device.exe
This command will only display the selected backend that is supported by SYCL. The default backend is level_zero. For example, in a system with 2 Intel GPU it would look like the following:
found 2 SYCL devices: | | | |Compute |Max compute|Max work|Max sub| | |ID| Device Type| Name|capability|units |group |group |Global mem size| |--|------------------|---------------------------------------------|----------|-----------|--------|-------|---------------| | 0|[level_zero:gpu:0]| Intel(R) Arc(TM) A770 Graphics| 1.3| 512| 1024| 32| 16225243136| | 1|[level_zero:gpu:1]| Intel(R) UHD Graphics 770| 1.3| 32| 512| 32| 53651849216|
Choose level-zero devices
| Chosen Device ID | Setting |
|---|---|
| 0 | Default option. You may also want to set ONEAPI_DEVICE_SELECTOR="level_zero:0" |
| 1 | set ONEAPI_DEVICE_SELECTOR="level_zero:1" |
| 0 & 1 | set ONEAPI_DEVICE_SELECTOR="level_zero:0;level_zero:1" or set ONEAPI_DEVICE_SELECTOR="level_zero:*" |
Execute
Choose one of following methods to run.
- Script
- Run test:
examples\sycl\win-test.bat
- Run llama-server:
examples\sycl\win-start-svr.bat -m PATH\MODEL_FILE
- Command line
Launch inference
There are two device selection modes:
- Single device: Use one device assigned by user. Default device id is 0.
- Multiple devices: Automatically choose the devices with the same backend.
In two device selection modes, the default SYCL backend is level_zero, you can choose other backend supported by SYCL by setting environment variable ONEAPI_DEVICE_SELECTOR.
| Device selection | Parameter |
|---|---|
| Single device | --split-mode none --main-gpu DEVICE_ID |
| Multiple devices | --split-mode layer (default) |
| Multiple devices | --split-mode tensor (tensor parallelism) |
--split-mode tensor (tensor parallelism) shards each layer across the selected
GPUs. It requires flash attention, which is auto-enabled when --flash-attn is
left at its default auto, so --split-mode tensor works out of the box.
Passing --flash-attn off together with --split-mode tensor is rejected at
context creation. The default f16 KV cache is recommended. Tensor parallelism
is currently optimized for 2 GPUs; other device counts fall back to a generic
all-reduce.
Examples:
- Use device 0:
build\bin\llama-completion.exe -no-cnv -m models\llama-2-7b.Q4_0.gguf -p "Building a website can be done in 10 simple steps:\nStep 1:" -n 400 -e -ngl 99 -sm none -mg 0 --load-mode auto
- Use multiple devices:
build\bin\llama-completion.exe -no-cnv -m models\llama-2-7b.Q4_0.gguf -p "Building a website can be done in 10 simple steps:\nStep 1:" -n 400 -e -ngl 99 -sm layer --load-mode auto
Note:
- Upon execution, verify the selected device(s) ID(s) in the output log, which can for instance be displayed as follow:
detect 1 SYCL GPUs: [0] with top Max compute units:512
Or
use 1 SYCL GPUs: [0] with Max compute units:512
User can use the device management in docs/multi-gpu.md, like parameter --device SYCL0,SYCL1 to assign one or more devices.
Environment Variable
Build
| Name | Value | Function |
|---|---|---|
| GGML_SYCL | ON (mandatory) | Enable build with SYCL code path. |
| GGML_SYCL_TARGET | INTEL (default) | Set the SYCL target device type. |
| GGML_SYCL_DEVICE_ARCH | Optional | Set the SYCL device architecture. Setting the device architecture can improve the performance. See the table --offload-arch for a list of valid architectures. |
| GGML_SYCL_F16 | OFF (default) |ON (optional) | Enable FP16 build with SYCL code path. (1.) |
| GGML_SYCL_GRAPH | ON (default) |OFF (Optional) | Enable build with SYCL Graph extension. |
| GGML_SYCL_DNN | ON (default) |OFF (Optional) | Enable build with oneDNN. |
| GGML_SYCL_HOST_MEM_FALLBACK | ON (default) |OFF (Optional) | Allow host memory fallback when device memory is full during quantized weight reorder. Enables inference to continue at reduced speed (reading over PCIe) instead of failing. Requires Linux kernel 6.8+. |
| GGML_SYCL_SUPPORT_LEVEL_ZERO_API | ON (default) |OFF (Optional) | Support to use Level Zero API for device memory allocation. Requires Level Zero headers/library at build time and Intel GPU driver (Level Zero runtime) at run time. Reduces system RAM usage during multi-GPU inference. SYCL backend always runs on Level Zero running time even if it's set as OFF (The SYCL api will be usage for memory allocation). |
| CMAKE_C_COMPILER | icx (Linux), icx/cl (Windows) | Set icx compiler for SYCL code path. |
| CMAKE_CXX_COMPILER | icpx (Linux), icx (Windows) | Set icpx/icx compiler for SYCL code path. |
- FP32 or FP16 have different performance impact to LLM. Recommended to test them for better prompt processing performance on your models. You need to rebuild the code after change
GGML_SYCL_F16=OFF/ON.
Runtime
| Name | Value | Function |
|---|---|---|
| GGML_SYCL_DEBUG | 0 (default) or 1 | Enable log function: GGML_SYCL_DEBUG() for common debug. |
| GGML_SYCL_DEV_DEBUG | 0 (default) or 1 | Enable log function: GGML_SYCL_DEV_DEBUG() for developmental purposes by replacing GGML_SYCL_DEBUG() in special codes. Restore to GGML_SYCL_DEBUG() before committing code. |
| GGML_SYCL_DEV2DEV_MEMCPY | 0 (default), 1, 2 | Choose the method of dev2dev memory copy.<br>Value: <br>* 0: SYCL API (default), only support dGPUs.<br>* 1: L0 API -- Better performance, only support dGPUs, found to lead to abnormal crash in some case. <br>* 2: Host Forward -- Most stable method for all cases (including iGPU + dGPU*N), but with lower performance (-2% to -5%).<br>SYCL & L0 API are easy to be impacted by Intel GPU driver issue. When you meet the garbled output or crash issues in multiple GPUs case, try with this debug flag to work around or check the issue. |
| GGML_SYCL_ENABLE_FLASH_ATTN | 1 (default) or 0 | Enable Flash-Attention. It can reduce memory usage. The performance impact depends on the LLM. |
| GGML_SYCL_ENABLE_OPT | 0 or 1 (default) | Enable optimize features for Intel GPUs. (Recommended to 0 for Intel devices older than Gen 10) |
| GGML_SYCL_ENABLE_GRAPH | 0 (default) or 1 | Enable running computations through SYCL Graphs feature. Disabled by default because SYCL Graph is still on development, no better performance. |
| GGML_SYCL_ENABLE_HOST_PINNED_MEM | 0 or 1 (default) | Enable host pinned memory to speed up copy data from host to device. When disable it, host memory will common malloc() on CPU. Disable it when use --load-model mlock. |
| GGML_SYCL_HOST_PINNED_MEM_2G | 0 (default) or 1 | Limit the max memory allocation to be no more than 2GB when enable host pinned memory. USM allocations above 2 GiB take the relaxed/large-allocation path, which serializes H2D copies with compute and prevents copy/compute overlap. It will impact the startup time. Need more test. Depend on GGML_SYCL_ENABLE_HOST_PINNED_MEM=1. |
| GGML_SYCL_GET_MEM_API | 0 (default) or 1 | Set to get memory info (free, total) by Level Zero or SYCL API:<br>0 - Level Zero API: support more GPUs, only run on Level Zero running time. When there is an error, fallback to call SYCL API. Depend on GGML_SYCL_SUPPORT_LEVEL_ZERO_API.<br>1 - SYCL API: legacy, support more running time, it can't get the free size of some GPUs (like Arc770). In such case, return the free size as value of total size. |
| GGML_SYCL_USE_LEVEL_ZERO_API | 1 (default) or 0 | Use Level Zero API for device memory allocation instead of SYCL. Reduces system RAM usage on Intel dGPUs by avoiding DMA-buf/TTM host memory staging. Requires GGML_SYCL_SUPPORT_LEVEL_ZERO_API=ON at build time. SYCL backend always runs on Level Zero running time even if it's set as OFF (The SYCL api will be usage for memory allocation). |
| GGML_SYCL_ENABLE_DNN | 0 or 1 (default) | Enable running computations through oneDNN and always use oneMKL. |
| GGML_SYCL_FA_ONEDNN | 1 (default) or 0 | Enable the oneDNN fused SDPA (flash-attention) path on supported GPUs. Set to 0 to always use the native SYCL flash-attention kernel. |
| GGML_SYCL_FA_ONEDNN_MAX_KV | 0 (default, disabled) or positive integer | By default (0), all sequences are handled by the oneDNN fused SDPA path, regardless of KV length; a positive value caps that length, past which sequences fall back to the native kernel. If GPU driver watchdog resets (DEVICE_LOST) occur during long-context inference, set this near the context depth where they start, e.g. 24576. |
| GGML_SYCL_ENABLE_VMM | 0 or 1 (default) | Enable the virtual-memory device pool. |
| GGML_SYCL_ENABLE_MKL_FA | 1 (default) or 0 | Enable oneMKL GEMM flash attention for XMX-accelerated prompt processing with quantized KV cache. Automatically activates during prefill (prompt processing) when all conditions are met: (1) flash-attn enabled (-fa or --flash-attn on), (2) KV cache quantized (--cache-type-k q8_0 --cache-type-v q8_0 or other *_0/*_1 types), (3) batch size ≥ 1024 (--batch-size 1024), (4) prompt length ≥ 1024 tokens. Set to 0 to force the TILE kernel for A/B testing. Example minimum command: llama-cli -m model.gguf -fa -ngl 99 --cache-type-k q8_0 --cache-type-v q8_0 --batch-size 1024 -p "your prompt" |
| GGML_SYCL_MKL_FA_DEBUG | 0 (default) or 1 | Enable per-call diagnostic logging for MKL flash attention: GEMM/softmax timings, interleaved-head detection, and buffer memory usage. |
| GGML_SYCL_MEMTRACE | 0 (default), 1, 2 | Enable record and output memory allocation diagnostics. Requires -lv 4. <br>0 - Disable<br>1 - Basic memory info, including current and peak allocations, as well allocations from other sources, around 50 lines per model load.<br>2 - More verbose, logging around 900 specific allocations and deallocations. |
| GGML_SYCL_MEMTRACE_STEP | 64 (default) or positive integer | With GGML_SYCL_MEMTRACE=1, the minimum growth in memory usage to trigger another log record. |
| GGML_SYCL_MKL_FA_DIAG | 0 (default) or 1 | Enable output fingerprinting for MKL flash attention. Dumps the first 64 float output values for the first 6 FA calls with n_kv ≥ 1024, labeled with kernel type (MKL/TILE/VEC) for cross-kernel comparison. |
| GGML_SYCL_ENABLE_FUSION | 0 or 1 (default) | Enable fused-kernel dispatch in graph compute. Unsupported types and layouts fall back to the standalone op kernels. See ggml_sycl_can_fuse(). |
| GGML_SYCL_ENABLE_ESIMD | 0 or 1 (default) | Enable ESIMD kernels when available. |
| ZES_ENABLE_SYSMAN | 0 (default) or 1 | Support to get free memory of GPU by sycl::aspect::ext_intel_free_memory.<br>Recommended to use when --split-mode = layer |
| UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS | 0 (default) or 1 | Allow SYCL/Unified Runtime Level Zero device allocations larger than 4 GiB. llama.cpp's direct Level Zero allocation path requests the relaxed maximum-size limit itself when GGML_SYCL_ENABLE_LEVEL_ZERO=1. |
| GGML_SYCL_USM_SYSTEM | 0 (default) or 1 | Enable experimental support for USM system allocations for large GPU buffers. This requires enough host memory for model weights and caches, an Intel Xe2+ GPU such as BMG or newer and supported on Linux only, with CONFIG_DRM_XE_GPUSVM enabled. |
Compile-time Flags
Pass these via CXXFLAGS or add a one-off #define to enable a flag on the spot.
| Name | Function |
|---|---|
| DEBUG_SYCL_POOL | Enable device memory pool logging on teardown. Useful for profiling allocations. |
| DEBUG_SYCL_MALLOC | Enable verbose per-call logging of device pool alloc/free operations. |
| GGML_SYCL_SUPPORT_VMM | Support to building with VMM code. Default is Yes. |
Design Rule
-
Open to all contributors.
-
All code change should be useful to user:
- Fix bug.
- Add new function.
- Improve the performance/usage.
- Make code be easy to maintain.
- ...
-
Don't accept the codes of following cases:
- Break legacy function.
- Reduce the performance of legacy case in default.
- Not completed work/the functionality cannot be demonstrated.
-
Encourage to use environment variable to control features to be opened/closed.
- User can evaluate the feature without rebuild the code.
- Recommend the best features to user by setting them be opened as default.
-
Design the code based on the published official releases of oneAPI packages: compiler, library, driver, OS kernel.
-
Developers need to maintain the code they submit.
Known Issues
-
Split-mode:[row]is not supported. -
Missed the AOT (Ahead-of-Time) in building.
- Good: Builds quickly, smaller size of binary file.
- Bad: The startup is slow (JIT) in first time, but subsequent performance is unaffected.
Q&A
-
Error:
error while loading shared libraries: libsycl.so: cannot open shared object file: No such file or directory.- Potential cause: Unavailable oneAPI installation or not set ENV variables.
- Solution: Install oneAPI base toolkit and enable its ENV through:
source /opt/intel/oneapi/setvars.sh.
-
General compiler error:
- Remove build folder or try a clean-build.
-
I can not see
[ext_oneapi_level_zero:gpu]after installing the GPU driver on Linux.Please double-check with
sudo sycl-ls.If it's present in the list, please add video/render group to your user then logout/login or restart your system:
sudo usermod -aG render $USER sudo usermod -aG video $USER
Otherwise, please double-check the GPU driver installation steps.
-
Can I report Ollama issue on Intel GPU to llama.cpp SYCL backend?
No. We can't support Ollama issue directly, because we aren't familiar with Ollama.
Suggest reproducing on llama.cpp and report similar issue to llama.cpp. We will support it.
It's same for other projects including llama.cpp SYCL backend.
-
Native API failed. Native API returns: 39 (UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY),ggml_backend_sycl_buffer_type_alloc_buffer: can't allocate 3503030272 Bytes of memory on device, orfailed to allocate SYCL0 bufferYou are running out of Device Memory.
Reason Solution The default context is too big. It leads to excessive memory usage. Set -c 8192or a smaller value.The model is too big and requires more memory than what is available. Choose a smaller model or change to a smaller quantization, like Q5 -> Q4;<br>Alternatively, use more than one device to load model. -
ggml_backend_sycl_buffer_type_alloc_buffer: can't allocate 5000000000 Bytes of memory on deviceWith the default
GGML_SYCL_ENABLE_LEVEL_ZERO=1, llama.cpp requests Level Zero's relaxed maximum-size allocation limit directly. If Level Zero support is disabled at build time or runtime and the allocation goes through SYCL/Unified Runtime instead, enable support for allocations larger than 4 GiB by:export UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS=1 set UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS=1
-
When I set
SYCL_CACHE_PERSISTENT=1in running time, I meet crash.SYCL_CACHE_PERSISTENT=1is not recommended by llama.cpp SYCL backend. When cache is enabled, SYCL runtime will try to cache and reuse JIT-compiled binaries.We find some AI will tell user this cmd to speed up SYCL backend. It only speeds up the startup to skip the JIT process, instead of running speed.
It will bring negative impact when the SYCL binary file is changed frequently in your running environment. The new & old codes mix will lead to crash.
Compare to the benefit, it has brought more failed cases. If you are not familiar with the SYCL compiler principle of JIT and AOT, please don't use it.
To restore, you need to remove the local cache:
~/.cache/libsycl_cache/and executeunset SYCL_CACHE_PERSISTENTin running time. -
How to use iGPU and dGPU in same time?
- Detect the devices in your running time.
source /opt/intel/oneapi/setvars.sh ./build/bin/llama-server --list-devices or ./build/bin/llama-cli --list-devices ./build/bin/llama-bench --list-devices ./build/bin/llama-completion --list-devices Available devices: SYCL0: Intel(R) Arc(TM) A770 Graphics (15473 MiB, 15473 MiB free) SYCL1: Intel(R) UHD Graphics 770 (59675 MiB, 44986 MiB free)
The dGPU will be in the head of this list and iGPU will be the end. If not all GPUs are listed, please check the env var: ONEAPI_DEVICE_SELECTOR and unset it.
- Set the iGPU and dGPU
Set the iGPU and dGPU by
./build/bin/llama-server --device SYCL0,SYCL1,SYCLxxx.
GitHub contribution:
Please add the [SYCL] prefix/tag in issues/PRs titles to help the SYCL contributors to check/address them without delay.
TODO
- Review ZES_ENABLE_SYSMAN: https://github.com/intel/compute-runtime/blob/master/programmers-guide/SYSMAN.md#support-and-limitations
1# llama.cpp for SYCL 2 3- [Background](#background) 4- [Recommended Release](#recommended-release) 5- [News](#news) 6- [OS](#os) 7- [Hardware](#hardware) 8- [Performance Reference](#performance-reference) 9- [Docker](#docker) 10- [Linux](#linux) 11- [Windows](#windows-1) 12- [Environment Variable](#environment-variable) 13- [Design Rule](#design-rule) 14- [Known Issue](#known-issues) 15- [Q&A](#qa) 16- [TODO](#todo) 17 18## Background 19 20**SYCL** is a high-level parallel programming model designed to improve developers productivity writing code across various hardware accelerators such as CPUs, GPUs, and FPGAs. It is a single-source language designed for heterogeneous computing and based on standard C++17. 21 22**oneAPI** is an open ecosystem and a standard-based specification, supporting multiple architectures including but not limited to Intel CPUs, GPUs and FPGAs. The key components of the oneAPI ecosystem include: 23 24- **DPCPP** *(Data Parallel C++)*: The primary oneAPI SYCL implementation, which includes the icpx/icx Compilers. 25- **oneAPI Libraries**: A set of highly optimized libraries targeting multiple domains *(e.g. Intel oneMKL, oneMath and oneDNN)*. 26- **oneAPI LevelZero**: A high performance low level interface for fine-grained control over Intel iGPUs and dGPUs. 27 28### Llama.cpp + SYCL 29 30The llama.cpp SYCL backend is primarily designed for **Intel GPUs**. 31SYCL cross-platform capabilities enable support for other vendor GPUs as well. 32 33## Recommended Release 34 35### Windows 36 37The following releases are verified and recommended: 38 39|Commit ID|Tag|Release|Verified Platform| Update date| 40|-|-|-|-|-| 41|24e86cae7219b0f3ede1d5abdf5bf3ad515cccb8|b5377 |[llama-b5377-bin-win-sycl-x64.zip](https://github.com/ggml-org/llama.cpp/releases/download/b5377/llama-b5377-bin-win-sycl-x64.zip) |Arc B580/Linux/oneAPI 2025.1<br>LNL Arc GPU/Windows 11/oneAPI 2025.1.1|2025-05-15| 42|3bcd40b3c593d14261fb2abfabad3c0fb5b9e318|b4040 |[llama-b4040-bin-win-sycl-x64.zip](https://github.com/ggml-org/llama.cpp/releases/download/b4040/llama-b4040-bin-win-sycl-x64.zip) |Arc A770/Linux/oneAPI 2024.1<br>MTL Arc GPU/Windows 11/oneAPI 2024.1| 2024-11-19| 43|fb76ec31a9914b7761c1727303ab30380fd4f05c|b3038 |[llama-b3038-bin-win-sycl-x64.zip](https://github.com/ggml-org/llama.cpp/releases/download/b3038/llama-b3038-bin-win-sycl-x64.zip) |Arc A770/Linux/oneAPI 2024.1<br>MTL Arc GPU/Windows 11/oneAPI 2024.1|| 44 45### Ubuntu 24.04 46 47The release packages for Ubuntu 24.04 x64 (FP32/FP16) only include the binary files of the llama.cpp SYCL backend. They require the target machine to have pre-installed Intel GPU drivers and oneAPI packages that are the same version as the build package. To get the version and installation info, refer to [.github/workflows/release.yml#L713](../../.github/workflows/release.yml#L713): ubuntu-24-sycl -> Download & Install oneAPI. 48 49It is recommended to use them with [Intel Docker](https://hub.docker.com/r/intel/deep-learning-essentials). 50 51The packages for FP32 and FP16 would have different accuracy and performance on LLMs. Please choose it according to the test result. 52 53## News 54 55- 2026.04-05 56- Optimize mul_mat by reorder feature for data type: Q4_K, Q5_K, Q6_K, Q8_0. 57- Fused MoE. 58- Upgrate CI and built package for oneAPI 2025.3.3, support Ubuntu 24.04 built package. 59 60- 2026.03 61- Support Flash-Attention: less memory usage, performance impact depends on LLM. 62 63- 2026.02 64- Remove support for Nvidia & AMD GPU, because the oneAPI plugin for Nvidia & AMD GPU is unavailable: download/installation channels are out of work. User can't build up the software for Nvidia & AMD GPU. 65 66- 2025.11 67- Support malloc memory on device more than 4GB. 68 69- 2025.2 70- Optimize MUL_MAT Q4_0 on Intel GPU for all dGPUs and built-in GPUs since MTL. Increase the performance of LLM (llama-2-7b.Q4_0.gguf) 21%-87% on Intel GPUs (MTL, ARL-H, Arc, Flex, PVC). 71|GPU|Base tokens/s|Increased tokens/s|Percent| 72|-|-|-|-| 73|PVC 1550|39|73|+87%| 74|Flex 170|39|50|+28%| 75|Arc A770|42|55|+30%| 76|MTL|13|16|+23%| 77|ARL-H|14|17|+21%| 78 79- 2024.11 80- Use syclcompat to improve the performance on some platforms. This requires to use oneAPI 2025.0 or newer. 81 82- 2024.8 83- Use oneDNN as the default GEMM library, improve the compatibility for new Intel GPUs. 84 85- 2024.5 86- Performance is increased: 34 -> 37 tokens/s of llama-2-7b.Q4_0 on Arc A770. 87- Arch Linux is verified successfully. 88 89- 2024.4 90- Support data types: GGML_TYPE_IQ4_NL, GGML_TYPE_IQ4_XS, GGML_TYPE_IQ3_XXS, GGML_TYPE_IQ3_S, GGML_TYPE_IQ2_XXS, GGML_TYPE_IQ2_XS, GGML_TYPE_IQ2_S, GGML_TYPE_IQ1_S, GGML_TYPE_IQ1_M. 91 92- 2024.3 93- Release binary files of Windows. 94- A blog is published: **Run LLM on all Intel GPUs Using llama.cpp**: [intel.com](https://www.intel.com/content/www/us/en/developer/articles/technical/run-llm-on-all-gpus-using-llama-cpp-artical.html) or [medium.com](https://medium.com/@jianyu_neo/run-llm-on-all-intel-gpus-using-llama-cpp-fd2e2dcbd9bd). 95- New base line is ready: [tag b2437](https://github.com/ggml-org/llama.cpp/tree/b2437). 96- Support multiple cards: **--split-mode**: [none|layer]; not support [row], it's on developing. 97- Support to assign main GPU by **--main-gpu**, replace $GGML_SYCL_DEVICE. 98- Support detecting all GPUs with level-zero and same top **Max compute units**. 99- Support OPs 100- hardsigmoid 101- hardswish 102- pool2d 103 104- 2024.1 105- Create SYCL backend for Intel GPU. 106- Support Windows build 107 108## OS 109 110| OS | Status | Verified | 111|---------|---------|------------------------------------------------| 112| Linux | Support | Ubuntu 22.04, Fedora Silverblue 39, Arch Linux | 113| Windows | Support | Windows 11 | 114 115 116## Hardware 117 118### Intel GPU 119 120SYCL backend supports Intel GPU Family: 121 122- Intel Data Center Max Series 123- Intel Flex Series, Arc Series 124- Intel Built-in Arc GPU 125- Intel iGPU in Core CPU (11th Generation Core CPU and newer, refer to [oneAPI supported GPU](https://www.intel.com/content/www/us/en/developer/articles/system-requirements/intel-oneapi-base-toolkit-system-requirements.html#inpage-nav-1-1)). 126 127On older Intel GPUs, you may try [OpenCL](/docs/backend/OPENCL.md) although the performance is not optimal, and some GPUs may not support OpenCL nor have any GPGPU capabilities. 128 129#### Verified devices 130 131| Intel GPU | Status | Verified Model | 132|-------------------------------|---------|---------------------------------------| 133| Intel Data Center Max Series | Support | Max 1550, 1100 | 134| Intel Data Center Flex Series | Support | Flex 170 | 135| Intel Arc A-Series | Support | Arc A770, Arc A730M, Arc A750 | 136| Intel Arc B-Series | Support | Arc B580 | 137| Intel built-in Arc GPU | Support | built-in Arc GPU in Meteor Lake, Arrow Lake, Lunar Lake | 138| Intel iGPU | Support | iGPU in 13700k, 13400, i5-1250P, i7-1260P, i7-1165G7 | 139 140*Notes:* 141 142- **Memory** 143- The device memory is a limitation when running a large model. The loaded model size, *`llm_load_tensors: buffer_size`*, is displayed in the log when running `./bin/llama-completion`. 144- Please make sure the GPU shared memory from the host is large enough to account for the model's size. For e.g. the *llama-2-7b.Q4_0* requires at least 8.0GB for integrated GPU and 4.0GB for discrete GPU. 145 146- **Execution Unit (EU)** 147- If the iGPU has less than 80 EUs, the inference speed will likely be too slow for practical use. 148 149### Other Vendor GPU 150 151NA 152 153## Performance Reference 154 155 156To get the supported LLMs, GPUs, and performance reference, please check [Performance of llama.cpp on Intel GPU with SYCL backend](https://github.com/ggml-org/llama.cpp/discussions/23313). 157 158You could update your test result in it directly. 159 160## Docker 161 162Please refer to [Docker with SYCL](../docker.md#docker-with-sycl) for details. 163 164## Quick Development WOW 165 166This chapter is for quick development & try with SYCL backend on Intel GPU. 167 168You need to install following sofeware before development: 169- Intel GPU driver 170- oneAPI package 171- other development tools. 172 173Please refer to [Linux](#linux) or [Windows](#windows-1) for above installation and resolve the trouble in usage. There are the detailed guide. 174 175- Linux 176 177``` 178## build from source code 179./examples/sycl/build.sh 180 181## run CONV_2D_DW unit test cases 182./build/bin/test-backend-ops -b SYCL0 -o CONV_2D_DW 183 184## run all unit test cases 185./build/bin/test-backend-ops -b SYCL0 186 187## run with LLM on the first GPU 188./examples/sycl/test.sh -mg 0 -m xxxx.gguf 189 190## run service with LLM on the first GPU 191export ONEAPI_DEVICE_SELECTOR="level_zero:0" 192./examples/sycl/start-svr.sh -m xxxx.gguf 193 194## update the docs/ops.md for new/update OPs 195./examples/sycl/update-ops-doc.sh 196``` 197 198- Windows 199 200``` 201## build from source code 202examples\sycl\win-build-sycl.bat 203 204## run CONV_2D_DW unit test cases 205build\bin\test-backend-ops.exe -b SYCL0 -o CONV_2D_DW 206 207## run all unit test cases 208build\bin\test-backend-ops.exe -b SYCL0 209 210## run LLM on the first GPU 211examples\sycl\win-test.bat -mg 0 -m xxxx.gguf 212 213## run service with LLM on the first GPU 214set ONEAPI_DEVICE_SELECTOR="level_zero:0" 215examples\sycl\win-start-svr.bat -m xxxx.gguf 216 217## update the docs/ops.md for new/update OPs 218examples\sycl\win-update-ops-doc.bat 219``` 220 221 222## Linux 223 224### I. Setup Environment 225 2261. **Install GPU drivers** 227 228- **Intel GPU** 229 230Intel data center GPUs drivers installation guide and download page can be found here: [Get Intel dGPU Drivers](https://dgpu-docs.intel.com/driver/installation.html#ubuntu-install-steps). 231 232*Note*: for client GPUs *(iGPU & Arc A-Series)*, please refer to the [client iGPU driver installation](https://dgpu-docs.intel.com/driver/client/overview.html). 233 234Once installed, add the user(s) to the `video` and `render` groups. 235 236``` sh 237sudo usermod -aG render $USER 238sudo usermod -aG video $USER 239``` 240 241*Note*: logout/re-login for the changes to take effect. 242 243Verify installation through `clinfo`: 244 245``` sh 246sudo apt install clinfo 247sudo clinfo -l 248``` 249 250Sample output: 251 252``` sh 253Platform #0: Intel(R) OpenCL Graphics 254`-- Device #0: Intel(R) Arc(TM) A770 Graphics 255 256Platform #0: Intel(R) OpenCL HD Graphics 257`-- Device #0: Intel(R) Iris(R) Xe Graphics [0x9a49] 258``` 259 2602. **Install Intel® oneAPI Base toolkit** 261 262SYCL backend depends on: 263- Intel® oneAPI DPC++/C++ compiler/running-time. 264- Intel® oneAPI DPC++/C++ library (oneDPL). 265- Intel® oneAPI Deep Neural Network Library (oneDNN). 266- Intel® oneAPI Math Kernel Library (oneMKL). 267 268- **For Intel GPU** 269 270All above are included in both **Intel® oneAPI Base toolkit** and **Intel® Deep Learning Essentials** packages. 271 272It's recommended to install **Intel® Deep Learning Essentials** which only provides the necessary libraries with less size. 273 274The **Intel® oneAPI Base toolkit** and **Intel® Deep Learning Essentials** can be obtained from the official [Intel® oneAPI Base Toolkit](https://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkit.html) page. 275 276Please follow the instructions for downloading and installing the Toolkit for Linux, and preferably keep the default installation values unchanged, notably the installation path *(`/opt/intel/oneapi` by default)*. 277 278Following guidelines/code snippets assume the default installation values. Otherwise, please make sure the necessary changes are reflected where applicable. 279 280Upon a successful installation, SYCL is enabled for the available Intel devices, along with relevant libraries such as oneAPI oneDNN for Intel GPUs. 281 282|Verified release| 283|-| 284|2025.3.3 | 285|2025.2.1| 286|2025.1| 287|2024.1| 288 2893. **Verify installation and environment** 290 291In order to check the available SYCL devices on the machine, please use the `sycl-ls` command. 292``` sh 293source /opt/intel/oneapi/setvars.sh 294sycl-ls 295``` 296 297- **Intel GPU** 298 299When targeting an intel GPU, the user should expect one or more devices among the available SYCL devices. Please make sure that at least one GPU is present via `sycl-ls`, for instance `[level_zero:gpu]` in the sample output below: 300 301``` 302[level_zero:gpu][level_zero:0] Intel(R) oneAPI Unified Runtime over Level-Zero, Intel(R) Arc(TM) A770 Graphics 12.55.8 [1.3.29735+27] 303[level_zero:gpu][level_zero:1] Intel(R) oneAPI Unified Runtime over Level-Zero, Intel(R) UHD Graphics 730 12.2.0 [1.3.29735+27] 304[opencl:cpu][opencl:0] Intel(R) OpenCL, 13th Gen Intel(R) Core(TM) i5-13400 OpenCL 3.0 (Build 0) [2025.20.8.0.06_160000] 305[opencl:gpu][opencl:1] Intel(R) OpenCL Graphics, Intel(R) Arc(TM) A770 Graphics OpenCL 3.0 NEO [24.39.31294] 306[opencl:gpu][opencl:2] Intel(R) OpenCL Graphics, Intel(R) UHD Graphics 730 OpenCL 3.0 NEO [24.39.31294] 307``` 308 309### II. Build llama.cpp 310 311#### Intel GPU 312 313``` sh 314# Uses FP32, consider using FP16 for better performance in most cases 315./examples/sycl/build.sh 316``` 317 318or 319 320``` sh 321# Export relevant ENV variables 322source /opt/intel/oneapi/setvars.sh 323 324# Option 1: Use FP16 (recommended for better performance in most cases) 325cmake -B build -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DGGML_SYCL_F16=ON 326 327# Option 2: Use FP32 328cmake -B build -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx 329 330# build all binary 331cmake --build build --config Release -j -v 332``` 333 334It is possible to come across some precision issues when running tests that stem from using faster 335instructions, which can be circumvented by setting the environment variable `SYCL_PROGRAM_COMPILE_OPTIONS` 336as `-cl-fp32-correctly-rounded-divide-sqrt` 337 338### III. Run the inference 339 340#### Retrieve and prepare model 341 342You can refer to the general [*Obtaining and quantizing models*](../../README.md#obtaining-and-quantizing-models) guide for model preparation, or download an already quantized model like [llama-2-7b.Q4_0.gguf](https://huggingface.co/TheBloke/Llama-2-7B-GGUF/resolve/main/llama-2-7b.Q4_0.gguf?download=true) or [Meta-Llama-3-8B-Instruct-Q4_0.gguf](https://huggingface.co/aptha/Meta-Llama-3-8B-Instruct-Q4_0-GGUF/resolve/main/Meta-Llama-3-8B-Instruct-Q4_0.gguf). 343 344##### Check device 345 3461. Enable oneAPI running environment 347 348``` sh 349source /opt/intel/oneapi/setvars.sh 350``` 351 3522. List devices information 353 354Similar to the native `sycl-ls`, available SYCL devices can be queried as follow: 355 356``` sh 357./build/bin/llama-ls-sycl-device 358``` 359 360This command will only display the selected backend that is supported by SYCL. The default backend is level_zero. For example, in a system with 2 *Intel GPU* it would look like the following: 361``` 362found 2 SYCL devices: 363 364| | | |Compute |Max compute|Max work|Max sub| | 365|ID| Device Type| Name|capability|units |group |group |Global mem size| 366|--|------------------|---------------------------------------------|----------|-----------|--------|-------|---------------| 367| 0|[level_zero:gpu:0]| Intel(R) Arc(TM) A770 Graphics| 1.3| 512| 1024| 32| 16225243136| 368| 1|[level_zero:gpu:1]| Intel(R) UHD Graphics 770| 1.3| 32| 512| 32| 53651849216| 369``` 370 371#### Choose level-zero devices 372 373|Chosen Device ID|Setting| 374|-|-| 375|0|`export ONEAPI_DEVICE_SELECTOR="level_zero:0"` or no action| 376|1|`export ONEAPI_DEVICE_SELECTOR="level_zero:1"`| 377|0 & 1|`export ONEAPI_DEVICE_SELECTOR="level_zero:0;level_zero:1"`| 378 379#### Execute 380 381Choose one of following methods to run. 382 3831. Script 384 385- Use device 0: 386 387``` sh 388./examples/sycl/test.sh -mg 0 389``` 390- Use multiple devices: 391 392``` sh 393./examples/sycl/test.sh 394``` 395 396- Run llama-server: 397 398``` sh 399./examples/sycl/start-svr.sh -m PATH/MODEL_FILE 400``` 401 4022. Command line 403Launch inference 404 405There are two device selection modes: 406 407- Single device: Use one device assigned by user. Default device id is 0. 408- Multiple devices: Automatically choose the devices with the same backend. 409 410In two device selection modes, the default SYCL backend is level_zero, you can choose other backend supported by SYCL by setting environment variable ONEAPI_DEVICE_SELECTOR. 411 412| Device selection | Parameter | 413|------------------|----------------------------------------| 414| Single device | --split-mode none --main-gpu DEVICE_ID | 415| Multiple devices | --split-mode layer (default) | 416| Multiple devices | --split-mode tensor (tensor parallelism) | 417 418`--split-mode tensor` (tensor parallelism) shards each layer across the selected 419GPUs. It requires flash attention, which is auto-enabled when `--flash-attn` is 420left at its default `auto`, so `--split-mode tensor` works out of the box. 421Passing `--flash-attn off` together with `--split-mode tensor` is rejected at 422context creation. The default `f16` KV cache is recommended. Tensor parallelism 423is currently optimized for 2 GPUs; other device counts fall back to a generic 424all-reduce. 425 426Examples: 427 428- Use device 0: 429 430``` sh 431ZES_ENABLE_SYSMAN=1 ./build/bin/llama-completion -no-cnv -m models/llama-2-7b.Q4_0.gguf -p "Building a website can be done in 10 simple steps:" -n 400 -e -ngl 99 -sm none -mg 0 --load-mode auto 432``` 433 434- Use multiple devices: 435 436``` sh 437ZES_ENABLE_SYSMAN=1 ./build/bin/llama-completion -no-cnv -m models/llama-2-7b.Q4_0.gguf -p "Building a website can be done in 10 simple steps:" -n 400 -e -ngl 99 -sm layer --load-mode auto 438``` 439 440*Notes:* 441 442- Upon execution, verify the selected device(s) ID(s) in the output log, which can for instance be displayed as follow: 443 444``` sh 445detect 1 SYCL GPUs: [0] with top Max compute units:512 446``` 447Or 448``` sh 449use 1 SYCL GPUs: [0] with Max compute units:512 450``` 451 452User can use the device management in [docs/multi-gpu.md](https://github.com/ggml-org/llama.cpp/blob/master/docs/multi-gpu.md), like parameter `--device SYCL0,SYCL1` to assign one or more devices. 453 454## Windows 455 456### Install GPU driver 457 458Intel GPU drivers instructions guide and download page can be found here: [Get Intel GPU Drivers](https://www.intel.com/content/www/us/en/products/docs/discrete-gpus/arc/software/drivers.html). 459 460### Option 1: download the binary package directly 461 462Download the binary package for Windows from: https://github.com/ggml-org/llama.cpp/releases. 463 464Extract the package to local folder, run the llama tools directly. Refer to [Run the inference](#iii-run-the-inference-1). 465 466Note, the package includes the SYCL running time and all depended dll files, no need to install oneAPI package and activte them. 467 468### Option 2: build locally from the source code. 469 470#### I. Setup environment 471 4721. Install Visual Studio 473 474If you already have a recent version of Microsoft Visual Studio, you can skip this step. Otherwise, please refer to the official download page for [Microsoft Visual Studio](https://visualstudio.microsoft.com/). 475 4762. Install Intel® oneAPI Base toolkit 477 478SYCL backend depends on: 479- Intel® oneAPI DPC++/C++ compiler/running-time. 480- Intel® oneAPI DPC++/C++ library (oneDPL). 481- Intel® oneAPI Deep Neural Network Library (oneDNN). 482- Intel® oneAPI Math Kernel Library (oneMKL). 483 484All above are included in both **Intel® oneAPI Base toolkit** and **Intel® Deep Learning Essentials** packages. 485 486It's recommended to install **Intel® Deep Learning Essentials** which only provides the necessary libraries with less size. 487 488The **Intel® oneAPI Base toolkit** and **Intel® Deep Learning Essentials** can be obtained from the official [Intel® oneAPI Base Toolkit](https://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkit.html) page. 489 490Please follow the instructions for downloading and installing the Toolkit for Windows, and preferably keep the default installation values unchanged, notably the installation path *(`C:\Program Files (x86)\Intel\oneAPI` by default)*. 491 492Following guidelines/code snippets assume the default installation values. Otherwise, please make sure the necessary changes are reflected where applicable. 493 494b. Enable oneAPI running environment: 495 496- Type "oneAPI" in the search bar, then open the `Intel oneAPI command prompt for Intel 64 for Visual Studio 2022` App. 497 498- On the command prompt, enable the runtime environment with the following: 499``` 500"C:\Program Files (x86)\Intel\oneAPI\setvars.bat" intel64 501``` 502 503- if you are using Powershell, enable the runtime environment with the following: 504 505``` 506cmd.exe "/K" '"C:\Program Files (x86)\Intel\oneAPI\setvars.bat" && powershell' 507``` 508 509c. Verify installation 510 511In the oneAPI command line, run the following to print the available SYCL devices: 512 513``` 514sycl-ls.exe 515``` 516 517There should be one or more *level-zero* GPU devices displayed as **[ext_oneapi_level_zero:gpu]**. Below is example of such output detecting an *Intel Iris Xe* GPU as a Level-zero SYCL device: 518 519Output (example): 520``` 521[opencl:acc:0] Intel(R) FPGA Emulation Platform for OpenCL(TM), Intel(R) FPGA Emulation Device OpenCL 1.2 [2023.16.10.0.17_160000] 522[opencl:cpu:1] Intel(R) OpenCL, 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz OpenCL 3.0 (Build 0) [2023.16.10.0.17_160000] 523[opencl:gpu:2] Intel(R) OpenCL Graphics, Intel(R) Iris(R) Xe Graphics OpenCL 3.0 NEO [31.0.101.5186] 524[ext_oneapi_level_zero:gpu:0] Intel(R) Level-Zero, Intel(R) Iris(R) Xe Graphics 1.3 [1.3.28044] 525``` 526 5273. Install build tools 528 529a. Download & install cmake for Windows: https://cmake.org/download/ (CMake can also be installed from Visual Studio Installer) 530b. The new Visual Studio will install Ninja as default. (If not, please install it manually: https://ninja-build.org/) 531 532 533#### II. Build llama.cpp 534 535You could download the release package for Windows directly, which including binary files and depended oneAPI dll files. 536 537Choose one of following methods to build from source code. 538 539##### Option 1: Script 540 541``` sh 542# Uses FP32, consider using FP16 for better performance in most cases 543.\examples\sycl\win-build-sycl.bat 544``` 545 546##### Option 2: CMake 547 548On the oneAPI command line window, step into the llama.cpp main directory and run the following: 549 550``` 551@call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" intel64 --force 552 553# Option 1: Use FP16 (recommended for better performance in most cases) 554cmake -B build -G "Ninja" -DGGML_SYCL=ON -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=icx -DCMAKE_BUILD_TYPE=Release -DGGML_SYCL_F16=ON 555 556# Option 2: Or FP32 557cmake -B build -G "Ninja" -DGGML_SYCL=ON -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=icx -DCMAKE_BUILD_TYPE=Release 558 559cmake --build build --config Release -j 560``` 561 562Or, use CMake presets to build: 563 564``` sh 565cmake -DGGML_SYCL_F16=ON --preset x64-windows-sycl-release 566cmake --build build-x64-windows-sycl-release -j --target llama-completion 567 568cmake --preset x64-windows-sycl-release 569cmake --build build-x64-windows-sycl-release -j --target llama-completion 570 571cmake --preset x64-windows-sycl-debug 572cmake --build build-x64-windows-sycl-debug -j --target llama-completion 573``` 574 575##### Option 3: Visual Studio 576 577You have two options to use Visual Studio to build llama.cpp: 578- As CMake Project using CMake presets. 579- Creating a Visual Studio solution to handle the project. 580 581**Note**: 582 583All following commands are executed in PowerShell. 584 585###### - Open as a CMake Project 586 587You can use Visual Studio to open the `llama.cpp` folder directly as a CMake project. Before compiling, select one of the SYCL CMake presets: 588 589- `x64-windows-sycl-release` 590 591- `x64-windows-sycl-debug` 592 593*Notes:* 594- For a minimal experimental setup, you can build only the inference executable using: 595 596```Powershell 597cmake --build build --config Release -j --target llama-completion 598``` 599 600###### - Generating a Visual Studio Solution 601 602You can use Visual Studio solution to build and work on llama.cpp on Windows. You need to convert the CMake Project into a `.sln` file. 603 604If you want to use the Intel C++ Compiler for the entire `llama.cpp` project, run the following command: 605 606``` Powershell 607cmake -B build -G "Visual Studio 17 2022" -T "Intel C++ Compiler 2025" -A x64 -DGGML_SYCL=ON -DCMAKE_BUILD_TYPE=Release 608``` 609 610If you prefer to use the Intel C++ Compiler only for `ggml-sycl`, ensure that `ggml` and its backend libraries are built as shared libraries ( i.e. `-DBUILD_SHARED_LIBRARIES=ON`, this is default behaviour): 611 612``` Powershell 613cmake -B build -G "Visual Studio 17 2022" -A x64 -DGGML_SYCL=ON -DCMAKE_BUILD_TYPE=Release \ 614-DSYCL_INCLUDE_DIR="C:\Program Files (x86)\Intel\oneAPI\compiler\latest\include" \ 615-DSYCL_LIBRARY_DIR="C:\Program Files (x86)\Intel\oneAPI\compiler\latest\lib" 616``` 617 618If successful the build files have been written to: *path/to/llama.cpp/build* 619Open the project file **build/llama.cpp.sln** with Visual Studio. 620 621Once the Visual Studio solution is created, follow these steps: 622 6231. Open the solution in Visual Studio. 624 6252. Right-click on `ggml-sycl` and select **Properties**. 626 6273. In the left column, expand **C/C++** and select **DPC++**. 628 6294. In the right panel, find **Enable SYCL Offload** and set it to `Yes`. 630 6315. Apply the changes and save. 632 633 634*Navigation Path:* 635 636``` 637Properties -> C/C++ -> DPC++ -> Enable SYCL Offload (Yes) 638``` 639 640Now, you can build `llama.cpp` with the SYCL backend as a Visual Studio project. 641To do it from menu: `Build -> Build Solution`. 642Once it is completed, final results will be in **build/Release/bin** 643 644*Additional Note* 645 646- You can avoid specifying `SYCL_INCLUDE_DIR` and `SYCL_LIBRARY_DIR` in the CMake command by setting the environment variables: 647 648- `SYCL_INCLUDE_DIR_HINT` 649 650- `SYCL_LIBRARY_DIR_HINT` 651 652- Above instruction has been tested with Visual Studio 17 Community edition and oneAPI 2025.0. We expect them to work also with future version if the instructions are adapted accordingly. 653 654### III. Run the inference 655 656#### Retrieve and prepare model 657 658You can refer to the general [*Obtaining and quantizing models*](../../README.md#obtaining-and-quantizing-models) guide for model preparation, or download an already quantized model like [llama-2-7b.Q4_0.gguf](https://huggingface.co/TheBloke/Llama-2-7B-GGUF/blob/main/llama-2-7b.Q4_0.gguf) or [Meta-Llama-3-8B-Instruct-Q4_0.gguf](https://huggingface.co/aptha/Meta-Llama-3-8B-Instruct-Q4_0-GGUF/resolve/main/Meta-Llama-3-8B-Instruct-Q4_0.gguf). 659 660##### Check device 661 6621. Enable oneAPI running environment 663 664On the oneAPI command line window, run the following and step into the llama.cpp directory: 665``` 666"C:\Program Files (x86)\Intel\oneAPI\setvars.bat" intel64 667``` 668 6692. List devices information 670 671Similar to the native `sycl-ls`, available SYCL devices can be queried as follow: 672 673``` 674build\bin\llama-ls-sycl-device.exe 675``` 676 677This command will only display the selected backend that is supported by SYCL. The default backend is level_zero. For example, in a system with 2 *Intel GPU* it would look like the following: 678``` 679found 2 SYCL devices: 680| | | |Compute |Max compute|Max work|Max sub| | 681|ID| Device Type| Name|capability|units |group |group |Global mem size| 682|--|------------------|---------------------------------------------|----------|-----------|--------|-------|---------------| 683| 0|[level_zero:gpu:0]| Intel(R) Arc(TM) A770 Graphics| 1.3| 512| 1024| 32| 16225243136| 684| 1|[level_zero:gpu:1]| Intel(R) UHD Graphics 770| 1.3| 32| 512| 32| 53651849216| 685 686``` 687 688##### Choose level-zero devices 689 690|Chosen Device ID|Setting| 691|-|-| 692|0|Default option. You may also want to `set ONEAPI_DEVICE_SELECTOR="level_zero:0"`| 693|1|`set ONEAPI_DEVICE_SELECTOR="level_zero:1"`| 694|0 & 1|`set ONEAPI_DEVICE_SELECTOR="level_zero:0;level_zero:1"` or `set ONEAPI_DEVICE_SELECTOR="level_zero:*"`| 695 696##### Execute 697 698Choose one of following methods to run. 699 7001. Script 701 702- Run test: 703 704``` 705examples\sycl\win-test.bat 706``` 707 708- Run llama-server: 709 710``` 711examples\sycl\win-start-svr.bat -m PATH\MODEL_FILE 712``` 713 7142. Command line 715 716Launch inference 717 718There are two device selection modes: 719 720- Single device: Use one device assigned by user. Default device id is 0. 721- Multiple devices: Automatically choose the devices with the same backend. 722 723In two device selection modes, the default SYCL backend is level_zero, you can choose other backend supported by SYCL by setting environment variable ONEAPI_DEVICE_SELECTOR. 724 725| Device selection | Parameter | 726|------------------|----------------------------------------| 727| Single device | --split-mode none --main-gpu DEVICE_ID | 728| Multiple devices | --split-mode layer (default) | 729| Multiple devices | --split-mode tensor (tensor parallelism) | 730 731`--split-mode tensor` (tensor parallelism) shards each layer across the selected 732GPUs. It requires flash attention, which is auto-enabled when `--flash-attn` is 733left at its default `auto`, so `--split-mode tensor` works out of the box. 734Passing `--flash-attn off` together with `--split-mode tensor` is rejected at 735context creation. The default `f16` KV cache is recommended. Tensor parallelism 736is currently optimized for 2 GPUs; other device counts fall back to a generic 737all-reduce. 738 739Examples: 740 741- Use device 0: 742 743``` 744build\bin\llama-completion.exe -no-cnv -m models\llama-2-7b.Q4_0.gguf -p "Building a website can be done in 10 simple steps:\nStep 1:" -n 400 -e -ngl 99 -sm none -mg 0 --load-mode auto 745``` 746 747- Use multiple devices: 748 749``` 750build\bin\llama-completion.exe -no-cnv -m models\llama-2-7b.Q4_0.gguf -p "Building a website can be done in 10 simple steps:\nStep 1:" -n 400 -e -ngl 99 -sm layer --load-mode auto 751``` 752 753 754Note: 755 756- Upon execution, verify the selected device(s) ID(s) in the output log, which can for instance be displayed as follow: 757 758``` sh 759detect 1 SYCL GPUs: [0] with top Max compute units:512 760``` 761 762Or 763 764``` sh 765use 1 SYCL GPUs: [0] with Max compute units:512 766``` 767 768User can use the device management in [docs/multi-gpu.md](https://github.com/ggml-org/llama.cpp/blob/master/docs/multi-gpu.md), like parameter `--device SYCL0,SYCL1` to assign one or more devices. 769 770## Environment Variable 771 772### Build 773 774| Name | Value | Function | 775|--------------------|---------------------------------------|---------------------------------------------| 776| GGML_SYCL | ON (mandatory) | Enable build with SYCL code path. | 777| GGML_SYCL_TARGET | INTEL *(default)* | Set the SYCL target device type. | 778| GGML_SYCL_DEVICE_ARCH | Optional | Set the SYCL device architecture. Setting the device architecture can improve the performance. See the table [--offload-arch](https://github.com/intel/llvm/blob/sycl/sycl/doc/design/OffloadDesign.md#--offload-arch) for a list of valid architectures. | 779| GGML_SYCL_F16 | OFF *(default)* \|ON *(optional)* | Enable FP16 build with SYCL code path. (1.) | 780| GGML_SYCL_GRAPH | ON *(default)* \|OFF *(Optional)* | Enable build with [SYCL Graph extension](https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/experimental/sycl_ext_oneapi_graph.asciidoc). | 781| GGML_SYCL_DNN | ON *(default)* \|OFF *(Optional)* | Enable build with oneDNN. | 782| GGML_SYCL_HOST_MEM_FALLBACK | ON *(default)* \|OFF *(Optional)* | Allow host memory fallback when device memory is full during quantized weight reorder. Enables inference to continue at reduced speed (reading over PCIe) instead of failing. Requires Linux kernel 6.8+. | 783| GGML_SYCL_SUPPORT_LEVEL_ZERO_API | ON *(default)* \|OFF *(Optional)* | Support to use Level Zero API for device memory allocation. Requires Level Zero headers/library at build time and Intel GPU driver (Level Zero runtime) at run time. Reduces system RAM usage during multi-GPU inference. SYCL backend always runs on Level Zero running time even if it's set as OFF (The SYCL api will be usage for memory allocation).| 784| CMAKE_C_COMPILER | `icx` *(Linux)*, `icx/cl` *(Windows)* | Set `icx` compiler for SYCL code path. | 785| CMAKE_CXX_COMPILER | `icpx` *(Linux)*, `icx` *(Windows)* | Set `icpx/icx` compiler for SYCL code path. | 786 7871. FP32 or FP16 have different performance impact to LLM. Recommended to test them for better prompt processing performance on your models. You need to rebuild the code after change `GGML_SYCL_F16=OFF/ON`. 788 789### Runtime 790 791| Name | Value | Function | 792|-------------------|------------------|---------------------------------------------------------------------------------------------------------------------------| 793| GGML_SYCL_DEBUG | 0 (default) or 1 | Enable log function: GGML_SYCL_DEBUG() for common debug. | 794| GGML_SYCL_DEV_DEBUG | 0 (default) or 1 | Enable log function: GGML_SYCL_DEV_DEBUG() for developmental purposes by replacing GGML_SYCL_DEBUG() in special codes. Restore to GGML_SYCL_DEBUG() before committing code.| 795| GGML_SYCL_DEV2DEV_MEMCPY | 0 (default), 1, 2 | Choose the method of dev2dev memory copy.<br>Value: <br>* 0: SYCL API (default), only support dGPUs.<br>* 1: L0 API -- Better performance, only support dGPUs, found to lead to abnormal crash in some case. <br>* 2: Host Forward -- Most stable method for all cases (including iGPU + dGPU*N), but with lower performance (-2% to -5%).<br>SYCL & L0 API are easy to be impacted by Intel GPU driver issue. When you meet the garbled output or crash issues in multiple GPUs case, try with this debug flag to work around or check the issue.| 796| GGML_SYCL_ENABLE_FLASH_ATTN | 1 (default) or 0| Enable Flash-Attention. It can reduce memory usage. The performance impact depends on the LLM.| 797| GGML_SYCL_ENABLE_OPT | 0 or 1 (default)| Enable optimize features for Intel GPUs. (Recommended to 0 for Intel devices older than Gen 10) | 798| GGML_SYCL_ENABLE_GRAPH | 0 (default) or 1 | Enable running computations through SYCL Graphs feature. Disabled by default because SYCL Graph is still on development, no better performance. | 799| GGML_SYCL_ENABLE_HOST_PINNED_MEM | 0 or 1 (default) | Enable host pinned memory to speed up copy data from host to device. When disable it, host memory will common malloc() on CPU. Disable it when use `--load-model mlock`.| 800| GGML_SYCL_HOST_PINNED_MEM_2G | 0 (default) or 1 | Limit the max memory allocation to be no more than 2GB when enable host pinned memory. USM allocations above 2 GiB take the relaxed/large-allocation path, which serializes H2D copies with compute and prevents copy/compute overlap. It will impact the startup time. Need more test. Depend on `GGML_SYCL_ENABLE_HOST_PINNED_MEM=1`.| 801| GGML_SYCL_GET_MEM_API | 0 (default) or 1 | Set to get memory info (free, total) by Level Zero or SYCL API:<br>0 - Level Zero API: support more GPUs, only run on Level Zero running time. When there is an error, fallback to call SYCL API. Depend on GGML_SYCL_SUPPORT_LEVEL_ZERO_API.<br>1 - SYCL API: legacy, support more running time, it can't get the free size of some GPUs (like Arc770). In such case, return the free size as value of total size.| 802| GGML_SYCL_USE_LEVEL_ZERO_API | 1 (default) or 0 | Use Level Zero API for device memory allocation instead of SYCL. Reduces system RAM usage on Intel dGPUs by avoiding DMA-buf/TTM host memory staging. Requires GGML_SYCL_SUPPORT_LEVEL_ZERO_API=ON at build time. SYCL backend always runs on Level Zero running time even if it's set as OFF (The SYCL api will be usage for memory allocation).| 803| GGML_SYCL_ENABLE_DNN | 0 or 1 (default)| Enable running computations through oneDNN and always use oneMKL. | 804| GGML_SYCL_FA_ONEDNN | 1 (default) or 0 | Enable the oneDNN fused SDPA (flash-attention) path on supported GPUs. Set to 0 to always use the native SYCL flash-attention kernel. | 805| GGML_SYCL_FA_ONEDNN_MAX_KV | 0 (default, disabled) or positive integer | By default (0), all sequences are handled by the oneDNN fused SDPA path, regardless of KV length; a positive value caps that length, past which sequences fall back to the native kernel. If GPU driver watchdog resets (DEVICE_LOST) occur during long-context inference, set this near the context depth where they start, e.g. 24576. | 806| GGML_SYCL_ENABLE_VMM | 0 or 1 (default) | Enable the virtual-memory device pool. | 807| GGML_SYCL_ENABLE_MKL_FA | 1 (default) or 0 | Enable oneMKL GEMM flash attention for XMX-accelerated prompt processing with quantized KV cache. Automatically activates during prefill (prompt processing) when all conditions are met: (1) flash-attn enabled (`-fa` or `--flash-attn on`), (2) KV cache quantized (`--cache-type-k q8_0 --cache-type-v q8_0` or other `*_0/*_1` types), (3) batch size ≥ 1024 (`--batch-size 1024`), (4) prompt length ≥ 1024 tokens. Set to 0 to force the TILE kernel for A/B testing. Example minimum command: `llama-cli -m model.gguf -fa -ngl 99 --cache-type-k q8_0 --cache-type-v q8_0 --batch-size 1024 -p "your prompt"` | 808| GGML_SYCL_MKL_FA_DEBUG | 0 (default) or 1 | Enable per-call diagnostic logging for MKL flash attention: GEMM/softmax timings, interleaved-head detection, and buffer memory usage. | 809| GGML_SYCL_MEMTRACE | 0 (default), 1, 2 | Enable record and output memory allocation diagnostics. Requires `-lv 4`. <br>0 - Disable<br>1 - Basic memory info, including current and peak allocations, as well allocations from other sources, around 50 lines per model load.<br>2 - More verbose, logging around 900 specific allocations and deallocations. | 810| GGML_SYCL_MEMTRACE_STEP | 64 (default) or positive integer | With GGML_SYCL_MEMTRACE=1, the minimum growth in memory usage to trigger another log record. | 811| GGML_SYCL_MKL_FA_DIAG | 0 (default) or 1 | Enable output fingerprinting for MKL flash attention. Dumps the first 64 float output values for the first 6 FA calls with n_kv ≥ 1024, labeled with kernel type (MKL/TILE/VEC) for cross-kernel comparison. | 812| GGML_SYCL_ENABLE_FUSION | 0 or 1 (default) | Enable fused-kernel dispatch in graph compute. Unsupported types and layouts fall back to the standalone op kernels. See `ggml_sycl_can_fuse()`. | 813| GGML_SYCL_ENABLE_ESIMD | 0 or 1 (default)| Enable ESIMD kernels when available. | 814| ZES_ENABLE_SYSMAN | 0 (default) or 1 | Support to get free memory of GPU by sycl::aspect::ext_intel_free_memory.<br>Recommended to use when --split-mode = layer | 815| UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS | 0 (default) or 1 | Allow SYCL/Unified Runtime Level Zero device allocations larger than 4 GiB. llama.cpp's direct Level Zero allocation path requests the relaxed maximum-size limit itself when GGML_SYCL_ENABLE_LEVEL_ZERO=1. | 816| GGML_SYCL_USM_SYSTEM | 0 (default) or 1 | Enable experimental support for [USM system allocations](https://github.khronos.org/SYCL_Reference/iface/usm_basic_concept.html#system-allocations) for large GPU buffers. This requires enough host memory for model weights and caches, an Intel Xe2+ GPU such as BMG or newer and supported on Linux only, with CONFIG_DRM_XE_GPUSVM enabled. | 817 818## Compile-time Flags 819 820Pass these via `CXXFLAGS` or add a one-off `#define` to enable a flag on the spot. 821 822| Name | Function | 823|-----------------|----------------------------------------------------------------------------------| 824| DEBUG_SYCL_POOL | Enable device memory pool logging on teardown. Useful for profiling allocations. | 825| DEBUG_SYCL_MALLOC | Enable verbose per-call logging of device pool alloc/free operations. | 826| GGML_SYCL_SUPPORT_VMM | Support to building with VMM code. Default is Yes. | 827 828## Design Rule 829 830- Open to all contributors. 831 832- All code change should be useful to user: 833- Fix bug. 834- Add new function. 835- Improve the performance/usage. 836- Make code be easy to maintain. 837- ... 838 839- Don't accept the codes of following cases: 840- Break legacy function. 841- Reduce the performance of legacy case in default. 842- Not completed work/the functionality cannot be demonstrated. 843 844- Encourage to use environment variable to control features to be opened/closed. 845- User can evaluate the feature without rebuild the code. 846- Recommend the best features to user by setting them be opened as default. 847 848- Design the code based on the published official releases of oneAPI packages: compiler, library, driver, OS kernel. 849 850- Developers need to maintain the code they submit. 851 852## Known Issues 853 854- `Split-mode:[row]` is not supported. 855 856- Missed the AOT (Ahead-of-Time) in building. 857- Good: Builds quickly, smaller size of binary file. 858- Bad: The startup is slow (JIT) in first time, but subsequent performance is unaffected. 859 860## Q&A 861 862- Error: `error while loading shared libraries: libsycl.so: cannot open shared object file: No such file or directory`. 863 864- Potential cause: Unavailable oneAPI installation or not set ENV variables. 865- Solution: Install *oneAPI base toolkit* and enable its ENV through: `source /opt/intel/oneapi/setvars.sh`. 866 867- General compiler error: 868 869- Remove **build** folder or try a clean-build. 870 871- I can **not** see `[ext_oneapi_level_zero:gpu]` after installing the GPU driver on Linux. 872 873Please double-check with `sudo sycl-ls`. 874 875If it's present in the list, please add video/render group to your user then **logout/login** or restart your system: 876 877``` 878sudo usermod -aG render $USER 879sudo usermod -aG video $USER 880``` 881Otherwise, please double-check the GPU driver installation steps. 882 883- Can I report Ollama issue on Intel GPU to llama.cpp SYCL backend? 884 885No. We can't support Ollama issue directly, because we aren't familiar with Ollama. 886 887Suggest reproducing on llama.cpp and report similar issue to llama.cpp. We will support it. 888 889It's same for other projects including llama.cpp SYCL backend. 890 891- `Native API failed. Native API returns: 39 (UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY)`, `ggml_backend_sycl_buffer_type_alloc_buffer: can't allocate 3503030272 Bytes of memory on device`, or `failed to allocate SYCL0 buffer` 892 893You are running out of Device Memory. 894 895|Reason|Solution| 896|-|-| 897| The default context is too big. It leads to excessive memory usage.|Set `-c 8192` or a smaller value.| 898| The model is too big and requires more memory than what is available.|Choose a smaller model or change to a smaller quantization, like Q5 -> Q4;<br>Alternatively, use more than one device to load model.| 899 900- `ggml_backend_sycl_buffer_type_alloc_buffer: can't allocate 5000000000 Bytes of memory on device` 901 902With the default `GGML_SYCL_ENABLE_LEVEL_ZERO=1`, llama.cpp requests Level Zero's relaxed maximum-size allocation limit directly. If Level Zero support is disabled at build time or runtime and the allocation goes through SYCL/Unified Runtime instead, enable support for allocations larger than 4 GiB by: 903``` 904export UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS=1 905set UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS=1 906``` 907 908- When I set `SYCL_CACHE_PERSISTENT=1` in running time, I meet crash. 909 910`SYCL_CACHE_PERSISTENT=1` is not recommended by llama.cpp SYCL backend. 911When cache is enabled, SYCL runtime will try to cache and reuse JIT-compiled binaries. 912 913We find some AI will tell user this cmd to speed up SYCL backend. It only speeds up the startup to skip the JIT process, instead of running speed. 914 915It will bring negative impact when the SYCL binary file is changed frequently in your running environment. The new & old codes mix will lead to crash. 916 917Compare to the benefit, it has brought more failed cases. 918If you are not familiar with the SYCL compiler principle of JIT and AOT, please don't use it. 919 920To restore, you need to remove the local cache: `~/.cache/libsycl_cache/` and execute `unset SYCL_CACHE_PERSISTENT` in running time. 921 922- How to use iGPU and dGPU in same time? 923 9241. Detect the devices in your running time. 925``` 926source /opt/intel/oneapi/setvars.sh 927./build/bin/llama-server --list-devices 928 929or 930./build/bin/llama-cli --list-devices 931./build/bin/llama-bench --list-devices 932./build/bin/llama-completion --list-devices 933 934Available devices: 935SYCL0: Intel(R) Arc(TM) A770 Graphics (15473 MiB, 15473 MiB free) 936SYCL1: Intel(R) UHD Graphics 770 (59675 MiB, 44986 MiB free) 937``` 938 939The dGPU will be in the head of this list and iGPU will be the end. 940If not all GPUs are listed, please check the env var: ONEAPI_DEVICE_SELECTOR and unset it. 941 9422. Set the iGPU and dGPU 943 944Set the iGPU and dGPU by `./build/bin/llama-server --device SYCL0,SYCL1,SYCLxxx`. 945 946 947### **GitHub contribution**: 948Please add the `[SYCL]` prefix/tag in issues/PRs titles to help the SYCL contributors to check/address them without delay. 949 950## TODO 951 952- Review ZES_ENABLE_SYSMAN: https://github.com/intel/compute-runtime/blob/master/programmers-guide/SYSMAN.md#support-and-limitations