concurrency implementation for llama.cpp#14
Merged
victorchall merged 1 commit intomainfrom Nov 3, 2025
Merged
Conversation
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.
This adds a simple batching and async.gather loop to enable batch concurrency when using hosts such as llama.cpp that allow concurrent generation. Note: LM Studio does not support batch concurrency, users will have to switch over to llama.cpp or another host that does to use this feature.
Seems like a fairly modest gain using Qwen3 VL 32B on RTX 6000 Blackwell, but still worth it.
Another enhancement for later would be adding using the OpenAI batch api spec that allows batching into JSONL, but this may or may not be supported by any hosts, will be left for a future investigation implementation.
Additionally, I'm not certain llama.cpp and this app will always be guaranteed to align the requests to the slots that have the same history and kv cache for the subsequent requests, but needs more investigation.
Example llama.cpp command to enable concurrency via
-npllama-server -np 4 -c 32768 --mmproj "mmproj-Qwen3-VL-32B-Instruct-F16.gguf" --model "Qwen3-VL-32B-Instruct-Q4_K_M.gguf" -dev cuda0 --top-k 30 --top-p 0.95 --min-p 0.05 --temp 0.5Note the context size
-cshould be increased by a multiple of the value for-npto make sure each slot has sufficient context. Ex.-np 4 -c 32768is 4 slots each with 8192 (32768/4) tokens of context.Some more info on llama.cpp's -np here: ggml-org/llama.cpp#3677