Repository navigation
Conversation
_record_stamp/_flush_records wrote one text file per rank and needed profiler_helper.py to merge them into pipeline_profile.json for chrome://tracing. It timestamps with time.time() at millisecond resolution and does a paddle.device.synchronize() per stamp, so turning it on perturbs what it measures, and host clocks are not comparable across ranks. It had also fallen behind the schedulers: PipelineParallelWithInterleaveFthenB never wired it up at all. The pipeline_event_hook mechanism covers the same ground with CUDA events and no synchronization, so drop this one. _forward_micro_step_counter / _backward_micro_step_counter and _reset_counter() are kept: static_scheduler reads them too. pp_configs.profiling stays in the proto but is now unread.
forward_backward_pipeline(static_scheduler=True) skipped every recv /
forward / send and only appended to a string, returning the schedule
("f0_vp0;b0_vp1;...") instead of a loss. get_static_scheduler() was its
only entry point and nothing in the tree called it.
With the chrome-tracing profiler gone this was the last reader of
_forward_micro_step_counter / _backward_micro_step_counter, so those and
_reset_counter() go with it. _rc_forward_count / _rc_backward_count are
unaffected: they are RecomputeStore's chunk identity and are maintained
unconditionally.
NoPipelineParallel (pp_degree = 1) now publishes the same scheduler events as
PipelineParallel through pipeline_event_hook, so a listener (for example a
timeline profiler) sees pp = 1 runs too: one stage, one step of
accumulate_steps forward / backward pairs in a single steady phase, no p2p.
- pipeline_event_hook: add the `step` span kind and PipelineEventHook.step(),
for a scheduler whose whole step sits in one block
- NoPipelineParallel: set the hook context in __init__ (stage 0 of 1) and wrap
forward_backward_pipeline in step / phase("steady") / forward(micro) /
backward(micro) spans. With no listener registered every emit is a no-op.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| @@ -2028,8 +2021,10 @@ class P2PAsyncHandle: | |||
| recv_next = None | |||
| out_bwd_wait_handles = None | |||
|
|
|||
| def forward_handle_wait(self): | |||
| self.forward_handle_wait_fn() | |||
| def forward_handle_wait(self, recv_micro, send_micro): | |||
There was a problem hiding this comment.
P2PAsyncHandle.forward_handle_wait / backward_handle_wait 新增了必填参数 recv_micro、send_micro,这会破坏现有的下游调用。
在 interleave 的 overlap 路径上(第 2682 行),p2p_async_handle 会交给模型的 overlapped_forward_backward。下游实现目前都是无参调用:
- PaddleFleet:
transformer_encoder.py - VHA:
transformer_encoder.py、gpt_model.py
调用形式都是 p2p_async_handle.forward_handle_wait() 和 p2p_async_handle.backward_handle_wait()。合入后,开启 overlap_p2p_comm 并且模型实现了 overlapped_forward_backward 时,steady 阶段会直接抛 TypeError。
建议:
- 两个方法的参数都改为可选,
recv_micro=None, send_micro=None。 - 参数缺省时不按 micro 标注,或者按
pipeline_event_hook.py注释里提到的role="OL"标注(目前代码里没有任何地方发出这个 role)。 - 补一个无参调用的用例。
There was a problem hiding this comment.
已修复:forward/backward handle wait 的 micro 参数均可省略,无参调用不会向旧 callback 传入额外参数。模型 overlap 路径等待顺序不变;没有 micro ID 时跳过该 wait 的埋点,避免下游 listener 收到无法归属的事件。补了无参调用回归测试。
修订提交:f12eedce2f。
| _release_output(output_tensor) | ||
|
|
||
| # remaining backward steps | ||
| # remaining backward steps | ||
| self._pp_hook.emit( |
There was a problem hiding this comment.
cooldown 的 phase 事件在
forward_only=True 时只有 begin,没有 end。
位置:
- 第 3494 行的
PHASE_BEGIN在if not forward_only:外面,配对的PHASE_END(第 3623 行)却在分支里面。 PipelineParallelWithInterleaveFthenB也一样:第 3961 行的 begin 在外,第 4014 行的 end 在内。
后果:
eval_batch走forward_only=True,listener 会收到一个没有闭合的 cooldown 区间。这违反了pipeline_event_hook.py里"区间不能只开不合"的约定。- begin 和 end 携带的
micro也不一致,分别是steady_steps和num_steps - 1。
建议:参照第 4535 行,用 with self._pp_hook.phase("cooldown", micro=...): 包住整段 cooldown。
There was a problem hiding this comment.
已修复:两种 interleave 的 cooldown 都在 if not forward_only 内使用 with self._pp_hook.phase(...),训练时成对且 payload 一致,eval 不发 cooldown。CPU 测试覆盖了两种调度的 train/eval。
修订提交:f12eedce2f。
There was a problem hiding this comment.
已确认:当前 head 中两处 cooldown 都已改为 if not forward_only 内的 with self._pp_hook.phase(...),begin/end 载荷一致,eval 路径不再发出 cooldown;测试同时覆盖了两种调度的 train/eval。该问题已关闭。
| # event vocabulary. Set up here rather than lazily because | ||
| # _use_batch_p2p_comm is only final at this point (the warning above can | ||
| # flip it) and listeners need it to resolve p2p lanes. | ||
| self._pp_hook = pp_ev.get_pipeline_event_hook() |
There was a problem hiding this comment.
本 PR 删除了
pp_configs.profiling 的全部实现,但配置项还在,而且没有任何提示。
具体变化:
- 删除了
_record_stamp、_flush_records和profiler_helper.py。 - 删除了
forward_backward_pipeline(static_scheduler=...)参数和get_static_scheduler()。 paddle/fluid/framework/distributed_strategy.proto:87的profiling字段仍然保留,但现在没有任何代码读取它。
影响:已经设置 profiling=True 的用户不会再得到 profile 记录,也收不到任何提示。显式传入 static_scheduler=True 的调用会直接报 TypeError。
建议:
profiling=True时打印弃用告警,说明改用pipeline_event_hook的 listener。- 或者同步把该字段标记为弃用,并在 PR 描述里写明迁移方式。
There was a problem hiding this comment.
已补迁移提示:pp_configs.profiling=True 在初始化 PipelineParallel 时发出 FutureWarning,指向 pipeline_event_hook.get_pipeline_event_hook() 的 listener,并说明 get_static_scheduler() / static_scheduler 参数已移除。protobuf 字段保留以便读取旧配置。
修订提交:f12eedce2f。
| listener(event, payload) | ||
|
|
||
| # ── regions ──────────────────────────────────────────────────────── | ||
| def span(self, kind: str, **payload): |
There was a problem hiding this comment.
这个模块本身声明了一组约定:
begin和end成对出现,payload 一致;- 异常路径上也会发出 end;
- 没有 listener 时返回共享的
NULL_SPAN; P2PReqs.roles与 handle 列表逐个对齐。
这些约定一旦被后续改动破坏,只有在多卡 trace 里才能看出来。
建议:在 test/collective/fleet/test_pipeline_parallel_micro_step_hooks.py 里沿用 _FakeReq 的写法,补几个不需要 GPU 的用例:
- span 的配对和 payload;
- 异常路径上的 end 事件;
- 无 listener 时返回
NULL_SPAN; P2PReqs交替调用add_sends/add_recvs后的顺序和 roles;_wait_p2p按 role 选取 micro。
There was a problem hiding this comment.
已在 test_pipeline_parallel_micro_step_hooks.py 新增 12 个 CPU 回归用例,覆盖 payload 配对、异常闭合、共享 NULL_SPAN、P2P 请求与 role 对齐、按 role 选 micro、不改变 wait 顺序及旧无参调用等。该文件 27 个用例均已通过;尚未运行多卡 GPU 测试。
修订提交:f12eedce2f。
There was a problem hiding this comment.
已确认:新增用例覆盖 span 配对、异常路径闭合、共享 NULL_SPAN、P2PReqs.roles 对齐、按 role 选 micro 以及无参调用兼容;多卡 GPU 路径由 CI 覆盖即可。该问题已关闭。
| + '}' | ||
| ) | ||
| def _wait_p2p(self, direction, reqs, recv_micro, send_micro): | ||
| """等一次 p2p,**一个 handle 一个 span**,span 上标它是 send 还是 recv。 |
There was a problem hiding this comment.
💡 可维护性建议(约定偏离,不阻塞合入):本 PR 在 pipeline_parallel.py 和 p2p_communication.py 里新增了大量中文 docstring 和注释,比如这里的 _wait_p2p、P2PReqs、_p2p_span 前的注释块,以及各个 _wait_p2p 调用点的注释。这两个文件原本没有中文注释,同一 PR 新增的 pipeline_event_hook.py 也是全英文。建议统一改写成简短的英文,并把重复的理由只保留在 pipeline_event_hook.py 一处。
There was a problem hiding this comment.
已将新增的中文注释和 docstring 改为简短英文;为什么按 send/recv 分开记录的说明集中在 pipeline_event_hook.py。
修订提交:f12eedce2f。
| return False | ||
|
|
||
|
|
||
| class PipelineEventHook: |
There was a problem hiding this comment.
💡 可维护性建议(依赖健康度,不阻塞合入):pipeline_parallel.py 里已经有公开的 PipelineParallelMicroStepCallback 和 register_global_pipeline_parallel_hook,提供 FORWARD_BEGIN/END、BACKWARD_BEGIN/END、P2P_ISSUED 这些位置。新的 PipelineEventHook 又另起了一套 listener 注册表和同名事件。建议二选一:
- 在模块 docstring 里说明两者的分工,以及旧接口是否会弃用;
- 或者让新机制复用已有的注册表。
There was a problem hiding this comment.
已在模块 docstring 中区分两者:原 micro-step callback 是控制接口,可参与张量计算,仍受支持;新 event hook 只发布调度元数据,供观测使用。
修订提交:f12eedce2f。
| return _HOOK.span(SPAN_SUB, name=event, which=which, layer=layer) | ||
|
|
||
|
|
||
| def pipeline_event_mark(event, phase, which=None, layer=None) -> None: |
There was a problem hiding this comment.
💡 可维护性建议(抽象适配度,不阻塞合入):以下新增的公共成员在仓库里都没有调用方:
SPAN_KINDSpipeline_event_span和pipeline_event_mark(后者已进入__all__)P2PReqs.sends/P2PReqs.recvs
其中 pipeline_event_mark 的 phase 参数只要不等于 "begin",就会被当成 end 处理,而且没有任何报错。建议先删掉这些没有使用者的成员,等真正有调用方时再加;如果要保留,至少给 phase 加上取值校验。
There was a problem hiding this comment.
已删除未使用的 SPAN_KINDS、pipeline_event_span、pipeline_event_mark 和 P2PReqs.sends / .recvs,保留与请求逐项对齐的 roles。
修订提交:f12eedce2f。
| return_micro_batch_loss=False, | ||
| ): | ||
| # use the 1f1b scheduling strategy. | ||
| # this strategy is inspired by: | ||
| # https://github.com/NVIDIA/Megatron-LM/blob/main/megatron/schedules.py | ||
|
|
||
| self._reset_user_hooks_status() | ||
| self._pp_hook.emit(pp_ev.STEP_BEGIN) |
There was a problem hiding this comment.
💡 可维护性建议(错误处理一致性,不阻塞合入):四个 pipeline 调度器的 step 边界都是用一对 emit(STEP_BEGIN) / emit(STEP_END) 手写的,比如这里和第 1445 行。只要中间抛出异常,STEP_END 就不会发出。NoPipelineParallel 和其他区间用的是 with self._pp_hook.step(),异常路径也能闭合。建议统一改成上下文管理器的写法。
There was a problem hiding this comment.
已把四个调度器的手写 STEP_BEGIN/END 替换为 with self._pp_hook.step(),异常路径也会发出 STEP_END。新增了调度异常的 CPU 回归测试。
修订提交:f12eedce2f。
There was a problem hiding this comment.
已确认:四个调度器的 step 边界都已改为 with self._pp_hook.step(),异常路径由 _Span.__exit__ 补发 STEP_END,并有调度异常的 CPU 用例覆盖。该建议已关闭。
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (65.32%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #80028 +/- ##
==========================================
Coverage ? 65.32%
==========================================
Files ? 2
Lines ? 248
Branches ? 0
==========================================
Hits ? 162
Misses ? 86
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Preserve model-side P2P wait callbacks and omit waits with no scheduler micro ID. Pair step and cooldown boundaries, warn on the removed profiling path, and cover the event contract with CPU tests. Co-Authored-By: AI Assistant <noreply@example.com>
| self.assertEqual(self.events, []) | ||
|
|
||
|
|
||
| class TestPipelineP2pWait(unittest.TestCase): |
There was a problem hiding this comment.
💡 可维护性建议(测试策略,不阻塞合入):新增用例覆盖了 span 配对、P2PReqs.roles 和 _wait_p2p,但 p2p_issue 事件还没有用例:_p2p_span 的 op / micro / is_async 载荷,以及 micro_step_id=None 时不发事件这一约定,目前只能靠读代码确认。建议沿用 _FakeReq 的写法补一个不需要 GPU 的用例,直接调用 p2p_communication 的一个方法(比如 recv_forward),断言收到的事件名、payload 和 None 时不发事件。
There was a problem hiding this comment.
已采纳(e5e970f071)。新增两个 CPU 用例,直接调用 P2pHelper.recv_forward,用假请求验证同步/异步的 p2p_issue_begin/end、op / micro / is_async payload,以及不传 micro_step_id 时仍正常 post、但不发事件。该测试文件的 30 个用例全部通过。
There was a problem hiding this comment.
已确认。TestPipelineP2pIssue 覆盖了同步/异步的 p2p_issue_begin/end payload 与缺省 micro_step_id 时不发事件但正常 post,测试策略建议已解决。
| assert forward_only, ( | ||
| "compute_loss can only be set to False when forward_only is set to True" | ||
| ) | ||
| with self._pp_hook.step(): |
There was a problem hiding this comment.
💡 可维护性建议(设计一致性,不阻塞合入):with self._pp_hook.step(): 直接包住了 forward_backward_pipeline 的全部函数体,四个调度器各自整体缩进一级,本 PR 的 diff 因此膨胀到 3000 行以上,评审和后续 backport 都更难核对。建议保留 step 事件语义,但改用极薄的装饰器(内部 with self._pp_hook.step(): return fn(self, *args, **kwargs))套在四个 forward_backward_pipeline 上,避免重排缩进。
There was a problem hiding this comment.
已采纳(e5e970f071)。用薄装饰器 _with_pipeline_step 保留 step 事件和异常闭合,恢复四种调度主体原有缩进。Balanced-memory 的 eval 继续委托父类,只发一对 step 事件,已有 CPU 用例覆盖 train/eval 的异常路径。对比上一轮评审前,pipeline_parallel.py 的累计 diff 从 3,266 行降为 550 行(增删合计)。
There was a problem hiding this comment.
已确认。_with_pipeline_step 保证了 step 事件与异常闭合,四种调度主体缩进恢复;balanced-memory 的 eval 委托父类只发一对 step 事件,设计一致性建议已解决。
Trace scheduler calls with a thin decorator instead of reindenting the bodies. Stay on the parent trace path for balanced-memory eval. Test P2P issue payloads and unknown micro IDs with fake requests on CPU. Co-Authored-By: AI Assistant <noreply@example.com>
Wrap the no-pipeline microbatch schedule with the same step decorator. Keep dataset preprocessing outside the span and cover event ordering on early failure. Co-Authored-By: AI Assistant <noreply@example.com>
|
/re-run --all-failed |
1 similar comment
|
/re-run --all-failed |
Do not export scheduler instrumentation through __all__. The profiler can keep using the same explicit imports and event contract without introducing public Paddle APIs. Co-Authored-By: AI Assistant <noreply@example.com>
PR Category
User Experience
PR Types
Improvements
Description
清理之前的pp 模拟等无用代码,并合入perfsim支持的pp profiler工具代码
是否引起精度变化
否