Repository navigation
common: support CPU parameters across tools - #27026
Conversation
|
/bot review |
Automated code reviewI reviewed the PR diff and explored the surrounding code (common.cpp init path, common.h, completion.cpp before/after, the server and parallel tools, ggml threadpool lifecycle, and llama_context attach/detach). The change moves the threadpool/priority setup that previously lived in Will slow the review(point 1) No null check on the proc-address function pointers before use ( (point 2) Behavior change for (point 3) Threadpool lifetime vs. Nits(point 4) (point 5) The header re-alignment of What looks right
This review was generated automatically by pi coding agent using |
|
Regarding the review:
|
|
There is one concern that I'm thinking about though (not sure if it's mentioned in the bot review) An example can create multiple This case is valid on server: target and draft models have different contexts, managed by different instances of |
|
@ngxson Yes, 100%. I was planning to address this in a follow-up PR by making both contexts share the thread pool. I saw this happening in The bot was reasoning about it but it didn't bring it up because of this note from the PR description:
|
|
hmm unfortunately I'm not experience enough in this part to tell if we gonna run into any correctness issues if we don't implement the threadpool reuse right away (in other words, will be version between when this is merged and the follow-up fix will be broken somehow?) otherwise, I think it might be better to ship everything in this PR? CC @ggerganov if you have more info about this |
|
ok so a bit more deep dive, seems like before this PR, ggml's cplan creates a disposable threadpool for each decode pass so this PR only make all decode calls of the same context reuse the same threadpool, should be a harmless change so it's ok to merge as-is, thanks for the refactoring |
|
Sorry for the delayed response!
That was also my conclusion. I wouldn’t have opened the PR as-is if that wasn’t the case. :) In the next few days, I’ll follow up with a PR to re-use the thread pool across drafter and main model contexts. Tracking issue: #27039 Thanks for reviewing and merging! Appreciate your help! 🙏 |
Overview
Fixes #26997
Adds support for CPU parameters such as
--cpu-mask,--cpu-range, and--priotollama-cli,llama-server, and other tools.I mostly moved code from
tools/completion/completion.cppintocommon/common.cpp.Additional information
If applying CPU parameters fails, it will log a warning, but it won't crash the app. In my opinion, it's better to continue with the wrong parameters than to exit.
There's a follow-up to use thread pools properly with speculative decoding, which probably means sharing thread pools between the draft model and the target model. I'll work on that as a follow-up PR after this is merged.
Requirements