Skip to content

Commit 52fc674

Browse files
authored
[recipe] chore: use verl.utils.metric to import reduce_metrics (#3927)
### What does this PR do? > Add **concise** overview of what this PR aims to achieve or accomplish. Reference related GitHub issues and PRs that help with the review. Fix FutureWarning: Warning: Function 'verl.trainer.ppo.metric_utils.reduce_metrics' is deprecated. Please use 'verl.utils.metric.reduce_metrics' instead. ### Checklist Before Starting - [X] Search for similar PRs. Paste at least one query link here: ... - [X] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python # Add code snippet or script demonstrating how to use this ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [X] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [X] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [X] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [X] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [X] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).) Signed-off-by: Hollow Man <hollowman@opensuse.org>
1 parent 34a61bd commit 52fc674

File tree

4 files changed

+7
-19
lines changed

4 files changed

+7
-19
lines changed

recipe/dapo/dapo_ray_trainer.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@
2828

2929
from verl import DataProto
3030
from verl.trainer.ppo.core_algos import agg_loss
31-
from verl.trainer.ppo.metric_utils import (
32-
compute_data_metrics,
33-
compute_throughout_metrics,
34-
compute_timing_metrics,
35-
reduce_metrics,
36-
)
31+
from verl.trainer.ppo.metric_utils import compute_data_metrics, compute_throughout_metrics, compute_timing_metrics
3732
from verl.trainer.ppo.ray_trainer import (
3833
AdvantageEstimator,
3934
RayPPOTrainer,
@@ -42,6 +37,7 @@
4237
compute_response_mask,
4338
)
4439
from verl.trainer.ppo.reward import compute_reward
40+
from verl.utils.metric import reduce_metrics
4541
from verl.utils.profiler import marked_timer
4642
from verl.utils.rollout_skip import RolloutSkip
4743

recipe/entropy/entropy_ray_trainer.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@
2626
from tqdm import tqdm
2727

2828
from verl import DataProto
29-
from verl.trainer.ppo.metric_utils import (
30-
compute_data_metrics,
31-
compute_throughout_metrics,
32-
compute_timing_metrics,
33-
reduce_metrics,
34-
)
29+
from verl.trainer.ppo.metric_utils import compute_data_metrics, compute_throughout_metrics, compute_timing_metrics
3530
from verl.trainer.ppo.ray_trainer import (
3631
AdvantageEstimator,
3732
RayPPOTrainer,
@@ -40,6 +35,7 @@
4035
compute_response_mask,
4136
)
4237
from verl.trainer.ppo.reward import compute_reward
38+
from verl.utils.metric import reduce_metrics
4339
from verl.utils.profiler import simple_timer
4440

4541

recipe/spin/spin_trainer.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,10 @@
3636
from verl.protocol import pad_dataproto_to_divisor, unpad_dataproto
3737
from verl.single_controller.ray import RayClassWithInitArgs, RayResourcePool, RayWorkerGroup
3838
from verl.single_controller.ray.base import create_colocated_worker_cls
39-
from verl.trainer.ppo.metric_utils import (
40-
compute_throughout_metrics,
41-
compute_timing_metrics,
42-
process_validation_metrics,
43-
reduce_metrics,
44-
)
39+
from verl.trainer.ppo.metric_utils import compute_throughout_metrics, compute_timing_metrics, process_validation_metrics
4540
from verl.trainer.ppo.utils import Role, WorkerType, need_reference_policy, need_reward_model
4641
from verl.utils.checkpoint.checkpoint_manager import find_latest_ckpt_path
42+
from verl.utils.metric import reduce_metrics
4743
from verl.utils.seqlen_balancing import get_seqlen_balanced_partitions, log_seqlen_unbalance
4844
from verl.utils.torch_functional import masked_mean
4945
from verl.utils.tracking import ValidationGenerationsLogger

recipe/sppo/sppo_ray_trainer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
from verl.single_controller.ray import RayWorkerGroup
3434
from verl.trainer.ppo import core_algos
3535
from verl.trainer.ppo.core_algos import agg_loss
36-
from verl.trainer.ppo.metric_utils import reduce_metrics
3736
from verl.trainer.ppo.ray_trainer import (
3837
AdvantageEstimator,
3938
RayPPOTrainer,
@@ -43,6 +42,7 @@
4342
)
4443
from verl.trainer.ppo.reward import compute_reward, compute_reward_async
4544
from verl.trainer.ppo.utils import Role, WorkerType, need_reference_policy, need_reward_model
45+
from verl.utils.metric import reduce_metrics
4646
from verl.utils.profiler.performance import simple_timer
4747
from verl.utils.tracking import ValidationGenerationsLogger
4848

0 commit comments

Comments
 (0)