Repository navigation
vulkan: support buffer_from_host_ptr - #18467
Conversation
9680dc4 to
ef542b2
Compare
af04f6b to
ccffc46
Compare
|
Removed draft, this is ready for review now. I've changed ggml_vk_host_malloc to use the external_memory path, this should let the directio loading code work without any changes to the model loader. |
ggerganov
left a comment
There was a problem hiding this comment.
I did some tests on Mac + vulkan backend and didn't spot any issues.
Is PP and TG values for you same as past ? |
|
@engrtipusultan Yes, here are CMAKE_OPTS="-DGGML_VULKAN=ON -DGGML_METAL=OFF -DGGML_BLAS=OFF" ./scripts/compare-commits.sh master pr/18467 llama-bench -m ~/models/qwen2.5-3b-coder/ggml-model-q8_0.gguf -fa 1 -b 16384 -ub 2048 -p 0,512,2048 -n 64 -mmp 0,1
|
Thank you for double confirming. I have AMD APU, I am facing degradation. Please check if I am doing something wrong or other community member can check on their equivalent AMD APUs before merging this. |
|
Other observation: This PR loads the model even faster. 7GB/s instead of 5GB/s. PP is better without mmap, TG really does take a hit. And with a smaller model:
|
|
I'm going almost to the full 128G via the ttm module (GTT option is deprecated). |
|
@engrtipusultan please share a vulkaninfo report so I can see what your memory heaps/types look like. Maybe the new path is picking a suboptimal memory type (though I think this is unlikely). I think these allocations should only be used for input/output tensors, so I'm surprised it's such a slowdown. I think imported memory is supposed to be roughly the same speed as driver-allocated system memory, but it might be getting mapped with different attributes on some systems. Another possible issue might be if the allocation is failing, but I don't see evidence of that in the log. |
|
IIRC performance of GTT/TTM memory is also supposed to have improved a lot in recent versions of the kernel. I've also noticed that if I set |
|
@engrtipusultan one more request. Please run with the env vars GGML_VK_PERF_LOGGER=1 and GGML_VK_PERF_LOGGER_FREQUENCY=99999, and share a log for the slowdown and for master. It'll dump some stats on shutdown. If this is a GPU slowdown I expect to see more time spent in soft_max and set_rows (based on which allocations are in Vulkan_Host). It's also possible this has somehow slowed down the input embedding calculation that runs on the CPU. |
|
@jeffbolznv thank you for further looking into it. Please find required info below attached. |
|
I also compared TG from this pr against master with mmap 0 (mmap 1 and PP doesn't see the slowdown). Maybe these numbers reveal something. Qwen3-Next-80B-A3B-Instruct-UD-Q8_K_XL#18467
master be47fb9
Qwen3-Coder-30B-A3B-Instruct-UD-Q4_K_XL#18467
master be47fb9
|
|
I do also see a small slowdown on AMD 8060S: Master:
PR:
It goes away with mmap. Merging this is fine as long as it's possible to use a different loading path, which I think #18166 is working at. But I still have to go through the code before I merge this. |
|
I'm reluctant to merge it if it's going to slow down a significant number of devices. The other option would be to leave the ggml_vk_host_malloc path as-is, and have the model loader handle the bad address failure and fall back. Then you'd just get slower loading on those devices rather than slower inference. |
|
Slower loading rather than slower inference seems preferable, yes. |
|
#18166 Has a fallback implemented now. |
5168244 to
17c41b7
Compare
|
Latest commit is almost indistinguishable from master. t/s and loadtimes. |
|
Thanks for confirming. Yes, this should restore things to basically how they were (and it does not fix the Bad Address error). |
|
Was it intentional that you didn't set the device capability |
|
It was intentional, setting that causes all the tensors to be allocated in host memory. |
* vulkan: support buffer_from_host_ptr * hacky use of buffer_from_host_ptr for directio * disable buffer_from_host_ptr cap * use external memory for ggml_vk_host_malloc, revert model loader changes * disable external_memory_host for MoltenVK * take buffer memory types into account * don't use external_memory_host for ggml_vk_host_malloc
* vulkan: support buffer_from_host_ptr * hacky use of buffer_from_host_ptr for directio * disable buffer_from_host_ptr cap * use external memory for ggml_vk_host_malloc, revert model loader changes * disable external_memory_host for MoltenVK * take buffer memory types into account * don't use external_memory_host for ggml_vk_host_malloc
* vulkan: support buffer_from_host_ptr * hacky use of buffer_from_host_ptr for directio * disable buffer_from_host_ptr cap * use external memory for ggml_vk_host_malloc, revert model loader changes * disable external_memory_host for MoltenVK * take buffer memory types into account * don't use external_memory_host for ggml_vk_host_malloc
* vulkan: support buffer_from_host_ptr * hacky use of buffer_from_host_ptr for directio * disable buffer_from_host_ptr cap * use external memory for ggml_vk_host_malloc, revert model loader changes * disable external_memory_host for MoltenVK * take buffer memory types into account * don't use external_memory_host for ggml_vk_host_malloc
* vulkan: support buffer_from_host_ptr * hacky use of buffer_from_host_ptr for directio * disable buffer_from_host_ptr cap * use external memory for ggml_vk_host_malloc, revert model loader changes * disable external_memory_host for MoltenVK * take buffer memory types into account * don't use external_memory_host for ggml_vk_host_malloc
|
Follow-up on the gfx1151 |
* vulkan: support buffer_from_host_ptr * hacky use of buffer_from_host_ptr for directio * disable buffer_from_host_ptr cap * use external memory for ggml_vk_host_malloc, revert model loader changes * disable external_memory_host for MoltenVK * take buffer memory types into account * don't use external_memory_host for ggml_vk_host_malloc
For #18166 (comment).
Draft, the model loader change needs testing/polishing and to be merged with the other pending change.The change only affects the vulkan backend now.