forked from ggml-org/llama.cpp
-
Notifications
You must be signed in to change notification settings - Fork 4
[Mirror] server: improve slots scheduling for n_cmpl #80
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
Open
ngxson
wants to merge
13
commits into
master
Choose a base branch
from
xsn/n_cmpl_sync_barrier
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+194
−103
Open
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b55964a
server : make sure children tasks are scheduled to launch with parent
ngxson e32545f
fix
ngxson 821e329
add comment pointing to this PR
ngxson 25702ba
fix
ngxson 9481b9d
clean up
ngxson f0349e4
more debug messages
ngxson da6e2ba
add pop_deferred_task with specific ID version
ngxson d6b0d23
improve the logic
ngxson ba86ad9
simple approach
ngxson 79c1967
no double move
ngxson d5505b1
Merge branch 'master' into xsn/n_cmpl_sync_barrier
ngxson 8b5474a
correct return type of launch_slots_with_parent_task
ngxson 64b48eb
Merge branch 'master' into xsn/n_cmpl_sync_barrier
ngxson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Return values are inverted due to bool/int mismatch.
The function returns
boolbut uses integer return values (return 0for success,return 2for failure). Due to implicit conversion:return 0→false(but should indicate success)return 2→true(but should indicate failure)At the call site (line 1755),
!launch_slots_with_parent_task(...)will:!false = true→ enters error branch incorrectly!true = false→ skips error branch incorrectly🐛 Proposed fix
// launch multiple slots for parent + child tasks bool launch_slots_with_parent_task(server_slot & parent_slot, std::vector<server_slot *> & child_slots, server_task && parent_task) { GGML_ASSERT(!parent_slot.is_processing()); GGML_ASSERT(parent_task.is_parent()); GGML_ASSERT(child_slots.size() == parent_task.child_tasks.size()); int id_parent = parent_task.id; SRV_INF("launching slots for parent task id_task = %d with %zu child tasks\n", id_parent, parent_task.child_tasks.size()); // to be called in case of failure to release all launched slots auto release_slots = [this, id_parent]() { for (auto & slot : slots) { if (slot.is_processing() && ( slot.task->id == id_parent || slot.task->id_parent == id_parent )) { slot.release(); } } }; // launch all child tasks first size_t idx = 0; GGML_ASSERT(child_slots.size() == parent_task.child_tasks.size()); for (auto * slot : child_slots) { int id_child = parent_task.child_tasks[idx].id; if (!launch_slot_with_task(*slot, std::move(parent_task.child_tasks[idx]))) { SRV_ERR("failed to launch slot with child task, id_task = %d\n", id_child); release_slots(); - return 2; + return false; } idx++; } // finally, launch the parent task if (!launch_slot_with_task(parent_slot, std::move(parent_task))) { SRV_ERR("failed to launch slot with task, id_task = %d\n", id_parent); release_slots(); - return 2; + return false; } - return 0; + return true; }🤖 Prompt for AI Agents