CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Phi module Support hdimQK != hdimV backward #73082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
ConcatKernel<T, Context>(ctx, {&out_grad, &padding}, {3}, &out_grad_padded); | ||
v_padded = v; | ||
out_padded = out; | ||
out_grad_padded = out_grad; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refine and remove the padding branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -674,7 +680,7 @@ void FlashAttnV3GradKernel(const Context &ctx, | |||
&dv_accum); | |||
|
|||
if (q.dims()[q.dims().size() - 1] > v.dims()[v.dims().size() - 1]) { | |||
*dv = Slice<T, Context>(ctx, dv_padded, {3}, {0}, {d_v}); | |||
*dv = dv_padded; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refine and remove the padding branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
PADDLE_ENFORCE_EQ( | ||
v.dims()[v.dims().size() - 3], | ||
out.dims()[out.dims().size() - 3], | ||
common::errors::InvalidArgument("seqlen_v and seqlen_o must be equal")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep the shape check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
v_padded = v; | ||
out_padded = out; | ||
out_grad_padded = out_grad; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to declare v_padded
, out_padded
, out_grad_padded
. pass v
, out
, out_grad
to base kernel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} else { | ||
*dv = dv_padded; | ||
} | ||
*dv = dv_padded; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to declare to dv_padded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -666,18 +655,12 @@ void FlashAttnV3GradKernel(const Context &ctx, | |||
sm_margin, | |||
dq, | |||
dk, | |||
&dv_padded, | |||
&dv, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&dv
-> dv
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Phi module Support hdimQK != hdimV backward * minor fix * minor fix * minor fix * minor fix * minor fix
* Phi module Support hdimQK != hdimV backward * minor fix * minor fix * minor fix * minor fix * minor fix
* Phi module Support hdimQK != hdimV backward * minor fix * minor fix * minor fix * minor fix * minor fix
* Phi module Support hdimQK != hdimV backward * minor fix * minor fix * minor fix * minor fix * minor fix
* Phi module Support hdimQK != hdimV backward * minor fix * minor fix * minor fix * minor fix * minor fix
PR Category
Performance Optimization
PR Types
Performance
Description
Pcard-70459
将torch flashattn库 pr1604进行迁移,来支持 headdim != headdim_v 的情况。
精度压测
1600组测试中前向逐位对齐
保证反向paddle相较于torch 误差小于torch2次误差
图1
图2
图3
基本如是,见图2,3
性能测试(经典shape)
进行端到端性能测试新版paddle相比于torch基本持平