From eb1f0f48e745d3008d31f191d40e2c3f10f641fd Mon Sep 17 00:00:00 2001 From: pepuscz Date: Tue, 18 Aug 2026 22:39:37 +0200 Subject: [PATCH] fix(hip): restrict wavefront guard to device pass --- server/src/flashprefill_kernels.hip.cu | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/src/flashprefill_kernels.hip.cu b/server/src/flashprefill_kernels.hip.cu index eb3ce1cd2..d5e3d9891 100644 --- a/server/src/flashprefill_kernels.hip.cu +++ b/server/src/flashprefill_kernels.hip.cu @@ -29,12 +29,15 @@ // which is a 32-lane instruction. A wave64 target would need a different WMMA // instruction and fragment layout, not a warp-width tweak, so we fail the build // loudly rather than emit silently-wrong results. All currently declared AMD -// targets (gfx1100 / gfx1151, RDNA3) are wave32. __AMDGCN_WAVEFRONT_SIZE(__) is -// defined only in the device compile pass. -#if defined(__AMDGCN_WAVEFRONT_SIZE__) && (__AMDGCN_WAVEFRONT_SIZE__ != 32) +// targets (gfx1100 / gfx1151, RDNA3) are wave32. Check the compiler-provided +// wavefront macros only in the device pass: some ROCm versions expose a +// host-side definition that is not an integer constant expression. +#if defined(__HIP_DEVICE_COMPILE__) && __HIP_DEVICE_COMPILE__ +# if defined(__AMDGCN_WAVEFRONT_SIZE__) && (__AMDGCN_WAVEFRONT_SIZE__ != 32) # error "flashprefill_kernels.hip.cu requires a 32-lane wavefront (RDNA v_wmma_f32_16x16x16 fragment layout). Build for a wave32 target (gfx10/gfx11) or provide a wave64 WMMA rewrite." -#elif !defined(__AMDGCN_WAVEFRONT_SIZE__) && defined(__AMDGCN_WAVEFRONT_SIZE) && (__AMDGCN_WAVEFRONT_SIZE != 32) +# elif !defined(__AMDGCN_WAVEFRONT_SIZE__) && defined(__AMDGCN_WAVEFRONT_SIZE) && (__AMDGCN_WAVEFRONT_SIZE != 32) # error "flashprefill_kernels.hip.cu requires a 32-lane wavefront (RDNA v_wmma_f32_16x16x16 fragment layout). Build for a wave32 target (gfx10/gfx11) or provide a wave64 WMMA rewrite." +# endif #endif namespace dflash::common {