-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Support opt save load #59843
Support opt save load #59843
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
@@ -399,6 +405,8 @@ def load_state_dict( | |||
paddle.distributed.init_parallel_env() | |||
|
|||
rank_to_files = get_rank_to_files(path, state_dict, process_group, use_dist) | |||
if len(rank_to_files) <= 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.
<0 is impossible?
@@ -55,6 +55,12 @@ def get_rank_to_files(path, state_dict, process_group, use_dist): | |||
if local_tensor_index.tensor_key in state_dict: | |||
necessary_files.append(file_name) | |||
necessary_data_files_set = set(necessary_files) | |||
if len(necessary_data_files_set) <= 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.
<0 is impossible?
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 param in param_list: | ||
if param.stop_gradient: | ||
continue | ||
if hasattr(param, "main_grad"): | ||
if param.main_grad is not None: | ||
return state_dict | ||
else: | ||
if param.grad is not None: | ||
return state_dict |
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.
I think it is a little bit trick
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.
暂时没有想到更好的做法,这里就先考虑这样,后面再思考是否有更好做法
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, to be refined in next pr
PR types
Others
PR changes
Others
Description
card-78318
support semi-auto optimizer save load