Skip to content

cuda: add TP flag-fold and kv-norm task fallbacks - #12

Merged
GiorgioOppo merged 1 commit into
GiorgioOppo:aprojq4-dense-attentionfrom
adamlawi:cuda-tp-kvnorm-stubs
Sep 4, 2026
Merged

GiorgioOppo merged 1 commit into
GiorgioOppo:aprojq4-dense-attentionfrom
adamlawi:cuda-tp-kvnorm-stubs

Conversation

@adamlawi

@adamlawi adamlawi commented Sep 4, 2026

Copy link
Copy Markdown

ds4.c:27325 calls ds4_gpu_add_tensor_tp_flag() under #ifndef DS4_NO_GPU, so every GPU backend has to provide it. Metal implements it; ROCm got fallbacks in 9f005f4c ("rocm: fix build break from Metal-only TP/kv-norm symbols"), merged here in 79907e02. CUDA had neither, so linking fails on CUDA for all five binaries:

ds4.o: in function `metal_graph_encode_decode_layer_phase':
ds4.c:27325: undefined reference to `ds4_gpu_add_tensor_tp_flag'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:539: ds4] Error 1
make[1]: *** [Makefile:542: ds4-server] Error 1
make[1]: *** [Makefile:545: ds4-bench] Error 1
make[1]: *** [Makefile:548: ds4-eval] Error 1
make[1]: *** [Makefile:551: ds4-agent] Error 1

This mirrors the ROCm block verbatim, including its rationale: the TP flag-fold and deferred kv-norm paths are Metal-only optimizations, so the plain fallback is the correct behaviour elsewhere — add without the checked flag, kv norm always standalone.

No functional change on any path that computes. Six of the seven functions are empty or return 0; the only non-empty one delegates to the existing ds4_gpu_add_tensor().

Verified on GB10 / sm_121 (DGX Spark), CUDA 13: make cuda-spark and make quality-score both exit 0 with no unresolved symbols, on exactly the content of this PR.

Context: this is what currently blocks anyone from building antirez#952 on CUDA, which is why it did not show up earlier — Metal and ROCm both link fine.

ds4.c:27325 calls ds4_gpu_add_tensor_tp_flag() under #ifndef DS4_NO_GPU,
so every GPU backend has to provide it. Metal implements it; ROCm got
fallbacks in 9f005f4 ("rocm: fix build break from Metal-only TP/kv-norm
symbols"), merged here in 79907e0. CUDA had neither, so linking ds4,
ds4-server, ds4-bench, ds4-eval and ds4-agent fails on CUDA:

  ds4.o: in function `metal_graph_encode_decode_layer_phase':
  ds4.c:27325: undefined reference to `ds4_gpu_add_tensor_tp_flag'
  collect2: error: ld returned 1 exit status

This mirrors the ROCm block verbatim: the TP flag-fold and deferred
kv-norm paths are Metal-only optimizations, so the plain fallback is the
correct behaviour elsewhere - add without the checked flag, kv norm
always standalone.

No functional change on any path that computes: the only non-empty
function delegates to the existing ds4_gpu_add_tensor().

Verified on GB10 / sm_121 (DGX Spark), CUDA 13, make cuda-spark and
make quality-score both exit 0 with no unresolved symbols.
@GiorgioOppo
GiorgioOppo merged commit 8c22d66 into GiorgioOppo:aprojq4-dense-attention Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants