From ce79ded4cb740cfb65b6929ef02bd93e192dd25b Mon Sep 17 00:00:00 2001 From: MengAiDev <3463526515@qq.com> Date: Tue, 26 Aug 2025 12:20:38 +0800 Subject: [PATCH 1/2] fix(ggml-sycl): add synchronization before exiting argsort kernel - Add `stream->wait()` to ensure all kernels finish execution before proceeding - This resolves potential race conditions in the argsort operation --- ggml/src/ggml-sycl/ggml-sycl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ggml/src/ggml-sycl/ggml-sycl.cpp b/ggml/src/ggml-sycl/ggml-sycl.cpp index 12dd5dd2e6287..d1c07e7db10ec 100644 --- a/ggml/src/ggml-sycl/ggml-sycl.cpp +++ b/ggml/src/ggml-sycl/ggml-sycl.cpp @@ -1774,7 +1774,9 @@ static void argsort_f32_i32_sycl(const float *x, int *dst, const int ncols, } else { GGML_ABORT("fatal error"); } -} + + // Ensure all kernels finish execution before proceeding further + stream->wait(); static void argmax_f32_i32_sycl(const float *x, int *dst, const int ncols, const int nrows, queue_ptr stream) { From afb6f450bda6d54c8a93d8aaa66f81d693302239 Mon Sep 17 00:00:00 2001 From: MengAiDev <3463526515@qq.com> Date: Thu, 28 Aug 2025 08:28:11 +0800 Subject: [PATCH 2/2] fix --- ggml/src/ggml-sycl/ggml-sycl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ggml/src/ggml-sycl/ggml-sycl.cpp b/ggml/src/ggml-sycl/ggml-sycl.cpp index d1c07e7db10ec..4464369a8608d 100644 --- a/ggml/src/ggml-sycl/ggml-sycl.cpp +++ b/ggml/src/ggml-sycl/ggml-sycl.cpp @@ -1777,6 +1777,7 @@ static void argsort_f32_i32_sycl(const float *x, int *dst, const int ncols, // Ensure all kernels finish execution before proceeding further stream->wait(); +} static void argmax_f32_i32_sycl(const float *x, int *dst, const int ncols, const int nrows, queue_ptr stream) {