Skip to content

sycl: remove unused flash attention kv buffers - #27689

Merged
ggerganov merged 1 commit into
ggml-org:masterfrom
Pratyush-gg:fix-sycl-igpu
Oct 7, 2026
Merged

ggerganov merged 1 commit into
ggml-org:masterfrom
Pratyush-gg:fix-sycl-igpu

Conversation

@Pratyush-gg

@Pratyush-gg Pratyush-gg commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Remove the unused ggml_sycl_fattn_kv_buffers implementation and related code. K/V F16 conversion now uses extra K_buffer_ptr / extra.V_buffer_ptr directly with assertions. These buffers became unreachable after #27629, so the fallback allocations were dead code.

Additional information

Iris Xe, Windows 11, oneAPI 2026.1
FLASH_ATTN_EXT: 350/350 passed for q4_0; 363/364 for q8_0 (known #27769 failure)
llama-bench: Qwen2.5-1.5B Q4_K_M, -fa 1, q8_0 KV cache ran successfully

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: NO
    (the warning i am getting is maybe because I used AI to format the text properly)

@Pratyush-gg
Pratyush-gg requested a review from a team as a code owner August 25, 2026 06:35
@github-actions github-actions Bot added ggml changes relating to the ggml tensor library for machine learning SYCL https://en.wikipedia.org/wiki/SYCL - GPU programming language labels Aug 25, 2026
@ggml-gh-bot

ggml-gh-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown

Hi @Pratyush-gg, thanks for your contribution!

Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:

  • AI-generated content: While code is allowed to be generated by AI, please write the PR description and commit messages on your own without the help of AI.

Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below.

@arthw arthw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good job!
Summary main comments:

  1. remove the warning of get_memory_info()
    I will create a PR to refactor this part and remove the warning in most cases.
    So, no need to update it in this PR.

  2. Usage of GGML_SYCL_DISABLE_DNN / GGML_SYCL_DISABLE_VMM .
    There are env vars for DNN and VMM: GGML_SYCL_ENABLE_DNN / GGML_SYCL_ENABLE_VMM.
    Do you want to define new vars named as GGML_SYCL_DISABLE_DNN / GGML_SYCL_DISABLE_VMM?

If yes, please use another names; update the SYCL.md to explain them like GGML_SYCL_ENABLE_DNN; need to print the value after read them.

Thank you!

Comment thread ggml/src/ggml-sycl/dpct/helper.hpp Outdated
#if (defined(__SYCL_COMPILER_VERSION) && __SYCL_COMPILER_VERSION >= 20221105)
if (!has(sycl::aspect::ext_intel_free_memory)) {
std::cerr << warning_info << std::endl;
if (!warned) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changed code want to print out the warning once.
But because this variable is static, it only prints out once even if there are multiple GPUs.

Get the free memory of GPU is always an issue.
I want to update it by a new PR to fix it and remove the warning.
I suggest not changing this part in the PR.

Comment thread ggml/src/ggml-sycl/ggml-sycl.cpp Outdated
g_ggml_sycl_enable_optimize = ggml_sycl_get_env("GGML_SYCL_ENABLE_OPT", 1);
g_ggml_sycl_enable_graph = ggml_sycl_get_env("GGML_SYCL_ENABLE_GRAPH", 0);
g_ggml_sycl_enable_dnn = ggml_sycl_get_env("GGML_SYCL_ENABLE_DNN", 1);
g_ggml_sycl_enable_dnn = ggml_sycl_get_env("GGML_SYCL_ENABLE_DNN", 1) && !ggml_sycl_get_env("GGML_SYCL_DISABLE_DNN", 0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
g_ggml_sycl_enable_dnn = ggml_sycl_get_env("GGML_SYCL_ENABLE_DNN", 1) && !ggml_sycl_get_env("GGML_SYCL_DISABLE_DNN", 0);
g_ggml_sycl_enable_dnn = ggml_sycl_get_env("GGML_SYCL_ENABLE_DNN", 1) ;

GGML_SYCL_DISABLE_DNN is renamed to GGML_SYCL_ENABLE_DNN in base code.

Comment thread ggml/src/ggml-sycl/ggml-sycl.cpp Outdated
g_ggml_sycl_fa_onednn = ggml_sycl_get_env("GGML_SYCL_FA_ONEDNN", 1);
g_ggml_sycl_fa_onednn_max_kv = ggml_sycl_get_env("GGML_SYCL_FA_ONEDNN_MAX_KV", 0);
g_ggml_sycl_enable_vmm = ggml_sycl_get_env("GGML_SYCL_ENABLE_VMM", 1);
g_ggml_sycl_enable_vmm = ggml_sycl_get_env("GGML_SYCL_ENABLE_VMM", 1) && !ggml_sycl_get_env("GGML_SYCL_DISABLE_VMM", 0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
g_ggml_sycl_enable_vmm = ggml_sycl_get_env("GGML_SYCL_ENABLE_VMM", 1) && !ggml_sycl_get_env("GGML_SYCL_DISABLE_VMM", 0);
g_ggml_sycl_enable_vmm = ggml_sycl_get_env("GGML_SYCL_ENABLE_VMM", 1);

GGML_SYCL_DISABLE_VMM is renamed to GGML_SYCL_ENABLE_VMM in base.

case GGML_TYPE_Q1_0:
case GGML_TYPE_Q4_0:
case GGML_TYPE_Q8_0:
case GGML_TYPE_Q2_K:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove GGML_TYPE_Q2_K?

static bool ggml_sycl_supports_reorder_esimd(enum ggml_type type) {
#ifdef GGML_SYCL_DMMV_HAS_ESIMD
switch (type) {
case GGML_TYPE_Q2_K:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove GGML_TYPE_Q2_K?

@arthw

arthw commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

I will verify the function on iGPU.

@arthw

arthw commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

@Pratyush-gg
I meet crash when execute the llama-bench on the iGPU (SYCL1) or dGPU(SYCL0) in my PC.
With base code, iGPU appear the OOM crash, dGPU is passed.
With this PR, both iGPU and dGPU crash for same log info.

sycl-ls
[level_zero:gpu][level_zero:0] Intel(R) oneAPI Unified Runtime over Level-Zero, Intel(R) Arc(TM) A770 Graphics 12.55.8 [1.15.39122+11]
[level_zero:gpu][level_zero:1] Intel(R) oneAPI Unified Runtime over Level-Zero, Intel(R) UHD Graphics 770 12.2.0 [1.15.39122+11]
[opencl:cpu][opencl:0] Intel(R) OpenCL, 13th Gen Intel(R) Core(TM) i7-13700K OpenCL 3.0 (Build 0) [2026.21.6.0.17_160000]
[opencl:gpu][opencl:1] Intel(R) OpenCL Graphics, Intel(R) Arc(TM) A770 Graphics OpenCL 3.0 NEO  [26.27.39122.11]
[opencl:gpu][opencl:2] Intel(R) OpenCL Graphics, Intel(R) UHD Graphics 770 OpenCL 3.0 NEO  [26.27.39122.11]

Log:

./build/bin/llama-bench -m /xxx/llama.cpp/models/Qwen3.5-9B.Q4_K_M.gguf -fa 1 --device SYCL1 -ngl -1
| model                          |       size |     params | backend    | ngl |  fa | dev          |            test |                  t/s |
| ------------------------------ | ---------: | ---------: | ---------- | --: | --: | ------------ | --------------: | -------------------: |
/hd1/jianyuzh/llama.cpp/Pratyush-gg_fix-sycl-igpu/ggml/src/ggml-sycl/ggml-sycl.cpp:1795: GGML_ASSERT(ptr == reinterpret_cast<void *>(pool_addr + pool_used)) failed
[New LWP 980547]
[New LWP 980542]
[New LWP 980515]
warning: File "/opt/intel/oneapi/compiler/2026.1/lib/libsycl.so.9.0.0-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
	add-auto-load-safe-path /opt/intel/oneapi/compiler/2026.1/lib/libsycl.so.9.0.0-gdb.py
line to your configuration file "/home/jianyuzh/.config/gdb/gdbinit".
To completely disable this security protection add
	set auto-load safe-path /
line to your configuration file "/home/jianyuzh/.config/gdb/gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
	info "(gdb)Auto-loading safe path"
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007ba9acb10913 in __GI___wait4 (pid=980548, stat_loc=0x0, options=0, usage=0x0) at ../sysdeps/unix/sysv/linux/wait4.c:30
warning: 30	../sysdeps/unix/sysv/linux/wait4.c: No such file or directory
#0  0x00007ba9acb10913 in __GI___wait4 (pid=980548, stat_loc=0x0, options=0, usage=0x0) at ../sysdeps/unix/sysv/linux/wait4.c:30
30	in ../sysdeps/unix/sysv/linux/wait4.c
#1  0x00007ba9b1325c2a in ggml_print_backtrace () from /hd1/jianyuzh/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libggml-base.so.0
#2  0x00007ba9b1324d99 in ggml_abort () from /hd1/jianyuzh/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libggml-base.so.0
#3  0x00007ba9ad4821e7 in ggml_sycl_pool_vmm::free(void*, unsigned long) () from /hd1/jianyuzh/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libggml-sycl.so.0
#4  0x00007ba9ad48527b in ggml_sycl_op_mul_mat_sycl(ggml_backend_sycl_context&, ggml_tensor const*, ggml_tensor const*, ggml_tensor*, char const*, float const*, char const*, float*, long, long, long, long, sycl::_V1::queue* const&) () from /hd1/jianyuzh/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libggml-sycl.so.0
#5  0x00007ba9ad44dfc4 in void ggml_sycl_op_mul_mat<no_quantize_q8_1>(ggml_backend_sycl_context&, ggml_tensor const*, ggml_tensor const*, ggml_tensor*, void (*)(ggml_backend_sycl_context&, ggml_tensor const*, ggml_tensor const*, ggml_tensor*, char const*, float const*, char const*, float*, long, long, long, long, sycl::_V1::queue* const&)) () from /hd1/jianyuzh/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libggml-sycl.so.0
#6  0x00007ba9ad443975 in ggml_sycl_mul_mat(ggml_backend_sycl_context&, ggml_tensor const*, ggml_tensor const*, ggml_tensor*) () from /hd1/jianyuzh/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libggml-sycl.so.0
#7  0x00007ba9ad43a61c in ggml_backend_sycl_graph_compute_impl(ggml_backend_sycl_context*, ggml_cgraph*) () from /hd1/jianyuzh/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libggml-sycl.so.0
#8  0x00007ba9ad438907 in ggml_backend_sycl_graph_compute(ggml_backend*, ggml_cgraph*) () from /hd1/jianyuzh/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libggml-sycl.so.0
#9  0x00007ba9b134d5b6 in ggml_backend_sched_graph_compute_async () from /hd1/jianyuzh/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libggml-base.so.0
#10 0x00007ba9b14cb7a1 in llama_context::graph_compute(ggml_cgraph*, bool) () from /hd1/jianyuzh/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libllama.so.0
#11 0x00007ba9b14cafe5 in llama_context::process_ubatch(llama_ubatch const&, llm_graph_type, llama_memory_context_i*, ggml_status&) () from /hd1/jianyuzh/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libllama.so.0
#12 0x00007ba9b14cd132 in llama_context::decode(llama_batch const&) () from /hd1/jianyuzh/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libllama.so.0
#13 0x00007ba9b14d229b in llama_decode () from /hd1/jianyuzh/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libllama.so.0
#14 0x00007ba9b1cf5cdf in test_prompt(llama_context*, int, int, int) () from /hd1/jianyuzh/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libllama-bench-impl.so
#15 0x00007ba9b1cefef2 in llama_bench(int, char**) () from /hd1/jianyuzh/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libllama-bench-impl.so
#16 0x00007ba9aca2a1ca in __libc_start_call_main (main=main@entry=0x4064f0 <main>, argc=argc@entry=9, argv=argv@entry=0x7ffda92d5468) at ../sysdeps/nptl/libc_start_call_main.h:58
warning: 58	../sysdeps/nptl/libc_start_call_main.h: No such file or directory
#17 0x00007ba9aca2a28b in __libc_start_main_impl (main=0x4064f0 <main>, argc=9, argv=0x7ffda92d5468, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffda92d5458) at ../csu/libc-start.c:360
warning: 360	../csu/libc-start.c: No such file or directory
#18 0x0000000000406425 in _start ()
[Inferior 1 (process 980513) detached]
Aborted (core dumped)

@Pratyush-gg

Copy link
Copy Markdown
Contributor Author

@arthw I have made the changes as suggested by you.
Also the crash you got in ggml_sycl_pool_vmm::free() because get_scratchpad_mem() was allocating 1 byte buffer into lifo vmm pool when scratchpad_md.get_size() == 0. it was violating the strict LIFO stack deallocation order of ggml_sycl_pool_vmm when scoped temporary tensors (src0_as_f16, src1_as_f16) were freed.

I have updated get_scratchpad_mem() to return dnnl::memory(scratchpad_md, eng, nullptr) when scratchpad_md.get_size() == 0. I have also removed the DISABLE_* variable aliases in favor of the standard GGML_SYCL_ENABLE_* flags.

I was using these setting when running for igpu before:
export GGML_SYCL_USE_LEVEL_ZERO_API=1
export UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS=1
export ZES_ENABLE_SYSMAN=1
export GGML_SYCL_ENABLE_DNN=0
export GGML_SYCL_ENABLE_VMM=0
export SYCL_CACHE_PERSISTENT=1

Could you please retest on discrete and igpu with the latest commit? Thanks!"

@arthw

arthw commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

@Pratyush-gg
I still meet the crash after update the PR code.
I set env vars as following and use default. Both are same error:
export GGML_SYCL_USE_LEVEL_ZERO_API=1
export UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS=1
export ZES_ENABLE_SYSMAN=1
export GGML_SYCL_ENABLE_DNN=0
export GGML_SYCL_ENABLE_VMM=0

Don't use it export SYCL_CACHE_PERSISTENT=1 in development env.

I'm afraid the issue is not easy to fix.

Thank you!

./build/bin/llama-bench -m /home/jianyuzh/ws/llama.cpp/models/llama-2-7b.Q4_0.gguf  -fa 1,0 --device SYCL1 -ngl -1 
| model                          |       size |     params | backend    | ngl |  fa | dev          |            test |                  t/s |
| ------------------------------ | ---------: | ---------: | ---------- | --: | --: | ------------ | --------------: | -------------------: |
level_zero backend failed with error: 39 (UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY)
Exception caught at file:/home/jianyuzh/ws/llama.cpp/Pratyush-gg_fix-sycl-igpu/ggml/src/ggml-sycl/ggml-sycl.cpp, line:5534, func:operator()
SYCL error: CHECK_TRY_ERROR((stream)->memcpy( data, (const char *)tensor->data + offset, size)): Exception caught in this line of code.
  in function ggml_backend_sycl_get_tensor_async at /home/jianyuzh/ws/llama.cpp/Pratyush-gg_fix-sycl-igpu/ggml/src/ggml-sycl/ggml-sycl.cpp:5534
/home/jianyuzh/ws/llama.cpp/Pratyush-gg_fix-sycl-igpu/ggml/src/ggml-sycl/../ggml-sycl/common.hpp:155: SYCL error
[New LWP 2090874]
[New LWP 2090870]
[New LWP 2090862]

This GDB supports auto-downloading debuginfo from the following URLs:
  <https://debuginfod.ubuntu.com>
Enable debuginfod for this session? (y or [n]) [answered N; input not from terminal]
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.
warning: File "/opt/intel/oneapi/compiler/2026.1/lib/libsycl.so.9.0.0-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
	add-auto-load-safe-path /opt/intel/oneapi/compiler/2026.1/lib/libsycl.so.9.0.0-gdb.py
line to your configuration file "/home/jianyuzh/.config/gdb/gdbinit".
To completely disable this security protection add
	set auto-load safe-path /
line to your configuration file "/home/jianyuzh/.config/gdb/gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
	info "(gdb)Auto-loading safe path"
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x0000717285b10913 in __GI___wait4 (pid=2090875, stat_loc=0x0, options=0, usage=0x0) at ../sysdeps/unix/sysv/linux/wait4.c:30
warning: 30	../sysdeps/unix/sysv/linux/wait4.c: No such file or directory
#0  0x0000717285b10913 in __GI___wait4 (pid=2090875, stat_loc=0x0, options=0, usage=0x0) at ../sysdeps/unix/sysv/linux/wait4.c:30
30	in ../sysdeps/unix/sysv/linux/wait4.c
#1  0x000071728ad2bc0a in ggml_print_backtrace () from /home/jianyuzh/ws/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libggml-base.so.0
#2  0x000071728ad2ad79 in ggml_abort () from /home/jianyuzh/ws/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libggml-base.so.0
#3  0x0000717286424608 in ggml_sycl_error(char const*, char const*, char const*, int, char const*) () from /home/jianyuzh/ws/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libggml-sycl.so.0
#4  0x0000717286438432 in ggml_backend_sycl_get_tensor_async(ggml_backend*, ggml_tensor const*, void*, unsigned long, unsigned long) () from /home/jianyuzh/ws/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libggml-sycl.so.0
#5  0x000071728a4cd326 in llama_context::decode(llama_batch const&) () from /home/jianyuzh/ws/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libllama.so.0
#6  0x000071728a4d20db in llama_decode () from /home/jianyuzh/ws/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libllama.so.0
#7  0x000071728ae2fcef in test_prompt(llama_context*, int, int, int) () from /home/jianyuzh/ws/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libllama-bench-impl.so
#8  0x000071728ae29f02 in llama_bench(int, char**) () from /home/jianyuzh/ws/llama.cpp/Pratyush-gg_fix-sycl-igpu/build/bin/libllama-bench-impl.so
#9  0x0000717285a2a1ca in __libc_start_call_main (main=main@entry=0x4064f0 <main>, argc=argc@entry=9, argv=argv@entry=0x7ffe0e84b938) at ../sysdeps/nptl/libc_start_call_main.h:58
warning: 58	../sysdeps/nptl/libc_start_call_main.h: No such file or directory
#10 0x0000717285a2a28b in __libc_start_main_impl (main=0x4064f0 <main>, argc=9, argv=0x7ffe0e84b938, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffe0e84b928) at ../csu/libc-start.c:360
warning: 360	../csu/libc-start.c: No such file or directory
#11 0x0000000000406425 in _start ()
[Inferior 1 (process 2090860) detached]
Aborted (core dumped)

@Pratyush-gg

Copy link
Copy Markdown
Contributor Author

@arthw thanks for testing this again

this OOM in ggml_backend_sycl_get_tensor_async looks like a different bug from the LIFO/scratchpad crash you hit before (that one's fixed in 0a1554f).

I tried to reproduce it on my own hardware my i9-14900K's UHD 770 iGPU, and separately a laptop with Iris Xe using the same model, flags, and env vars you posted (llama-2-7b.Q4_0.gguf, -ngl -1, -fa 0 and -fa 1 run separately, GGML_SYCL_ENABLE_DNN=0 GGML_SYCL_ENABLE_VMM=0), and also toggled GGML_SYCL_USE_LEVEL_ZERO_API=0 vs =1. All four combinations pass cleanly on both machines, no crash.

The one structural difference I can see between our setups is device count. I only have a single Level-Zero GPU on either machine, while your sycl-ls shows two (Arc A770 as SYCL0, UHD 770 as SYCL1). Looking at dev_mgr in dpct/helper.hpp, _devs[0] is whatever sycl::default_selector_v picks (likely the Arc on your box) and _devs[1] only gets appended because a second device exists to enumerate at all so this might be something that only surfaces with 2+ level zero devices alive in the process, rather than the iGPU specifically.

Could you help narrow it down with two more tests when you get a chance?

  1. Fully hide the Arc from the SYCL runtime (not just --device, which still leaves both enumerated) and see if it still crashes on the iGPU alone:
export ONEAPI_DEVICE_SELECTOR=level_zero:1
./build/bin/llama-bench -m llama-2-7b.Q4_0.gguf -fa 1,0 -ngl -1
  1. Run the Arc alone with the same env vars as before, to see if it hits the identical error:
./build/bin/llama-bench -m llama-2-7b.Q4_0.gguf -fa 1,0 --device SYCL0 -ngl -1

If you can reproduce it again, a trace would help pin down the actual error under the generic OOM message:

export SYCL_UR_TRACE=2
export ZE_DEBUG=1

@KellenRenshaw

Copy link
Copy Markdown

I had a similar OOM with a Intel Meteor Lake iGPU and B580 eGPU. Attempting to run on the MTL iGPU resulted in this.

Aug 29 12:14:31 aibit-2 llama-server[13743]: [47131] level_zero backend failed with error: 39 (UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY)
Aug 29 12:14:31 aibit-2 llama-server[13743]: [47131] Exception caught at file:/home/kellen/llama.cpp/ggml/src/ggml-sycl/ggml-sycl.cpp>
Aug 29 12:14:31 aibit-2 llama-server[13743]: [47131] SYCL error: CHECK_TRY_ERROR((stream)->memcpy( data, (const char *)tensor->data +>
Aug 29 12:14:31 aibit-2 llama-server[13743]: [47131]   in function ggml_backend_sycl_get_tensor_async at /home/kellen/llama.cpp/ggml/>
Aug 29 12:14:31 aibit-2 llama-server[13743]: [47131] /home/kellen/llama.cpp/ggml/src/ggml-sycl/../ggml-sycl/common.hpp:155: SYCL error
Aug 29 12:14:31 aibit-2 llama-server[13743]: [47131] /opt/llama.cpp/SYCL-mtl/lib/libggml-base.so.0(+0x16cf8) [0x7f1d5b328cf8]
Aug 29 12:14:31 aibit-2 llama-server[13743]: [47131] /opt/llama.cpp/SYCL-mtl/lib/libggml-base.so.0(ggml_print_backtrace+0x285) [0x7f1>
Aug 29 12:14:31 aibit-2 llama-server[13743]: [47131] /opt/llama.cpp/SYCL-mtl/lib/libggml-base.so.0(ggml_abort+0x109) [0x7f1d5b327d49]
Aug 29 12:14:31 aibit-2 llama-server[13743]: [47131] /opt/llama.cpp/SYCL-mtl/lib/libggml-sycl.so.0(+0x224618) [0x7f1d46424618]
Aug 29 12:14:31 aibit-2 llama-server[13743]: [47131] /opt/llama.cpp/SYCL-mtl/lib/libggml-sycl.so.0(+0x238412) [0x7f1d46438412]
Aug 29 12:14:31 aibit-2 llama-server[13743]: [47131] /opt/llama.cpp/SYCL-mtl/lib/libllama.so.0(_ZN13llama_context6decodeERK11llama_ba>
Aug 29 12:14:31 aibit-2 llama-server[13743]: [47131] /opt/llama.cpp/SYCL-mtl/lib/libllama.so.0(llama_decode+0xb) [0x7f1d5a8d491b]
Aug 29 12:14:31 aibit-2 llama-server[13743]: [47131] /opt/llama.cpp/SYCL-mtl/lib/libllama-common.so.0(_Z25common_context_can_seq_rmP1>
Aug 29 12:14:31 aibit-2 llama-server[13743]: [47131] /opt/llama.cpp/SYCL-mtl/lib/libllama-server-impl.so(_ZN19server_context_impl10lo>
Aug 29 12:14:31 aibit-2 llama-server[13743]: [47131] /opt/llama.cpp/SYCL-mtl/lib/libllama-server-impl.so(_Z12llama_serverR13common_pa>
Aug 29 12:14:31 aibit-2 llama-server[13743]: [47131] /opt/llama.cpp/SYCL-mtl/lib/libllama-server-impl.so(_Z12llama_serveriPPc+0x85) [>
Aug 29 12:14:31 aibit-2 llama-server[13743]: [47131] /usr/lib/x86_64-linux-gnu/libc.so.6(+0x2a8c1) [0x7f1d4522a8c1]
Aug 29 12:14:31 aibit-2 llama-server[13743]: [47131] /usr/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x88) [0x7f1d4522a9d8]
Aug 29 12:14:31 aibit-2 llama-server[13743]: [47131] /opt/llama.cpp/SYCL-mtl/bin/llama-server() [0x407425]
Aug 29 12:14:33 aibit-2 llama-server[13743]: 0.07.210.046 I srv    operator(): instance name=zerank-2 exited with status 1

Hiding the B580 with

export ONEAPI_DEVICE_SELECTOR=level_zero:1

caused the model to load normally.

Ran a trace, file is attached.
ze_debug.txt

Options were
export SYCL_UR_TRACE=2
export ZE_DEBUG=1

@arthw

arthw commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

@Pratyush-gg
Got it!
The device ID is important clue.

I'm checking this issue: crash on iGPU only.
I suggest pending this PR until I fix the crash issue.
So that this PR can be verified easily.

How do you think?

Thank you!

@Pratyush-gg

Copy link
Copy Markdown
Contributor Author

@arthw agreed lets hold this until its sorted. Worth noting your dgpu worked fine before this PR and broke with an earlier version of it, so I won't assume the current crash is unrelated to my changes either. Better to find the real cause first.

@KellenRenshaw Could you send a smaller trace? The full ze_debug.txt cut off before the actual crash. If you run:

journalctl -u llama-mtl.service --no-pager | grep -n "ggml_backend_sycl_get_tensor_async"

that gives you the line number of the crash, then pull a few thousand lines before it with sed and attach that instead. Should land right on the failing call.

Thanks both I'll keep testing on my end too.

@KellenRenshaw

Copy link
Copy Markdown

@Pratyush-gg Sorry about that, didn't realize it did that. Attaching a full log.
ze_debug.txt

@Pratyush-gg

Copy link
Copy Markdown
Contributor Author

@KellenRenshaw looks like GGML_SYCL_DEBUG was on but SYCL_UR_TRACE and ZE_DEBUG werent. Maybe llama server runs as a systemd service here, exporting those in your shell dont work, systemd services get their own environment.

Could you try and add them to the test instead?

systemctl edit llama-mtl.service

Add:

[Service]
Environment=SYCL_UR_TRACE=2
Environment=ZE_DEBUG=1

Then:

systemctl daemon-reload
systemctl restart llama-mtl.service

@KellenRenshaw

Copy link
Copy Markdown

Ok, pulled it out of the systemd unit, some sort of buffering was interfering with the output. Here's the run configuration:

source /opt/intel/oneapi/setvars.sh

:: initializing oneAPI environment ...
   -bash: BASH_VERSION = 5.3.9(1)-release
   args: Using "$@" for setvars.sh arguments:
:: ccl -- latest
:: compiler -- latest
:: debugger -- latest
:: dev-utilities -- latest
:: dnnl -- latest
:: dpl -- latest
:: mkl -- latest
:: mpi -- latest
:: pti -- latest
:: tbb -- latest
:: tcm -- latest
:: umf -- latest
:: oneAPI environment initialized ::

export ZES_ENABLE_SYSMAN=1
export SYCL_UR_TRACE=2
export ZE_DEBUG=1
export GGML_SYCL_USM_SYSTEM=1
export LD_LIBRARY_PATH=/opt/llama.cpp/SYCL-mtl/lib:$LD_LIBRARY_PATH
/opt/llama.cpp/SYCL-mtl/bin/llama-server --models-preset /home/kellen/models/models-mtl.preset --port 8081 | tee ze_debug.txt

ze_debug.txt

@KellenRenshaw

Copy link
Copy Markdown

Quick note, setting GGML_SYCL_USM_SYSTEM=0 didn't change the behavior.

Comment thread ggml/src/ggml-sycl/common.hpp Outdated
}
dnnl::memory get_scratchpad_mem(const dnnl::memory::desc & scratchpad_md,
const dnnl::engine & eng, const queue_ptr q) {
if (scratchpad_md.get_size() == 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. My PR sycl : fix oneDNN scratchpad breaking the pool free order #28704 removes this function entirely. Whoever merges second should remove the function on conflict resolution.
  2. My change also passes nullptr in case of 0 size scratchpad, so nothing you fixed here is lost.
  3. The LIFO assert which @arthw reported hits in a second scenario when get_size() > 0 and VMM works. The scenario is described in Eval bug: SYCL crash in ggml_sycl_pool_vmm::free - oneDNN scratchpad breaks LIFO pool order #28660 and I verified that the change here does not fix it (all fine, you had a different case).
  4. You may want to change std::max((size_t)1, ...) in description as your patch uses an early return now.
  5. I have machine with Arc Prov B70 and UHD Graphics 770 visible through LevelZero. Do you need help?

@lslusarczyk

Copy link
Copy Markdown
Contributor

@Pratyush-gg , the OOM errors which were met here are not related to your changes, but are caused by #28765. I managed to reproduce them and found the root cause on a clean master branch. Your code is clean as far as this crash is concerned.

Your hypothesis that this might be something that only surfaces with 2+ level zero devices alive in the process was very close to the truth, but the condition for the issue is having a non-zero SYCL index for the device.

@arthw, hypothesis about crash on iGPU only is false. The issue hits whatever GPU has non-zero index. You can verify that by swapping your devices with ONEAPI_DEVICE_SELECTOR=level_zero:1,0 and setting --device SYCL0. This will make iGPU work fine. Setting --device SYCL1 will make your A770 crash.

Workaround for the issue is to set GGML_SYCL_ENABLE_HOST_PINNED_MEM=0, so this PR can be verified easily.

I have a working fix for #28765 based on using the correct device index instead of the hardcoded 0 in ggml_backend_sycl_host_malloc. I will continue to verify it on Monday, unless you want to take over this issue and fix it yourself. In that case please let me know.

@arthw

arthw commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

@lslusarczyk
Yes, I have noticed that the Index 1 GPU has such issue.
Your analyis is correct.
It's great that you are working to fix it!

Thank you!

@lslusarczyk

Copy link
Copy Markdown
Contributor

@lslusarczyk Yes, I have noticed that the Index 1 GPU has such issue. Your analyis is correct. It's great that you are working to fix it!

@arthw , @KellenRenshaw , @Pratyush-gg , the PR with OOM fix is ready here #28895. You are welcome to verify and review.

@arthw

arthw commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

@Pratyush-gg
The following issues which impact this PR is fixed:

  • crash issue of iGPU
  • warning of get the free mem.

Could you rebase this PR?
We will retest and review it.

Thank you!

@Pratyush-gg Pratyush-gg changed the title sycl: fix zero size scratchpad crash and >4GB allocation limit on iGPU sycl: use ggml SYCL device allocation helpers for flash-attention KV buffers Sep 22, 2026

@lslusarczyk lslusarczyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead code removal is done perfectly. @arthw, go ahead with merging this

@arthw arthw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good job!
I have tested with UT and benchmark.
All are passed.

Thank you!

@arthw arthw added the merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. label Oct 6, 2026
@ggerganov
ggerganov merged commit 5e5b628 into ggml-org:master Oct 7, 2026
20 of 22 checks passed
edwardyoon pushed a commit to edwardyoon/focus-llama that referenced this pull request Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. SYCL https://en.wikipedia.org/wiki/SYCL - GPU programming language

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants