vulkan: use CPU writes in ggml_backend_vk_cpy_tensor_async if the context is idle - #28618
Merged
Merged
Conversation
jeffbolznv
force-pushed
the
cpu_cpy_tensor_async
branch
from
September 9, 2026 19:31
fb4df22 to
60738df
Compare
0cc4m
approved these changes
Sep 10, 2026
1 task
pl752
pushed a commit
to pl752/llama.cpp
that referenced
this pull request
Sep 15, 2026
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
I've again run into a perf issue where downloading inputs from the CPU/previous split is fairly expensive due to overhead of waiting on a fence (roughly 50us each in my testing). A while back we had all of these running through ggml_vk_buffer_write_2d and using memcpy to host-visible vidmem. But I think when we enabled cpy_tensor_async they started using GPU copies and a synchronize call for each download. This is relatively worse in recent qwen/gemma4 models which download 2 inputs per token, each doing a full CPU-GPU sync.
Fix is to detect that the backend is idle and use a CPU copy if so. I had also considered trying to amortize the synchronize calls in ggml-backend, but there was a recent change that tried to do that (#20793) and it had to be reverted, so handling this in the vulkan backend seems safer.
Requirements