You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Vulkan][SPIR-V] i8 loads emulated as i32 read past the binding range when the buffer length is not a multiple of 4 #25272
On Vulkan targets without 8-bit storage (e.g. the default vulkan-spirv target, vp_android_baseline_2022, storage = b32), an i8 linalg.batch_matmul returns wrong results when an operand's byte length is not a multiple of 4.
Seen on lavapipe (llvmpipe, Mesa 25.2.8, LLVM 20.1.2) with release 3.14.0rc2026111.
Cause
i8 is emulated by loading the containing i32 word and shifting. The index arithmetic in the generated SPIR-V is correct.
%b is 6 bytes, and the dispatch binds it with range [0, 6]. Batch 1 reads bytes 4 and 5 through a 4-byte load of word 1 (bytes 4–7), 2 bytes past the bound range.
The runtime sets VkDescriptorBufferInfo.range to the exact binding length
(runtime/src/iree/hal/drivers/vulkan/command_buffer.c). It creates theVkBuffer at the exact allocation size (allocator.c), so the range cannot simply be rounded up.
robustBufferAccess is off by default, so the read is undefined behaviour. lavapipe returns 0 for the whole word, which drops the k=1 and k=2 terms of batch 1 (1·7 = 7, 4·7 = 28). Drivers that return the neighbouring bytes would hide the bug.
Supporting checks:
The same matmul with N=4, where every buffer length is a multiple of 4 bytes, gives the correct result.
With --iree-vulkan-target=valhall, which has 8-bit storage, the result is correct.
Activity