Skip to content

[bugfix] AS block leaks#7895

Open
zccjjj wants to merge 1 commit into
PaddlePaddle:release/2.6from
zccjjj:release/2.6
Open

[bugfix] AS block leaks#7895
zccjjj wants to merge 1 commit into
PaddlePaddle:release/2.6from
zccjjj:release/2.6

Conversation

@zccjjj
Copy link
Copy Markdown
Contributor

@zccjjj zccjjj commented May 22, 2026

Motivation

💡 If this PR is a Cherry Pick, the PR title needs to follow the format by adding the [Cherry-Pick] label at the very beginning and appending the original PR ID at the end. For example, [Cherry-Pick][CI] Add check trigger and logic(#5191)

💡 如若此PR是Cherry Pick,PR标题需遵循格式,在最开始加上[Cherry-Pick]标签,以及最后面加上原PR ID,例如[Cherry-Pick][CI] Add check trigger and logic(#5191)

Modifications

Usage or Command

Accuracy Tests

Checklist

  • 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.
  • 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.

@paddle-bot
Copy link
Copy Markdown

paddle-bot Bot commented May 22, 2026

Thanks for your contribution!

Copy link
Copy Markdown

@PaddlePaddle-bot PaddlePaddle-bot left a comment

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-05-22 13:21:52

📋 Review 摘要

PR 概述:修复 resource_manager_v1 调度器中 AS block 泄漏问题,将 can_allocate_gpu_blocks 的阈值计算从内联表达式改为通过 _get_can_schedule_prefill_threshold_block() 函数获取,并对已知的 storage block 泄漏路径增加 Warning 注释
变更范围fastdeploy/engine/sched/resource_manager_v1.py
影响面 Tag[Scheduler]

问题

级别 文件 概述
❓ 疑问 resource_manager_v1.py:1130 Warning 注释承认 _free_blocks 调用顺序会导致 storage block 泄漏,但代码仍执行该调用,未见实际修复
📝 PR 规范 标题 Tag 大小写不规范、release 分支缺 Cherry-Pick 标记、描述内容全部为空

📝 PR 规范检查

本 PR 存在以下规范问题:

  1. 标题 Tag 大小写偏差[bugfix] → 官方 Tag 为 [BugFix]
  2. Cherry-Pick 格式缺失:目标分支为 release/2.6(非 develop),标题应采用 [Cherry-Pick][BugFix] 格式并附原始 PR 编号
  3. 描述内容全部为空:Motivation / Modifications / Usage or Command / Accuracy Tests 均未填写

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

  • [Cherry-Pick][BugFix] Fix AS block leaks in resource_manager_v1(#原PR号)

PR 描述建议(可直接复制):

## Motivation

修复 resource_manager_v1 调度器中 AS block 泄漏问题。在分层 KV Cache(hierarchical cache)场景下,`can_allocate_gpu_blocks` 的阈值计算未考虑 AS block 需求,导致实际可用 block 不足时仍尝试分配,进而引发 block 泄漏及潜在死锁。

## Modifications

- `fastdeploy/engine/sched/resource_manager_v1.py`:将 `_allocate_decode_and_extend()` 中两处内联 block 数计算替换为 `_get_can_schedule_prefill_threshold_block()` 函数调用,以正确获取包含 AS block 的可调度阈值;对已知的 `_free_blocks` 调用顺序风险增加 Warning 注释

## Usage or Command

N/A

## Accuracy Tests

N/A

## Checklist

- [ ] 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.

总体评价

核心修复(两处对称地用 _get_can_schedule_prefill_threshold_block() 替代内联 block 数计算)思路正确,逻辑一致。但新增的 Warning 注释承认存在 storage block 泄漏路径(_free_blocks 先于 update_cache_blocks 执行),而 PR 标题正是 "AS block leaks",需作者说明此泄漏路径是否已在本 PR 范围内修复,或有对应跟进计划;PR 规范信息亦需补全。

self.req_dict[request.request_id] = allocated_position
llm_logger.debug(f"req_id:{request.request_id} allocate pos end")
else:
# Warning: _free_blocks before update_cache_blocks may cause storage blocks leak
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

❓ 疑问 新增 Warning 注释说明 _free_blocksupdate_cache_blocks 之前调用可能导致 storage block 泄漏,但紧接着的代码仍然执行 self._free_blocks(request),并未修复该顺序问题。

PR 标题为 "AS block leaks",请作者说明:

  1. 此处 _free_blocks before update_cache_blocks 的调用顺序是否就是本次要修复的 AS block 泄漏根因?
  2. 若是,应在此处补充修复逻辑(例如先调用 update_cache_blocks 再调用 _free_blocks,或跳过 _free_blocks);若不是,建议在 PR 描述中补充对应 issue 编号,说明此 Warning 何时跟进修复。

@PaddlePaddle-bot
Copy link
Copy Markdown

PaddlePaddle-bot commented May 22, 2026

🤖 Paddle-CI-Agent | ci_status_monitor | 2026-05-23 10:01:04

CI报告基于以下代码生成(30分钟更新一次):


1 任务总览

当前 Required 任务 9/10 通过,唯一阻塞项为 Approval,需要人工审批;主测试任务 Run FastDeploy Unit Tests and Coverage / run_tests_with_coverage 已通过。Optional 失败不阻塞合并,仅供参考。

总执行(rerun次数) 总任务 ✅ 通过 ❌ 失败 ⏳ 运行中 ⏸️ 等待中 跳过
36(0) 36 31 5 0 0 0

2 任务状态汇总

日志列说明:失败任务直接使用日志链接;运行中任务使用 Job 链接。

2.1 Required任务 : 9/10 通过

必选任务阻塞合并,失败需优先处理。

状态 任务 耗时 根因 修复建议 日志 重跑
Approval 8s 需要 Approval 请通过人工审批 Job -
其余 9 个必选任务通过 - - - - -

2.2 可选任务 — 22/26 通过

可选任务不阻塞合并,失败仅供参考。

状态 任务 耗时 日志 重跑
Run iluvatar Tests / run_iluvatar_cases 1m48s Job -
Check PR Template 10s Job -
CI_HPU 1h13m Job -
Trigger Jenkins for PR 1m1s Job -
其余 22 个可选任务通过 - - -

3 失败详情(仅 required)

Approval — 等待人工审批(置信度: 高)

该 Job 需要人工 Approval,完成审批后 CI 才会继续执行。

  • 根因摘要:需要人工审批,当前 Required CI 被 Approval 阻塞。
  • 修复建议摘要:请有权限的维护者通过人工审批,审批后等待 CI 继续执行。

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release/2.6@b562b8d). Learn more about missing BASE report.

Files with missing lines Patch % Lines
fastdeploy/engine/sched/resource_manager_v1.py 50.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##             release/2.6    #7895   +/-   ##
==============================================
  Coverage               ?   72.34%           
==============================================
  Files                  ?      381           
  Lines                  ?    54227           
  Branches               ?     8473           
==============================================
  Hits                   ?    39233           
  Misses                 ?    12226           
  Partials               ?     2768           
Flag Coverage Δ
GPU 72.34% <50.00%> (?)

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

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

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.

3 participants