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

Support opt save load #59843

Merged
merged 19 commits into from
Dec 9, 2023
Merged

Conversation

pangengzheng
Copy link
Contributor

@pangengzheng pangengzheng commented Dec 8, 2023

PR types

Others

PR changes

Others

Description

card-78318
support semi-auto optimizer save load

Copy link

paddle-bot bot commented Dec 8, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

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

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

Choose a reason for hiding this comment

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

<0 is impossible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

嗯是不会有,但是也不影响正确性,习惯性这样写了。可修改

Comment on lines +511 to +519
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
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

暂时没有想到更好的做法,这里就先考虑这样,后面再思考是否有更好做法

Copy link
Contributor

@zhiqiu zhiqiu left a 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

@zhiqiu zhiqiu merged commit 8932f1c into PaddlePaddle:develop Dec 9, 2023
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.

2 participants