Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server : implement cancellable request #11285

Merged
merged 4 commits into from
Jan 18, 2025

Conversation

ngxson
Copy link
Collaborator

@ngxson ngxson commented Jan 17, 2025

Close #9273

Related to yhirose/cpp-httplib#2022

For requests that can take long time like completions or embeddings, the queue will unblock HTTP thread every 1 second to check for the status of HTTP connection.

Because this is done at HTTP thread, it will not affect the performance of inference thread, while still maintaining thread-safety requirement.

@github-actions github-actions bot added examples python python script changes server labels Jan 17, 2025
@ngxson ngxson requested a review from ggerganov January 18, 2025 09:29
@ngxson ngxson marked this pull request as ready for review January 18, 2025 09:29
}

if (result == nullptr) {
i--; // retry
Copy link
Owner

Choose a reason for hiding this comment

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

For i == 0 this will underflow

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It will be i++ as soon as we call continue anyway, so should not be a big problem. But anw I changed i to int, to be more explicit about the case where it can be negative.

(Also, i is not used anywhere inside the loop body, so I assume that it's safe to make it an int here)

@ngxson ngxson merged commit f30f099 into ggerganov:master Jan 18, 2025
50 checks passed
anagri pushed a commit to BodhiSearch/llama.cpp that referenced this pull request Jan 26, 2025
* server : implement cancellable request

* fix typo

* httplib 0.18.5

* fix i underflow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
examples python python script changes server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: (Server) Cannot properly cancel a non-stream completion request
2 participants