Skip to content

[Cherry-Pick][BugFix] fix consume_signals barrier deadlock in PD separation(#8034)#8035

Merged
kevincheng2 merged 1 commit into
PaddlePaddle:release/2.6from
kevincheng2:fix/consume-signals-barrier-deadlock-2.6
Jun 15, 2026
Merged

[Cherry-Pick][BugFix] fix consume_signals barrier deadlock in PD separation(#8034)#8035
kevincheng2 merged 1 commit into
PaddlePaddle:release/2.6from
kevincheng2:fix/consume-signals-barrier-deadlock-2.6

Conversation

@kevincheng2

Copy link
Copy Markdown
Collaborator

Cherry-pick of #8034 to release/2.6.

Problem

In PD separation mode, consume_signals thread splits layer0 signals into ready_engine_signals and pending_engine_signals based on whether engine_idx exists in idx_cache_task_dict. Since _add_cache_task_thread fills idx_cache_task_dict asynchronously, different ranks may see different states at the same moment, causing mismatched finish_send_cache_barrier.wait() calls and deadlock.

Fix

Route all layer0 signals through pending_layer0_signals uniformly. The _add_cache_task_thread recovers them one-by-one after cache_info arrives, ensuring all ranks produce identical per-request signals into the queue.

@kevincheng2
kevincheng2 force-pushed the fix/consume-signals-barrier-deadlock-2.6 branch 2 times, most recently from 15e5ab9 to d00f59e Compare June 10, 2026 09:12
In PD separation mode, different ranks may receive cache_info at different
times. When consume_signals gets a layer0 signal, some ranks find the
engine_idx already in idx_cache_task_dict (ready) while others don't (pending).
This causes different ranks to put different batch_engine_signals into the
queue, leading to mismatched finish_send_cache_barrier.wait() calls and
deadlock.

Fix: route all layer0 signals through pending_layer0_signals uniformly,
then immediately recover any that already have cache_info registered.
Each recovered signal is put into the queue individually (single-request
batch) to ensure all ranks have identical batch granularity regardless
of recovery timing.
@kevincheng2
kevincheng2 force-pushed the fix/consume-signals-barrier-deadlock-2.6 branch from d00f59e to 693d90c Compare June 10, 2026 09:17
PaddlePaddle-bot

This comment was marked as outdated.

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Paddle-CI-Agent | pr_review | 2026-06-10 17:47:58

📋 Review 摘要

PR 概述:修复 PD separation 下 consume_signals 在 cache_info 异步注册时按 rank 产生不同 layer0 signal 入队粒度导致的 barrier 死锁。
变更范围fastdeploy/cache_manager/cache_messager.py
影响面 Tag[KVCache] [PD Disaggregation]

问题

未发现阻塞性问题。PR 规范问题在下面章节报,不要在这里重复

历史 Findings 修复情况

Finding 问题 状态
F1 pending_layer0_signals 恢复时一次性批量入队导致不同 rank 的 cache_prefilled_engine_ids_queue 粒度仍可能不一致 ✅ 已修复

📝 PR 规范检查

当前 PR 提交到 release/2.6 且描述为 cherry-pick,但标题缺少 [Cherry-Pick] 和原 PR 号;PR 描述也未包含 checklist §D2 要求的固定章节。

标题建议(可直接复制):

  • [Cherry-Pick][BugFix] fix consume_signals barrier deadlock in PD separation(#8034)
PR 描述建议(点击展开,可直接复制)
## Motivation
In PD separation mode, consume_signals may observe cache_info registration at different times across ranks. This can make layer0 signal enqueue granularity differ by rank and cause cache send barriers to deadlock.

## Modifications
- In fastdeploy/cache_manager/cache_messager.py, route layer0 signals through pending_layer0_signals and recover registered signals after cache_info is available.
- Cherry-pick of https://github.com/PaddlePaddle/FastDeploy/pull/8034 to release/2.6.

## Usage or Command
N/A

## Accuracy Tests
N/A

## Checklist

- [x] Add at least a tag in the PR title.
  - Tag list: [`[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]`]
  - You can add new tags based on the PR content, but the semantics must be clear.
- [ ] Format your code, run `pre-commit` before commit.
- [ ] Add unit tests. Please write the reason in this PR if no unit tests.
- [ ] Provide accuracy results.
- [x] If the current PR is submitting to the `release` branch, make sure the PR has been submitted to the `develop` branch, then cherry-pick it to the `release` branch with the `[Cherry-Pick]` PR tag.

总体评价

本轮按风险优先审查了 consume_signals layer0 signal 入队、_add_cache_task_thread 恢复路径、prefill_layerwise_send_cache_thread 的 barrier/finished queue 下游,以及 EngineWorkerQueue 的 cache_info/finished queue 同步逻辑。当前 diff 将已注册 cache_info 的 layer0 signal 逐个 put([signal]),修复了历史指出的 batch 粒度不一致风险;未发现新的阻塞性问题。

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (release/2.6@21941f5). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff               @@
##             release/2.6    #8035   +/-   ##
==============================================
  Coverage               ?   72.14%           
==============================================
  Files                  ?      386           
  Lines                  ?    55752           
  Branches               ?     8756           
==============================================
  Hits                   ?    40225           
  Misses                 ?    12691           
  Partials               ?     2836           
Flag Coverage Δ
GPU 72.14% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

@kevincheng2 kevincheng2 changed the title [BugFix] fix consume_signals barrier deadlock in PD separation [Cherry-Pick][BugFix] fix consume_signals barrier deadlock in PD separation(#8034) Jun 10, 2026
@PaddlePaddle-bot

Copy link
Copy Markdown

🤖 Paddle-CI-Agent | ci_status_monitor | 2026-06-11 23:01:47

CI报告基于以下代码生成(30分钟更新一次):
PR commit: 693d90c | Merge base: 21941f5 (branch: release/2.6)


1 Required任务 : 10/10 通过

总执行(rerun次数) 总任务 ✅ 通过 ❌ 失败 ⏳ 运行中 ⏸️ 等待中 跳过
37(1) 36 33 3 0 0 0
任务 错误类型 置信度 日志

2 失败详情

@kevincheng2
kevincheng2 merged commit 8c1c62e into PaddlePaddle:release/2.6 Jun 15, 2026
34 of 38 checks passed
@paddle-bot

paddle-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

Thanks for your contribution!

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.

4 participants