Skip to content

Commit a7552cf

Browse files
mudlerlocalai-org-maint-bot
authored andcommitted
fix(buun-llama-cpp): pass WARP_SIZE to argmax __shfl_xor_sync calls
Two call sites in ggml/src/ggml-cuda/argmax.cu (the top-K intra-warp merge added by buun) use the 3-arg CUDA form __shfl_xor_sync(mask, var, laneMask), omitting the optional width parameter. The hipification shim at ggml/src/ggml-cuda/vendors/hip.h:33 is a function-like macro that requires all four arguments, so hipcc fails with: argmax.cu:265: too few arguments provided to function-like macro invocation note: macro '__shfl_xor_sync' defined here: #define __shfl_xor_sync(mask, var, laneMask, width) \ __shfl_xor(var, laneMask, width) Every other call in the same file already passes WARP_SIZE explicitly; aligning these two with that convention fixes the hipblas build without changing CUDA codegen (warpSize is the CUDA default). Assisted-by: Claude:claude-opus-4-7 Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent 0a04074 commit a7552cf

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Subject: [PATCH] ggml-cuda/argmax: pass WARP_SIZE to the top-K __shfl_xor_sync calls
2+
3+
Two __shfl_xor_sync calls in the top-K intra-warp merge drop the `width`
4+
argument and rely on the CUDA default (warpSize). Every other call in
5+
the same file already passes WARP_SIZE explicitly, and the HIP/ROCm
6+
compatibility shim at ggml/src/ggml-cuda/vendors/hip.h:33 is a 4-arg
7+
function-like macro — so the 3-arg form fails to preprocess when
8+
building with hipcc against ROCm:
9+
10+
argmax.cu:265: error: too few arguments provided to function-like
11+
macro invocation
12+
note: macro '__shfl_xor_sync' defined here:
13+
#define __shfl_xor_sync(mask, var, laneMask, width) \
14+
__shfl_xor(var, laneMask, width)
15+
16+
Align the two call sites with the rest of the file by passing WARP_SIZE
17+
explicitly. On CUDA the generated code is unchanged (warpSize is the
18+
default); on HIP it now matches the macro's arity.
19+
20+
--- a/ggml/src/ggml-cuda/argmax.cu
21+
+++ b/ggml/src/ggml-cuda/argmax.cu
22+
@@ -262,8 +262,8 @@
23+
// Each step: lane gets partner's min element, if it beats our min, replace and re-heapify
24+
for (int offset = WARP_SIZE / 2; offset > 0; offset >>= 1) {
25+
for (int i = 0; i < K; i++) {
26+
- float partner_val = __shfl_xor_sync(0xFFFFFFFF, heap_val[i], offset);
27+
- int partner_idx = __shfl_xor_sync(0xFFFFFFFF, heap_idx[i], offset);
28+
+ float partner_val = __shfl_xor_sync(0xFFFFFFFF, heap_val[i], offset, WARP_SIZE);
29+
+ int partner_idx = __shfl_xor_sync(0xFFFFFFFF, heap_idx[i], offset, WARP_SIZE);
30+
if (partner_val > heap_val[0]) {
31+
heap_val[0] = partner_val;
32+
heap_idx[0] = partner_idx;

0 commit comments

Comments
 (0)