-
Notifications
You must be signed in to change notification settings - Fork 3k
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
update mergekit #9811
base: develop
Are you sure you want to change the base?
update mergekit #9811
Conversation
paddlenlp/mergekit/merge_method.py
Outdated
weights = paddle.to_tensor(weight_list, dtype=stacked_tensors.dtype) | ||
weights = weights.reshape([-1] + [1] * (len(stacked_tensors.shape) - 1)) | ||
weighted_sum = paddle.sum(stacked_tensors * weights, axis=0) | ||
weighted_sum = paddle.zeros_like(tensor_list[0]) |
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.
测试发现for循环实现比stack后快,所以更换为stack方式
tensor *= mask | ||
if self.merge_config.rescale: | ||
tensor /= self.merge_config.reserve_p | ||
mode = "upscale_in_train" if self.merge_config.rescale else "downscale_in_infer" |
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.
改为dropout更高效的方式
return tensor | ||
else: | ||
raise ValueError(f"Unkonwn tensor type {self.merge_config.tensor_type}") | ||
|
||
def magprune(self, tensor): | ||
if self.merge_config.tensor_type == "np": | ||
if np.all(tensor == 0): | ||
if not np.any(tensor != 0): |
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.
测试发现,any的方式比all更高效
Codecov ReportAttention: Patch coverage is
❌ Your patch check has failed because the patch coverage (66.98%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #9811 +/- ##
===========================================
+ Coverage 51.27% 52.24% +0.96%
===========================================
Files 735 730 -5
Lines 121550 115724 -5826
===========================================
- Hits 62329 60458 -1871
+ Misses 59221 55266 -3955 ☔ View full report in Codecov by Sentry. |
PR types
New features
PR changes
APIs
Description
优化mergekit