Skip to content

[RL] Reset buffer size of slot_mapping#7868

Merged
yuanlehome merged 2 commits into
PaddlePaddle:release/2.6from
gongshaotian:r3_mm_2.6
May 21, 2026
Merged

[RL] Reset buffer size of slot_mapping#7868
yuanlehome merged 2 commits into
PaddlePaddle:release/2.6from
gongshaotian:r3_mm_2.6

Conversation

@gongshaotian
Copy link
Copy Markdown
Collaborator

Motivation

Reset buffer size of slot_mapping and position_ids.

Modifications

Shape of slot_mapping and position_ids.

Usage or Command

None

Accuracy Tests

None

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 20, 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-20 18:37:39

📋 Review 摘要

PR 概述:修正 slot_mapping_bufferposition_ids_buffer 的初始化大小,与同类 buffer 保持一致,并为已有 assert 补充详细错误信息。
变更范围fastdeploy/worker/input_batch.pyfastdeploy/worker/gpu_model_runner.py
影响面 Tag[RL] [Executor]

问题

未发现阻塞性问题。

📝 PR 规范检查

PR 目标分支为 release/2.6(非 develop),标题缺少 [Cherry-Pick] 前缀,不符合 Cherry-Pick 格式要求 [Cherry-Pick][Tag] 标题描述(#原PR号)

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

  • [Cherry-Pick][RL] Reset buffer size of slot_mapping (#<原develop分支PR号>)

PR 描述建议(可直接复制,必须复刻 checklist §D2 模板的完整结构):

## Motivation

`slot_mapping_buffer``position_ids_buffer` 原先使用 `scheduler_config.max_num_batched_tokens` 初始化,与同文件中其他 buffer(`ids_remove_padding``batch_id_per_token` 等)使用的 `max_chunk_tokens` 不一致,可能在 Chunked Prefill 或多模态场景下导致缓冲区大小偏大。统一使用 `max_chunk_tokens` 以保持一致性。

## Modifications

- `fastdeploy/worker/input_batch.py`:将 `position_ids_buffer``slot_mapping_buffer` 的初始化尺寸由 `scheduler_config.max_num_batched_tokens` 改为 `self.max_chunk_tokens`,与同文件其他 buffer 对齐。
- `fastdeploy/worker/gpu_model_runner.py`:为 `assert batch_id_per_token.shape == block_idx.shape` 补充详细错误信息,便于排查 shape 不一致问题。

## 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.
- [x] Format your code, run `pre-commit` before commit.
- [x] Add unit tests. Please write the reason in this PR if no unit tests.
- [x] 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.

总体评价

代码改动正确,slot_mapping_buffer/position_ids_buffer 改用 max_chunk_tokens 与同类 buffer 保持一致,逻辑清晰。仅 PR 标题缺少 [Cherry-Pick] 前缀,建议补充后合入。

_max_batched_tokens = self.scheduler_config.max_num_batched_tokens
self.position_ids_buffer = paddle.zeros([_max_batched_tokens], dtype=paddle.int32)
self.slot_mapping_buffer = paddle.zeros([_max_batched_tokens], dtype=paddle.int64)
self.position_ids_buffer = paddle.zeros([self.max_chunk_tokens], dtype=paddle.int32)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 建议 此处改动正确,与文件中其他使用 max_chunk_tokens 的 buffer(如 L183 ids_remove_padding、L187 batch_id_per_token)保持一致。

建议在注释中补充说明 max_chunk_tokens 与原 max_num_batched_tokens 的语义差异,例如:

# Initialize addressing buffers
# Use max_chunk_tokens (instead of max_num_batched_tokens) to be consistent
# with other per-token buffers (ids_remove_padding, batch_id_per_token, etc.)
self.position_ids_buffer = paddle.zeros([self.max_chunk_tokens], dtype=paddle.int32)
self.slot_mapping_buffer = paddle.zeros([self.max_chunk_tokens], dtype=paddle.int64)

@PaddlePaddle-bot
Copy link
Copy Markdown

PaddlePaddle-bot commented May 20, 2026

🤖 Paddle-CI-Agent | ci_status_monitor | 2026-05-21 06:25:39

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


1 任务总览

当前 9/10 个 required 任务已通过;仍有 1 个 required 任务失败(Approval),需完成人工审批后再继续观察 CI。

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

2 任务状态汇总

日志列说明:失败任务直接使用工具预生成的日志链接;运行中任务使用 Job 链接。

2.1 Required任务 : 9/10 通过

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

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

2.2 可选任务 — 23/28 通过

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

状态 任务 耗时 日志 重跑
Run iluvatar Tests / run_iluvatar_cases 18m16s Job -
CI_HPU 1h4m Job -
Trigger Jenkins for PR 1m9s Job -
Trigger Jenkins for PR 1m0s Job -
⏭️ 1 个可选任务跳过 - - -
其余 23 个可选任务通过 - - -

3 失败详情(仅 required)

Approval — 需要人工审批(置信度: 高)

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

  • 根因摘要:需要 Approval
  • 修复建议摘要:请通过人工审批
  • Job 链接:Approval

@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@8c4f5a6). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff               @@
##             release/2.6    #7868   +/-   ##
==============================================
  Coverage               ?   72.37%           
==============================================
  Files                  ?      381           
  Lines                  ?    54216           
  Branches               ?     8473           
==============================================
  Hits                   ?    39237           
  Misses                 ?    12218           
  Partials               ?     2761           
Flag Coverage Δ
GPU 72.37% <100.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.

@yuanlehome yuanlehome merged commit b5c8290 into PaddlePaddle:release/2.6 May 21, 2026
34 of 39 checks passed
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.

5 participants