prefill: the VGPR-capped gfx11 fused expert kernels are on again for gfx1151 on clang 23, except IQ2_XS and Q8_0 (#1180)
Since 0.1.40.2 the waves_per_eu(8) variant of native_w11_kernel is uncapped on clang 22 and newer, because clang 22 computes wrong results with it on gfx1100. On gfx1151 with clang 23 (ROCm 7.14.1) the capped kernels give the same bits and take less time, as alexdns1 measured in #1180. The cap now applies there again, per format (hip_prefill_fused_iq, one layer, 2048 / 3584 / 8192 tokens, the same output bits hash in every case): - gate/up IQ2_XXS / IQ3_XXS / IQ3_S / IQ4_XS and down Q2_0 / IQ4_NL: capped, 8-15% less time per layer. IQ2_S gate/up is capped too, but its LDS leaves room for 3 blocks per WGP and the compiler keeps its 238 VGPRs; IQ2_S / Q2_0 takes 2-4% less time from the Q2_0 down. - IQ2_XS gate/up: not capped. Under the cap it spills 104 VGPRs and takes 61-66% more time. - Q8_0 down: not capped. It spills 18 VGPRs and took -1.9% to +1.9% time (with Q4_K gate/up). The test is the clang major version: other clang 23 builds are not measured, and clang 24 and newer keep the clang 22 rule. The template argument is the same in the host and every device pass; only the device pass for gfx1151 decides the attribute (nw_capped). Other architectures, other compilers and -DSTRATA_W_LB=N behave as before: the gfx1100 disassembly is identical to before (kernel names aside). The file builds for gfx1012 / 1030 / 1100 / 1150 / 1151 / 1200 / 1201 and with STRATA_HIP_GFX906 (gfx906); no CUDA build here, and the changed lines are inside `#if defined(__HIPCC__)`. SYCL has its own copy of this file, not touched. The path is opt-in (STRATA_PF_FUSED=1), so default output is unchanged. End to end on a Ryzen AI Max+ 395 (128 GB, gfx1151), UD-IQ4_XS, the section-5 switches of docs/STRIX_HALO.md with --prefill 16384, 3 interleaved rounds of fresh servers: a 128K prompt read 1,126.1 -> 1,153.4 tok/s (+2.4%; +1.8%, +2.4%, +2.6% per round). At 4K (868.0 -> 894.9, +3.1%) and 32K (1,182.9 -> 1,207.0, +2.0%) the medians moved too, but within the spread of 3 runs. Decode unchanged; the same text for all 9 prompts.
This commit is contained in:
1 parent
acc94b2171
commit
edf61f18e9
1 file changed
+27
-6
@@ -678,15 +678,33 @@ native_kernel(const Batch b, const NativeGeom geo, const Tables tb, const uint8_
|
||||
#else
|
||||
#define NW_DROW(i, hi) (2 * (i) + (hi))
|
||||
#endif
|
||||
// The VGPR cap of the occupancy variant (amdgpu_waves_per_eu). 8 was measured against ROCm 7's clang; clang 22 (ROCm 7.10)
|
||||
// computes wrong results with it (#1180: gfx1100, every run), so there the cap is off. -DSTRATA_W_LB=N sets it.
|
||||
// The VGPR cap of the occupancy variant (amdgpu_waves_per_eu). 8 was measured against a clang before 22; clang 22
|
||||
// (ROCm 7.10) computes wrong results with it (#1180: gfx1100, every run), so from clang 22 the cap is off - except for
|
||||
// gfx1151 on clang 23, where the capped kernels give the same bits and take less time (measured with ROCm 7.14.1's
|
||||
// clang 23, hip_prefill_fused_iq, one layer, 2048-8192 tokens: gate/up IQ2_XXS / IQ3_XXS / IQ3_S / IQ4_XS with down
|
||||
// Q2_0 / IQ4_NL 8-15%; IQ2_S / Q2_0 2-4%, from its Q2_0 down: IQ2_S's LDS leaves room for 3 blocks per WGP, so the
|
||||
// compiler keeps its 238 VGPRs). Two formats stay uncapped there: IQ2_XS gate/up spills 104 VGPRs under the cap and
|
||||
// takes 61-66% more time, and Q8_0 down (18 spilled) took -1.9% to +1.9% time. The test is the clang major version:
|
||||
// other clang 23 builds are not measured, and clang 24 and newer keep the clang 22 rule. NW_LB is the variant's
|
||||
// template argument, the same in the host and every device pass (the launch names that instance); whether its cap
|
||||
// applies is decided per architecture and format in the device pass (nw_capped). -DSTRATA_W_LB=N sets the cap on
|
||||
// every architecture and format.
|
||||
#if defined(STRATA_W_LB)
|
||||
constexpr int NW_LB = STRATA_W_LB;
|
||||
#elif defined(__clang_major__) && __clang_major__ >= 22
|
||||
constexpr int NW_LB = 1;
|
||||
#else
|
||||
constexpr int NW_LB = 8;
|
||||
#endif
|
||||
constexpr bool nw_capped(int wt) {
|
||||
#if defined(STRATA_W_LB) || !defined(__clang_major__) || __clang_major__ < 22
|
||||
(void) wt;
|
||||
return true;
|
||||
#elif defined(__gfx1151__) && __clang_major__ == 23
|
||||
return wt != T_IQ2_XS && wt != T_Q8_0;
|
||||
#else
|
||||
(void) wt;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
typedef int nw_i4 __attribute__((ext_vector_type(4)));
|
||||
typedef int nw_i2 __attribute__((ext_vector_type(2)));
|
||||
typedef int nw_i8 __attribute__((ext_vector_type(8)));
|
||||
@@ -714,10 +732,11 @@ __device__ __forceinline__ nw_i8 nw_wmma(nw_ab a, nw_ab b, nw_i8 c) {
|
||||
#endif
|
||||
}
|
||||
|
||||
// W (X1): ALIAS = the H tile lives on the weight buffers (one extra barrier); LB > 0 = amdgpu_waves_per_eu(LB) (VGPR cap).
|
||||
// W (X1): ALIAS = the H tile lives on the weight buffers (one extra barrier); LB > 0 = amdgpu_waves_per_eu(LB) (VGPR cap)
|
||||
// where nw_capped(WT) says the cap applies.
|
||||
// Disable both with -DSTRATA_W_NO_OCC (the launch sites then use <WT, GU, false, 0> and grid factor wgp_blocks).
|
||||
template <int WT, bool GU, bool ALIAS = false, int LB = 0>
|
||||
__global__ void __launch_bounds__(NW_THREADS) __attribute__((amdgpu_waves_per_eu(LB > 0 ? LB : 1)))
|
||||
__global__ void __launch_bounds__(NW_THREADS) __attribute__((amdgpu_waves_per_eu(LB > 0 && nw_capped(WT) ? LB : 1)))
|
||||
native_w11_kernel(const Batch b, const NativeGeom geo, const Tables tb, const uint8_t* __restrict__ act,
|
||||
const int32_t* __restrict__ src, uint8_t* __restrict__ out, float* __restrict__ dm) {
|
||||
#if STRATA_NAT_WMMA
|
||||
@@ -1161,6 +1180,8 @@ void experts_native(const Batch& b, const NativeGeom& g, int n_expert, int64_t n
|
||||
// W (X1): LDS alias of the H tile + waves_per_eu(8) (192 VGPRs) + 4 blocks per WGP, only for the types whose
|
||||
// kernels do not spill under the cap (measured: gate/up IQ2_*, IQ3_*, IQ4_XS 0-5 regs; down IQ4_NL 11, Q8_0 / Q2_0 0;
|
||||
// Q4_K / Q5_K gate/up and Q5_1 down spill 100+ and keep the old launch).
|
||||
// Those counts are from a clang before 22; from clang 22 nw_capped decides which of these kernels get the cap
|
||||
// (above NW_LB), and the launch is the same.
|
||||
#ifdef STRATA_W_NO_OCC
|
||||
const bool occ_gu = false, occ_d = false;
|
||||
#else
|
||||
|
||||
Reference in new issue
Block a user