Skip to content

Commit c4c1031

Browse files
metax666duqimeng
andauthored
[Metax] Fix Bug (#2472)
* Remove debug print statements in flash_attn_grad_kernel Commented out debug print statements to clean up output. * [Metax] Fix Bug (#224) * [Metax] Fix eigen cmake bug * [Metax] Fix allow_tf32_cublas * fix patch * [Metax] Fix error rnn * [Metax] Fix error rnn * [Metax] update paddle * [Metax] Fix Bug * [Metax] Fix Bug --------- Co-authored-by: duqimeng <77875733+duqimeng@users.noreply.github.com>
1 parent 9f97994 commit c4c1031

7 files changed

Lines changed: 544 additions & 262 deletions

File tree

backends/metax_gpu/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ file(
290290
${PADDLE_SOURCE_DIR}/paddle/phi/kernels/unsqueeze_kernel.cc
291291
${PADDLE_SOURCE_DIR}/paddle/phi/kernels/squeeze_grad_kernel.cc
292292
${PADDLE_SOURCE_DIR}/paddle/phi/kernels/squeeze_kernel.cc
293-
${PADDLE_SOURCE_DIR}/paddle/phi/kernels/gpu/sign_kernel.cu.cc
293+
${PADDLE_SOURCE_DIR}/paddle/phi/kernels/gpu/sign_kernel.cu
294294
${PADDLE_SOURCE_DIR}/paddle/phi/kernels/gpu/split_kernel.cu
295295
${PADDLE_SOURCE_DIR}/paddle/phi/kernels/gpu/scatter_nd_add_kernel.cu
296296
${PADDLE_SOURCE_DIR}/paddle/phi/kernels/gpu/scatter_nd_add_grad_kernel.cu

backends/metax_gpu/kernels/cuda_kernels/sign_kernel_register.cu

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ PD_CUSTOM_KERNEL_REGISTER(sign,
2727
int64_t,
2828
float,
2929
double,
30-
phi::dtype::float16,
31-
phi::dtype::bfloat16,
32-
phi::dtype::complex<float>,
33-
phi::dtype::complex<double>) {}
30+
phi::float16,
31+
phi::bfloat16,
32+
phi::complex64,
33+
phi::complex128) {}

backends/metax_gpu/kernels/custom_kernel/flash_attn_grad_kernel.cu

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void FlashAttnUnpaddedGradKernel_(
4848
DenseTensor* dk,
4949
DenseTensor* dv) {
5050
#ifdef PADDLE_WITH_FLASHATTN
51-
printf("************ FlashAttnUnpaddedGradKernel_ ****************\n");
51+
// printf("************ FlashAttnUnpaddedGradKernel_ ****************\n");
5252
ctx.template Alloc<T>(dq);
5353

5454
DenseTensor dk_tmp;
@@ -214,7 +214,7 @@ void FlashAttnGradKernel(const Context& ctx,
214214
ctx.template Alloc<T>(dq);
215215
DenseTensor dk_tmp;
216216
if (dk) {
217-
printf("dk input pointer is not nullptr!\n");
217+
// printf("dk input pointer is not nullptr!\n");
218218
if (!is_mha) {
219219
dk_tmp.Resize({batch_size, seqlen_k, num_heads, head_size_og});
220220
ctx.template Alloc<T>(&dk_tmp);
@@ -224,7 +224,7 @@ void FlashAttnGradKernel(const Context& ctx,
224224
}
225225

226226
} else {
227-
printf("dk input pointer is nullptr!\n");
227+
// printf("dk input pointer is nullptr!\n");
228228
dk_tmp = EmptyLike<T, Context>(ctx, k);
229229
}
230230

@@ -242,9 +242,9 @@ void FlashAttnGradKernel(const Context& ctx,
242242
}
243243

244244
if (dk_tmp.meta().is_contiguous()) {
245-
printf("dk_tmp alloc memory is contiguous!\n");
245+
// printf("dk_tmp alloc memory is contiguous!\n");
246246
} else {
247-
printf("dk_tmp alloc memory is not contiguous!\n");
247+
// printf("dk_tmp alloc memory is not contiguous!\n");
248248
}
249249

250250
FlashAttnParamsBwd params = FlashAttnParamsBwd(ctx,
@@ -278,7 +278,7 @@ void FlashAttnGradKernel(const Context& ctx,
278278
VLOG(10) << "[FlashAttn Backward] attn_mask.shape=["
279279
<< (attn_mask.get_ptr())->dims() << "]";
280280
}
281-
// printf("params.dq dims[2]:%d, params.dk dims[2]:%d, params.dv
281+
// // printf("params.dq dims[2]:%d, params.dk dims[2]:%d, params.dv
282282
// dims[2]:%d\n", params.dq->head_num, params.dk->head_num,
283283
// params.dv->head_num);
284284
print_tensor_info(params.dq);
@@ -326,7 +326,7 @@ void FlashAttnGradKernel(const Context& ctx,
326326
phi::SumKernel<T, Context>(ctx, dk_tmp, {3}, dk->type(), false, dk);
327327
} else {
328328
// kvReduceBatchedForGQA<T, Context>(ctx, dk_tmp, dk);
329-
printf("[%s: %d] - Need to complete!\n", __func__, __LINE__);
329+
// printf("[%s: %d] - Need to complete!\n", __func__, __LINE__);
330330
}
331331
}
332332

@@ -340,7 +340,7 @@ void FlashAttnGradKernel(const Context& ctx,
340340
phi::SumKernel<T, Context>(ctx, dv_tmp, {3}, dv->type(), false, dv);
341341
} else {
342342
// kvReduceBatchedForGQA<T, Context>(ctx, dv_tmp, dv);
343-
printf("[%s: %d] - Need to complete!\n", __func__, __LINE__);
343+
// printf("[%s: %d] - Need to complete!\n", __func__, __LINE__);
344344
}
345345
}
346346
}

0 commit comments

Comments
 (0)