[Cherry-pick] Fix profile run in pd-disaggregated deployment #4693
+32
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
修复当前代码在 PD 分离场景 profile run 跑不通的问题 (cherry-picked from #4584)
Modifications
重新梳理 cache service (cache transfer + cache messager 的统称) 和 worker 的启动顺序,当前 engine.start() 有两种组件的启动顺序:
对于不指定 block 数量的场景,先启动 worker,让 worker 加载权重、跑 profile run 以确定实际的 block 数量,再启动 cache service。然后由 worker 或 cache service 其中一方创建 cache ,另一方读取 cache;
set_data_ipc设置共享内存指针,cache_transfer 和 worker 在等待 cache 被创建之后 (cache_ready_signal=1) 通过share_external_data读取 cache;paddle.empty_cache操作,因此将 cache 放到 worker 中管理。需要 worker 创建 cache 并通过set_data_ipc设置共享内存指针,cache transfer 在等待 cache 被创建之后通过share_external_data读取 cache。对于指定 block 数量的场景,先启动 cache service 直接创建 cache,再启动 worker 读取 cache;
对于禁用 prefix cache 的集中式部署场景,不需要启动 cache service。
各种场景的启动顺序逻辑真值表如下:
Usage or Command
Accuracy Tests
Checklist
[FDConfig],[APIServer],[Engine],[Scheduler],[PD Disaggregation],[Executor],[Graph Optimization],[Speculative Decoding],[RL],[Models],[Quantization],[Loader],[OP],[KVCache],[DataProcessor],[BugFix],[Docs],[CI],[Optimization],[Feature],[Benchmark],[Others],[XPU],[HPU],[GCU],[DCU],[Iluvatar],[Metax]]pre-commitbefore commit.releasebranch, make sure the PR has been submitted to thedevelopbranch, then cherry-pick it to thereleasebranch with the[Cherry-Pick]PR tag.