llama : synchronize context before backend teardown#24935
Open
krystophny wants to merge 1 commit into
Open
Conversation
krystophny
added a commit
to krystophny/llama.cpp
that referenced
this pull request
Jun 23, 2026
The synchronize-on-teardown fix (src/llama-context.cpp) and the phi3 meta split-state fix (src/llama-model.cpp) entered this branch via an upstream merge and are unrelated to the Responses API work. They are now filed independently as ggml-org#24935 and ggml-org#24936. Remove them here so this PR is limited to the server Responses changes.
|
Hi @krystophny, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
Member
|
It would be better to synchronize the contexts explicitly at the end of diff --git a/tests/test-thread-safety.cpp b/tests/test-thread-safety.cpp
index acda4aa81..d0b5946e2 100644
--- a/tests/test-thread-safety.cpp
+++ b/tests/test-thread-safety.cpp
@@ -146,6 +146,8 @@ int main(int argc, char ** argv) {
}
LOG_INF("Model %d/%d, Context %d/%d: %s\n\n", m + 1, num_models, c + 1, num_contexts, result.c_str());
+
+ llama_synchronize(ctx.get());
});
}
} |
Assisted-by: Claude
be1fd16 to
e654df6
Compare
Author
thx for the fast look, changed it! |
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
~llama_context()releases backend buffers without first drainingoutstanding GPU work. On a multi-GPU CUDA build this aborts during
teardown:
cudaFreereportsunspecified launch failureinside~ggml_backend_cuda_buffer_context. Callingsynchronize()at thestart of the destructor drains pending work before any buffer is freed.
Additional information
Reproduced on clean
master(dec5ca557), CUDA build, two RTX 5060 Ti(sm_120), CUDA 13.3.
Before:
After:
The abort surfaces on Blackwell here. The change is a teardown-ordering
fix and does not depend on the GPU.
Requirements
earlier work; AI assisted with bisecting the failure, building, and
running test-thread-safety. I reviewed every line, own the change,
and can explain it.