[PR #5161] [Engine] generate (SYCL): release draft layer buffers before exiting main #5328

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/5161
Author: @sruggier
Created: 11/3/2026
Status: 🔄 Open

Base: main ← Head: fix-SYCL-MTP-teardown


📝 Commits (1)

  • 86f66e1 generate (SYCL): release draft layer buffers before exiting main

📊 Changes

5 files changed (+107 additions, -27 deletions)

View changed files

📝 docs/INTEL.md (+1 -0)
📝 sycl/include/strata/core/mtp.hpp (+4 -0)
📝 sycl/src/core/mtp.cpp (+33 -27)
📝 sycl/src/program/generate.cpp (+6 -0)
➕ sycl/tools/test_mtp_teardown.sh (+63 -0)

📄 Description

I reported this in #5159. See below for model-generated answers to the PR template:

Problem and result

Problem. A one-shot strata generate run with the MTP drafter faults after it has finished: decode, prefill and time to first token all print, then Segmentation fault (core dumped), exit 139. The numbers are complete; the exit code is not, and nothing after the summary runs (profile write-back, clean teardown).

Result after the change. The same commands exit 0.

Approach

MtpDrafter::release() hands the buffers back - the graph captures first, then the buffers, each pointer nulled as it goes so it is safe to call twice - and generate.cpp calls it, for the canonical drafter and for the batch slots' drafters, next to the buffers it already frees by hand before returning. The destructor calls release() too.

This is the failure the port already names where a server closes: "Their destructors ran against a runtime already shutting down and aborted (exit 139)", dodged there with _Exit after gguf_src.close(). The one-shot path already frees d_next, d_logits, d_emb, d_parts, sbuf and arena by hand for the same reason - it just left the largest holder of device memory to its destructor. docs/INTEL.md gets the one-line entry in the list of fixed bugs so the symptom is searchable.

Validation

Passed (all on an Arc A770 16 GB, i915, the environment above):

  • v0.2.10 built clean in a separate worktree, the reproducer above: 139.
  • fix-sycl-mtp-teardown built clean: --spec 4 --max-new 512 twice, --spec 4 --max-new 192, --spec 3 --max-new 512, --spec 4 --max-new 64 - 0, 0, 0, 0, 0.
  • sycl/tools/test_mtp_teardown.sh (new, four arms, first arm repeated because the fault was flaky at 192 tokens and reliable at 512): PASS: 4 speculation arms generated their full reply and exited 0.
  • sycl/tools/test_prompt_deadlock.sh: PASS: the 2,743-token prompt was read (prefill 2743 tokens in 39383.0 ms -> 69.65 tok/s).
  • python -m pytest tests/sycl -q: 15 passed.

Failed: none observed after the change. Before the change, the four arms of test_mtp_teardown.sh were the failures listed above (139 each).

Not run:

  • CUDA and HIP builds. Every file the change touches is under sycl/ (sycl/include/strata/core/mtp.hpp, sycl/src/core/mtp.cpp, sycl/src/program/generate.cpp); MtpDrafter::release() is declared in the SYCL header, where the members it frees are. No CUDA or HIP file was changed, and neither backend was built or executed here.
  • Whether the same class of fault reaches the CUDA/HIP ports' teardown: unconfirmed static analysis. Both ports free their drafter buffers in ~MtpDrafter at the end of main; I did not observe a fault there and have no CUDA or AMD hardware.
  • A Windows or xe-driver run, and a Battlemage card: not available on this box.

Limits

  • This makes the port hand its buffers back while the device is plainly still there. It does not change why the runtime is already part-way down by the time main's last object is destroyed - a destructor ordering upstream could fix instead, at which point release() becomes a belt-and-braces call rather than the remedy.
  • The server path still avoids the same class with _Exit instead of unwinding, and this change does not touch it.
  • The boundary is soft. --spec 4 --max-new 192 was 0, 0 and 139 on three runs of one build before the change, so a single clean run at some generation length is not evidence the fault is absent; that is what the repeated arm in test_mtp_teardown.sh is for.

🔄 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/5161 **Author:** [@sruggier](https://github.com/sruggier) **Created:** 11/3/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-SYCL-MTP-teardown` --- ### 📝 Commits (1) - [`86f66e1`](https://github.com/Niko1221/Strata/commit/86f66e18b35197c29a6f3bf233370a5de6bf95b8) generate (SYCL): release draft layer buffers before exiting main ### 📊 Changes **5 files changed** (+107 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `docs/INTEL.md` (+1 -0) 📝 `sycl/include/strata/core/mtp.hpp` (+4 -0) 📝 `sycl/src/core/mtp.cpp` (+33 -27) 📝 `sycl/src/program/generate.cpp` (+6 -0) ➕ `sycl/tools/test_mtp_teardown.sh` (+63 -0) </details> ### 📄 Description I reported this in #5159. See below for model-generated answers to the PR template: ## Problem and result **Problem.** A one-shot `strata generate` run with the MTP drafter faults after it has finished: `decode`, `prefill` and `time to first token` all print, then `Segmentation fault (core dumped)`, exit 139. The numbers are complete; the exit code is not, and nothing after the summary runs (profile write-back, clean teardown). **Result after the change.** The same commands exit 0. ## Approach `MtpDrafter::release()` hands the buffers back - the graph captures first, then the buffers, each pointer nulled as it goes so it is safe to call twice - and `generate.cpp` calls it, for the canonical drafter and for the batch slots' drafters, next to the buffers it already frees by hand before returning. The destructor calls `release()` too. This is the failure the port already names where a server closes: *"Their destructors ran against a runtime already shutting down and aborted (exit 139)"*, dodged there with `_Exit` after `gguf_src.close()`. The one-shot path already frees `d_next`, `d_logits`, `d_emb`, `d_parts`, `sbuf` and `arena` by hand for the same reason - it just left the largest holder of device memory to its destructor. `docs/INTEL.md` gets the one-line entry in the list of fixed bugs so the symptom is searchable. ## Validation **Passed** (all on an Arc A770 16 GB, `i915`, the environment above): * `v0.2.10` built clean in a separate worktree, the reproducer above: **139**. * `fix-sycl-mtp-teardown` built clean: `--spec 4 --max-new 512` twice, `--spec 4 --max-new 192`, `--spec 3 --max-new 512`, `--spec 4 --max-new 64` - **0, 0, 0, 0, 0**. * `sycl/tools/test_mtp_teardown.sh` (new, four arms, first arm repeated because the fault was flaky at 192 tokens and reliable at 512): `PASS: 4 speculation arms generated their full reply and exited 0`. * `sycl/tools/test_prompt_deadlock.sh`: `PASS: the 2,743-token prompt was read (prefill 2743 tokens in 39383.0 ms -> 69.65 tok/s)`. * `python -m pytest tests/sycl -q`: `15 passed`. **Failed:** none observed after the change. Before the change, the four arms of `test_mtp_teardown.sh` were the failures listed above (139 each). **Not run:** * CUDA and HIP builds. Every file the change touches is under `sycl/` (`sycl/include/strata/core/mtp.hpp`, `sycl/src/core/mtp.cpp`, `sycl/src/program/generate.cpp`); `MtpDrafter::release()` is declared in the SYCL header, where the members it frees are. No CUDA or HIP file was changed, and neither backend was built or executed here. * Whether the same class of fault reaches the CUDA/HIP ports' teardown: **unconfirmed static analysis**. Both ports free their drafter buffers in `~MtpDrafter` at the end of `main`; I did not observe a fault there and have no CUDA or AMD hardware. * A Windows or `xe`-driver run, and a Battlemage card: not available on this box. ## Limits * This makes the port hand its buffers back while the device is plainly still there. It does not change *why* the runtime is already part-way down by the time `main`'s last object is destroyed - a destructor ordering upstream could fix instead, at which point `release()` becomes a belt-and-braces call rather than the remedy. * The server path still avoids the same class with `_Exit` instead of unwinding, and this change does not touch it. * The boundary is soft. `--spec 4 --max-new 192` was 0, 0 and 139 on three runs of one build before the change, so a single clean run at some generation length is not evidence the fault is absent; that is what the repeated arm in `test_mtp_teardown.sh` is for. --- <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#5328
No description provided.