Skip to content

[RL] Refoctor code and add comments #10565

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

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

Conversation

DrownFish19
Copy link
Collaborator

Before submitting

  • Lint code. If there are lint issues, please format the code first.
# Install and register `pre-commit` in the project folder
pip install pre-commit && pre-commit install

# Process previous code files separately
pre-commit run --file XXXX.py
  • Add test cases into tests folder. If there are codecov issues, please add tests cases first.

PR types

Others

PR changes

Docs

Description

Refoctor code (with minimal changes) and add comments.

Copy link

paddle-bot bot commented May 7, 2025

Thanks for your contribution!

@@ -140,6 +191,24 @@ def mp_reshard(


def init_reshard_mappings(model, training_args, pp_rank, pp_group):
"""
初始化重新分片映射,并返回全局的元数据字典。如果模型是在多个水平并行度下训练,则会设置管道名称映射。
Copy link
Contributor

Choose a reason for hiding this comment

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

是不是统一用英文比较好?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Copy link

codecov bot commented May 7, 2025

Codecov Report

Attention: Patch coverage is 0% with 77 lines in your changes missing coverage. Please review.

Project coverage is 46.97%. Comparing base (8205e3d) to head (d191da1).

Files with missing lines Patch % Lines
paddlenlp/rl/trainer/ppo_trainer.py 0.00% 33 Missing ⚠️
paddlenlp/rl/trainer/trainer_utils.py 0.00% 16 Missing ⚠️
paddlenlp/rl/utils/comm_utils.py 0.00% 12 Missing ⚠️
paddlenlp/rl/models/ppo_model_utils.py 0.00% 5 Missing ⚠️
paddlenlp/rl/trainer/rl_trainer.py 0.00% 3 Missing ⚠️
paddlenlp/rl/trainer/critic_trainer.py 0.00% 2 Missing ⚠️
paddlenlp/rl/utils/timer_utils.py 0.00% 2 Missing ⚠️
paddlenlp/rl/models/score_model_utils.py 0.00% 1 Missing ⚠️
paddlenlp/rl/utils/config_utils.py 0.00% 1 Missing ⚠️
paddlenlp/rl/utils/offload_utils.py 0.00% 1 Missing ⚠️
... and 1 more

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.
❌ Your project check has failed because the head coverage (46.97%) is below the target coverage (58.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #10565      +/-   ##
===========================================
- Coverage    46.98%   46.97%   -0.02%     
===========================================
  Files          799      799              
  Lines       132246   132282      +36     
===========================================
- Hits         62135    62133       -2     
- Misses       70111    70149      +38     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +95 to +113
if not isinstance(arg_name_values, list) and not isinstance(args, list):
arg_name_values = [arg_name_values]
args = [args]
elif isinstance(arg_name_values, list) and isinstance(args, list):
pass
else:
raise ValueError("args and arg_name_values should be both list or both not list")

for i in range(len(args)):
for k, v in arg_name_values[i].items():
old_value = getattr(args[i], k, None)
setattr(args[i], k, v)
arg_name_values[i][k] = old_value
yield
for k, v in arg_name_values.items():
old_value = getattr(args, k)
setattr(args, k, v)
arg_name_values[k] = old_value
for i in range(len(args)):
for k, v in arg_name_values[i].items():
old_value = getattr(args[i], k)
setattr(args[i], k, v)
arg_name_values[i][k] = old_value
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

支持list传入

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