Skip to content

[ggml] Fix Vulkan-Hpp handle usage on 32-bit targets. - #22892

Merged
0cc4m merged 1 commit into
ggml-org:masterfrom
miyanyan:vk-32bit
Sep 8, 2026
Merged

0cc4m merged 1 commit into
ggml-org:masterfrom
miyanyan:vk-32bit

Conversation

@miyanyan

@miyanyan miyanyan commented May 10, 2026 •

Copy link
Copy Markdown
Contributor

Overview

On 32-bit platforms, Vulkan non-dispatchable handles such as VkBuffer are represented as uint64_t, and Vulkan-Hpp disables implicit conversions for type safety. This exposes two issues in ggml-vulkan:

  1. vk::Buffer is streamed directly into std::ostream in debug/memory logs.
  2. vk::Buffer is cast to VkBuffer before being passed to Vulkan-Hpp CommandBuffer::copyBuffer APIs.

Fix these by adding the operator<< for vk::Buffer, and by passing vk::Buffer directly to Vulkan-Hpp copyBuffer calls.

Additional information

Requirements

@miyanyan
miyanyan requested a review from a team as a code owner May 10, 2026 04:06
@github-actions github-actions Bot added Vulkan Issues specific to the Vulkan backend ggml changes relating to the ggml tensor library for machine learning labels May 10, 2026
@miyanyan miyanyan changed the title Fix Vulkan-Hpp handle usage on 32-bit targets. [ggml] Fix Vulkan-Hpp handle usage on 32-bit targets. May 10, 2026
@miyanyan

Copy link
Copy Markdown
Contributor Author

the ubuntu-24-webgpu ci error:

98% tests passed, 1 tests failed out of 44

Label Time Summary:
main    = 994.86 sec*proc (43 tests)

Total Test time (real) = 995.40 sec

The following tests FAILED:
	 39 - test-backend-ops (Timeout)                        main
Errors while running CTest
Output from these tests are in: /home/runner/work/llama.cpp/llama.cpp/build/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.
Error: Process completed with exit code 8.

@0cc4m

0cc4m commented May 26, 2026

Copy link
Copy Markdown
Contributor

You missed some cases, but instead of manually casting everything, wouldn't it be easier to add the operator for vk::Buffer, e.g. (untested):

inline std::ostream& operator<<(std::ostream& os, vk::Buffer b) {
    return os << static_cast<VkBuffer>(b);
}

@0cc4m

0cc4m commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

This fell off our radar, sorry. I assume it is still valid? Can you check if it still applies to the master branch?

On 32-bit platforms, Vulkan non-dispatchable handles such as VkBuffer are
represented as uint64_t, and Vulkan-Hpp disables implicit conversions for
type safety. This exposes two issues in ggml-vulkan:

1. vk::Buffer is streamed directly into std::ostream in debug/memory logs.
2. vk::Buffer is cast to VkBuffer before being passed to Vulkan-Hpp
   CommandBuffer::copyBuffer APIs.

Fix these by add the operator<< for vk::Buffer, and
by passing vk::Buffer directly to Vulkan-Hpp copyBuffer calls.
@miyanyan

miyanyan commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

This fell off our radar, sorry. I assume it is still valid? Can you check if it still applies to the master branch?

I rebased onto master, and the patch still applies. Without this patch, still get errors on 32 bit:

error: invalid operands to binary expression ('ostream' ... and 'vk::Buffer')
error: no matching member function for call to 'copyBuffer'

@0cc4m 0cc4m left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, sorry for the delay

@0cc4m
0cc4m merged commit f014bfe into ggml-org:master Sep 8, 2026
23 of 29 checks passed
x1250 pushed a commit to x1250/llama.cpp that referenced this pull request Sep 9, 2026
On 32-bit platforms, Vulkan non-dispatchable handles such as VkBuffer are
represented as uint64_t, and Vulkan-Hpp disables implicit conversions for
type safety. This exposes two issues in ggml-vulkan:

1. vk::Buffer is streamed directly into std::ostream in debug/memory logs.
2. vk::Buffer is cast to VkBuffer before being passed to Vulkan-Hpp
   CommandBuffer::copyBuffer APIs.

Fix these by add the operator<< for vk::Buffer, and
by passing vk::Buffer directly to Vulkan-Hpp copyBuffer calls.
zbrad pushed a commit to zbrad/llama.cpp that referenced this pull request Sep 10, 2026
On 32-bit platforms, Vulkan non-dispatchable handles such as VkBuffer are
represented as uint64_t, and Vulkan-Hpp disables implicit conversions for
type safety. This exposes two issues in ggml-vulkan:

1. vk::Buffer is streamed directly into std::ostream in debug/memory logs.
2. vk::Buffer is cast to VkBuffer before being passed to Vulkan-Hpp
   CommandBuffer::copyBuffer APIs.

Fix these by add the operator<< for vk::Buffer, and
by passing vk::Buffer directly to Vulkan-Hpp copyBuffer calls.
@BrewTestBot BrewTestBot mentioned this pull request Sep 14, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning Vulkan Issues specific to the Vulkan backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants