已合并
mindspeed-rl profiler support multi-stage && add ppo model doc #796
xieanran创建于 2025年12月5日
mindspeed-rl profiler support multi-stage && add ppo model doc #796
已合并
共 2 个文件变更+23-4
| @@ -8,6 +8,11 @@ | |||
| 8 | 8 | ||
| 9 | > **注意**:当前 profiler 性能数据采集仅支持共卡模式(integrated)场景。 | 9 | > **注意**:当前 profiler 性能数据采集仅支持共卡模式(integrated)场景。 |
| 10 | 10 | ||
| 11 | +> **PPO场景采集**:由于PPO场景单卡多进程特性,profiler配置选项中的stage**不能**被设置为all。 | ||
| 12 | +> 如需采集所有stage,可以通过stage参数手动指定采集的stage, | ||
Z | |||
| 13 | +> 具体参数配置可参考配置选项章节的主要配置参数说明表格中的stage参数。 | ||
| 14 | + | ||
| 15 | + | ||
| 11 | 性能调优工具通过 YAML 配置文件中的 `profiler_config` 部分进行配置: | 16 | 性能调优工具通过 YAML 配置文件中的 `profiler_config` 部分进行配置: |
| 12 | 17 | ||
| 13 | ```yaml | 18 | ```yaml |
| @@ -53,7 +58,7 @@ profiler_config: | |||
| 53 | |------|------|--------| | 58 | |------|------|--------| |
| 54 | | profile | 性能分析开关 | true/false,默认值false,所有性能数据采集均依赖该开关开启 | | 59 | | profile | 性能分析开关 | true/false,默认值false,所有性能数据采集均依赖该开关开启 | |
| 55 | | mstx | 轻量化打点采集开关 | true/false,默认值false,启用/关闭轻量化打点采集,需要查看轻量化打点性能数据时需开启 | | 60 | | mstx | 轻量化打点采集开关 | true/false,默认值false,启用/关闭轻量化打点采集,需要查看轻量化打点性能数据时需开启 | |
| 56 | -| stage | 性能数据采集阶段 | all(采集所有阶段性能数据)、actor_generate(采集actor模型生成阶段性能数据)、actor_compute_log_prob(采集actor模型计算log概率阶段性能数据)、reference_compute_log_prob(采集reference参考模型计算log概率阶段性能数据)、critic_compute_values(采集critic模型计算values阶段性能数据)、actor_update(采集模型更新阶段性能数据)、critic_update(采集模型更新阶段性能数据)默认值all | | 61 | +| stage | 性能数据采集阶段 | 可选参数包括all(采集所有阶段性能数据)、actor_generate(采集actor模型生成阶段性能数据)、actor_compute_log_prob(采集actor模型计算log概率阶段性能数据)、reference_compute_log_prob(采集reference参考模型计算log概率阶段性能数据)、critic_compute_values(采集critic模型计算values阶段性能数据)、actor_update(采集模型更新阶段性能数据)、critic_update(采集模型更新阶段性能数据);stage参数支持列表传参,一次性采集多个stage;stage参数默认值为all | |
| 57 | | profile_save_path | 性能数据输出目录 | 任意有效路径,默认为"./profiler_data" | | 62 | | profile_save_path | 性能数据输出目录 | 任意有效路径,默认为"./profiler_data" | |
| 58 | | profile_export_type | 导出格式 | text、db(性能数据交付件为db格式,可减少约70%磁盘空间),默认值text | | 63 | | profile_export_type | 导出格式 | text、db(性能数据交付件为db格式,可减少约70%磁盘空间),默认值text | |
| 59 | | profile_step_start | 开启采集数据的步骤 | 任意正整数,默认为1,profile_step_start从1开始 | | 64 | | profile_step_start | 开启采集数据的步骤 | 任意正整数,默认为1,profile_step_start从1开始 | |
| @@ -8,6 +8,7 @@ import sys | |||
| 8 | import json | 8 | import json |
| 9 | import time | 9 | import time |
| 10 | import random | 10 | import random |
| 11 | +import logging as logger | ||
| 11 | from contextlib import contextmanager | 12 | from contextlib import contextmanager |
| 12 | from functools import wraps | 13 | from functools import wraps |
| 13 | from typing import Dict, List | 14 | from typing import Dict, List |
| @@ -22,7 +23,6 @@ import torch_npu | |||
| 22 | import torch.distributed as dist | 23 | import torch.distributed as dist |
| 23 | from torch import Tensor | 24 | from torch import Tensor |
| 24 | 25 | ||
| 25 | - | ||
| 26 | cur_file_dir = Path(__file__).absolute().parent | 26 | cur_file_dir = Path(__file__).absolute().parent |
| 27 | base_dir = os.path.realpath(os.path.join(cur_file_dir, "..", "..")) | 27 | base_dir = os.path.realpath(os.path.join(cur_file_dir, "..", "..")) |
| 28 | 28 | ||
| @@ -610,10 +610,24 @@ def profiler_start(profiler_config, role="profiler_data", profiler_iteration=Non | |||
| 610 | profiler_iteration < profiler_config.profile_step_start or | 610 | profiler_iteration < profiler_config.profile_step_start or |
| 611 | profiler_iteration >= profiler_config.profile_step_end): | 611 | profiler_iteration >= profiler_config.profile_step_end): |
| 612 | return None | 612 | return None |
| 613 | + if profiler_config.stage != "all": | ||
| 614 | + if isinstance(profiler_config.stage, str): | ||
| 615 | + if role != profiler_config.stage: | ||
| 616 | + return None | ||
| 617 | + else: | ||
| 618 | + try: | ||
| 619 | + stages = list(profiler_config.stage) | ||
Z PPO场景采集profiling的验证日志贴一下 ![]() ![]() | |||
| 620 | + except TypeError: | ||
| 621 | + logger.warning(f"profiler stage is not iterable, set stages to empty list") | ||
| 622 | + stages = [] | ||
| 623 | + except Exception as e: | ||
| 624 | + logger.warning(f"unexpected exception while profiling stage: {e}, set stages to empty list") | ||
| 625 | + stages = [] | ||
| 626 | + if role not in stages: | ||
| 627 | + return None | ||
| 613 | if profiler_config.stage == "all" and role != profiler_config.role: | 628 | if profiler_config.stage == "all" and role != profiler_config.role: |
| 614 | return None | 629 | return None |
| 615 | - if profiler_config.stage != "all" and role != profiler_config.stage: | 630 | + |
| 616 | - return None | ||
| 617 | profiler = get_grpo_profiler(profiler_config, role) | 631 | profiler = get_grpo_profiler(profiler_config, role) |
| 618 | if not profiler: | 632 | if not profiler: |
| 619 | return None | 633 | return None |


单卡多进程特性什么时候能够支持?