[PR #5405] [Engine] sycl: Prefill::release destroys the default in-order queue, and 349 frees use it afterwards at exit #5416

Open
opened 2026-11-07 16:35:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/5405
Author: @aslater3
Created: 11/6/2026
Status: 🔄 Open

Base: main ← Head: a770/up2-queue-release


📝 Commits (1)

  • 70cb539 sycl: Prefill::release must not destroy the default in-order queue

📊 Changes

1 file changed (+6 additions, -2 deletions)

View changed files

📝 sycl/src/prefill/prefill.cpp (+6 -2)

📄 Description

Problem and result

Prefill::Impl::kv_copy starts as &dpct::get_in_order_queue(). It only gets a queue of its own with
STRATA_KV_PREFETCH=1 (default off). Prefill::release() destroys it unconditionally, so on the default path it
destroys dpct's default in-order queue. dpct::get_in_order_queue() keeps returning that pointer afterwards, so every
later caller works on a freed queue.

On an unpatched build of 0.2.11 (its engine code is identical to main 9f7d977d), gdb shows the default queue
0x8560aa0 destroyed inside Prefill::release(). After that, 349 sycl::free calls pass that freed queue during
shutdown: 301 from NativeDense, 34 from Stager, 7 from MtpDrafter, 2 each from Prefill::release and
NativeHead, and 1 each from ExpertCache::close, FileExpertSource::close and NativeEmbed. Upstream does not
crash today, because sycl::free only reads the queue's context and that memory happens to still be intact.

On our Arc A770 branch, which adds one wait on the default queue while the expert cache is freed at exit, this
crashed in urQueueFinish: exit code 139 in 7 of 9 benchmark runs. gdb showed that the Level Zero queue handle
Prefill::release released was the one ExpertCache::close then waited on.

After this change the default queue is never destroyed, and kv_copy is cleared after release. With
STRATA_KV_PREFETCH=1 the separate queue is still destroyed, as before.

none (a focused fix)

Approach

Skip destroy_queue when kv_copy is the default in-order queue, and set kv_copy = nullptr afterwards. Five
lines in sycl/src/prefill/prefill.cpp. No behaviour change except at shutdown. Other destroy_queue calls in the
engine replace the queue with a newly created one before destroying it, so they don't have this problem.

Validation

Arc A770 16 GB (xe, Linux 7.0), oneAPI 2026.1 icpx, Ryzen 7 3800X, 30 GB RAM, no swap. Model Qwen3.8-Flash-Next
IQ1_M, --resident-experts --expert-cache auto --max-context 131072 --kv int8 --kv-resident 20480 --spec 4 --mtp,
--prefill auto, greedy, 8K-token prompt, 256 new tokens.

Passed:

  • cmake --build build-sycl --target strata (SYCL, Release) on main 9f7d977d + this commit: builds clean.
  • gdb on unpatched 0.2.11 (breakpoints on Prefill::release, dpct::device_ext::destroy_queue, sycl::free):
    the trace above.
  • main + this commit, 3 runs: exit 0 each time. Prompt 469.9 / 464.3 / 467.4 tok/s, generating 32.08 / 31.42 /
    30.87 tok/s. Same range as unpatched 0.2.11 earlier the same day (466 / 32.6).
  • On the A770 branch that crashed: 0 crashes in 36 runs after the fix (6 + 20 + 10), against 7 of 9 before.

Failed: none observed.

Not run: CUDA and HIP, because the change is in sycl/ only. Windows and i915 not tested. Same for
STRATA_KV_PREFETCH=1, whose path this change does not touch.

Limits

Upstream does not crash on the default path today. Without this fix, the shutdown sycl::free calls listed above
still run through a freed queue, and any future wait or submit on the default queue after Prefill::release would
crash.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/5405 **Author:** [@aslater3](https://github.com/aslater3) **Created:** 11/6/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `a770/up2-queue-release` --- ### 📝 Commits (1) - [`70cb539`](https://github.com/Niko1221/Strata/commit/70cb539135b9131f93d534ec85c4156d71229742) sycl: Prefill::release must not destroy the default in-order queue ### 📊 Changes **1 file changed** (+6 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `sycl/src/prefill/prefill.cpp` (+6 -2) </details> ### 📄 Description ## Problem and result `Prefill::Impl::kv_copy` starts as `&dpct::get_in_order_queue()`. It only gets a queue of its own with `STRATA_KV_PREFETCH=1` (default off). `Prefill::release()` destroys it unconditionally, so on the default path it destroys dpct's default in-order queue. `dpct::get_in_order_queue()` keeps returning that pointer afterwards, so every later caller works on a freed queue. On an unpatched build of 0.2.11 (its engine code is identical to `main` 9f7d977d), gdb shows the default queue `0x8560aa0` destroyed inside `Prefill::release()`. After that, 349 `sycl::free` calls pass that freed queue during shutdown: 301 from `NativeDense`, 34 from `Stager`, 7 from `MtpDrafter`, 2 each from `Prefill::release` and `NativeHead`, and 1 each from `ExpertCache::close`, `FileExpertSource::close` and `NativeEmbed`. Upstream does not crash today, because `sycl::free` only reads the queue's context and that memory happens to still be intact. On our Arc A770 branch, which adds one wait on the default queue while the expert cache is freed at exit, this crashed in `urQueueFinish`: exit code 139 in 7 of 9 benchmark runs. gdb showed that the Level Zero queue handle `Prefill::release` released was the one `ExpertCache::close` then waited on. After this change the default queue is never destroyed, and `kv_copy` is cleared after release. With `STRATA_KV_PREFETCH=1` the separate queue is still destroyed, as before. ## Related discussion none (a focused fix) ## Approach Skip `destroy_queue` when `kv_copy` is the default in-order queue, and set `kv_copy = nullptr` afterwards. Five lines in `sycl/src/prefill/prefill.cpp`. No behaviour change except at shutdown. Other `destroy_queue` calls in the engine replace the queue with a newly created one before destroying it, so they don't have this problem. ## Validation Arc A770 16 GB (xe, Linux 7.0), oneAPI 2026.1 icpx, Ryzen 7 3800X, 30 GB RAM, no swap. Model Qwen3.8-Flash-Next IQ1_M, `--resident-experts --expert-cache auto --max-context 131072 --kv int8 --kv-resident 20480 --spec 4 --mtp`, `--prefill auto`, greedy, 8K-token prompt, 256 new tokens. **Passed:** - `cmake --build build-sycl --target strata` (SYCL, Release) on `main` 9f7d977d + this commit: builds clean. - gdb on unpatched 0.2.11 (breakpoints on `Prefill::release`, `dpct::device_ext::destroy_queue`, `sycl::free`): the trace above. - `main` + this commit, 3 runs: exit 0 each time. Prompt 469.9 / 464.3 / 467.4 tok/s, generating 32.08 / 31.42 / 30.87 tok/s. Same range as unpatched 0.2.11 earlier the same day (466 / 32.6). - On the A770 branch that crashed: 0 crashes in 36 runs after the fix (6 + 20 + 10), against 7 of 9 before. **Failed:** none observed. **Not run:** CUDA and HIP, because the change is in `sycl/` only. Windows and i915 not tested. Same for `STRATA_KV_PREFETCH=1`, whose path this change does not touch. ## Limits Upstream does not crash on the default path today. Without this fix, the shutdown `sycl::free` calls listed above still run through a freed queue, and any future wait or submit on the default queue after `Prefill::release` would crash. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5416
No description provided.