Skip to content
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

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open

update mergekit #9811

wants to merge 4 commits into from

Conversation

lugimzzz
Copy link
Contributor

PR types

New features

PR changes

APIs

Description

优化mergekit

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])
Copy link
Contributor Author

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"
Copy link
Contributor Author

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):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

测试发现,any的方式比all更高效

Copy link

codecov bot commented Jan 23, 2025

Codecov Report

Attention: Patch coverage is 66.98113% with 35 lines in your changes missing coverage. Please review.

Project coverage is 52.24%. Comparing base (ac095f5) to head (a2ac30d).
Report is 6 commits behind head on develop.

Current head a2ac30d differs from pull request most recent head b088411

Please upload reports for the commit b088411 to get more accurate results.

Files with missing lines Patch % Lines
paddlenlp/mergekit/merge_model.py 59.21% 31 Missing ⚠️
paddlenlp/mergekit/merge_method.py 80.95% 4 Missing ⚠️

❌ 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.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant