Skip to content

Commit 9b3cd45

Browse files
kudomchoclaude
andcommitted
Fix WARP_SIZE detection for gfx942 in kernels.hip and ops.hip
Replace broken __GFX9__ guard with __AMDGCN_WAVEFRONT_SIZE (compiler-provided) and default to 64 for CDNA. The __GFX9__ macro is not defined at compile time on recent ROCm, causing WARP_SIZE=32 on 64-wide wavefront gfx942 (MI300X). This broke the 4-bit GEMV inference kernel grid launch and warp reduction, producing ~50% element mismatches in test_gemv_eye_4bit. Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
1 parent 7c0057d commit 9b3cd45

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

csrc/kernels.hip

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,10 +2853,10 @@ template <int THREADS, int ITEMS_PER_THREAD, int TILE_ROWS, int TILE_COLS, int T
28532853
#define DENORM 1.0f/127.0f
28542854
#define MAX_SPARSE_COUNT 32
28552855
#define SMEM_SIZE 8*256
2856-
#if defined(__GFX9__)
2857-
#define WARP_SIZE 64
2856+
#ifdef __AMDGCN_WAVEFRONT_SIZE
2857+
#define WARP_SIZE __AMDGCN_WAVEFRONT_SIZE
28582858
#else
2859-
#define WARP_SIZE 32
2859+
#define WARP_SIZE 64
28602860
#endif
28612861
template <typename T, int SPMM_ITEMS, int BITS>
28622862
__global__ void kspmm_coo_very_sparse_naive(int *max_count, int *max_idx, int *offset_rowidx, int *rowidx, int *colidx, half *values, T *B, half *out, float * __restrict__ const dequant_stats, int nnz, int rowsA, int rowsB, int colsB)

csrc/ops.hip

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
#define ERR_NOT_IMPLEMENTED 100
2222

23-
#if defined(__GFX9__)
24-
#define WARP_SIZE 64
23+
#ifdef __AMDGCN_WAVEFRONT_SIZE
24+
#define WARP_SIZE __AMDGCN_WAVEFRONT_SIZE
2525
#else
26-
#define WARP_SIZE 32
26+
#define WARP_SIZE 64
2727
#endif
2828

2929
using namespace BinSearch;

0 commit comments

Comments
 (0)