Skip to content

Commit

Permalink
partially revert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesGaessler committed May 7, 2024
1 parent 57bde8c commit 78ee06e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ggml-cuda/common.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ static __device__ __forceinline__ half2 ggml_cuda_hmax2(const half2 a, const hal
GGML_UNUSED(a);
GGML_UNUSED(b);
NO_DEVICE_CODE;
#endif // !(defined(GGML_USE_HIPBLAS) && defined(__HIP_PLATFORM_AMD__)) && CUDART_VERSION < CUDART_HMAX
#endif // !(defined(GGML_USE_HIPBLAS) && defined(__HIP_PLATFORM_AMD__))
}

static __device__ __forceinline__ half2 warp_reduce_max(half2 x) {
Expand Down
8 changes: 6 additions & 2 deletions ggml-cuda/fattn.cu
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ static __global__ void flash_attn_vec_ext_f16(
static_assert(D % (2*WARP_SIZE) == 0, "D not divisible by 2*WARP_SIZE == 64.");
constexpr int nwarps = D / WARP_SIZE;
const int tid = WARP_SIZE*threadIdx.y + threadIdx.x;
__builtin_assume(tid < D);

__shared__ half KQ[ncols*D];
#pragma unroll
Expand Down Expand Up @@ -106,7 +107,10 @@ static __global__ void flash_attn_vec_ext_f16(
for (int k_VKQ_0 = k_start; k_VKQ_0 < ne11; k_VKQ_0 += parallel_blocks*D) {
// Calculate KQ tile and keep track of new maximum KQ values:
half kqmax_new[ncols];
memcpy(kqmax_new, kqmax, sizeof(kqmax));
#pragma unroll
for (int j = 0; j < ncols; ++j) {
kqmax_new[j] = kqmax[j];
}

#pragma unroll
for (int i_KQ_0 = 0; i_KQ_0 < D; i_KQ_0 += nwarps) {
Expand All @@ -123,7 +127,7 @@ static __global__ void flash_attn_vec_ext_f16(

const half2 K_ik = K_h2[(k_VKQ_0 + i_KQ)*stride_KV2 + k_KQ];
#pragma unroll
for (int j = 0; j < ncols; ++j) {
for (int j = 0; j < ncols; ++j) {
sum2[j] += K_ik * Q_h2[j][k_KQ_0/WARP_SIZE];
}
}
Expand Down

0 comments on commit 78ee06e

Please sign in to comment.