Skip to content

[Bug Fix] Fix some bugs#7221

Open
ming1753 wants to merge 1 commit intoPaddlePaddle:developfrom
ming1753:cpu_cache
Open

[Bug Fix] Fix some bugs#7221
ming1753 wants to merge 1 commit intoPaddlePaddle:developfrom
ming1753:cpu_cache

Conversation

@ming1753
Copy link
Copy Markdown
Collaborator

@ming1753 ming1753 commented Apr 7, 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 Apr 7, 2026

Thanks for your contribution!

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@334b02c). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #7221   +/-   ##
==========================================
  Coverage           ?   73.87%           
==========================================
  Files              ?      376           
  Lines              ?    52938           
  Branches           ?     8264           
==========================================
  Hits               ?    39106           
  Misses             ?    11095           
  Partials           ?     2737           
Flag Coverage Δ
GPU 73.87% <ø> (?)

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.

Copy link
Copy Markdown

@fastdeploy-bot fastdeploy-bot left a comment

Choose a reason for hiding this comment

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

🤖 AI Code Review | 2026-04-08

📋 Review 摘要

PR 概述:修复 CUDA 操作中的同步和边界检查 bug

变更范围custom_ops/gpu_ops/append_attn/custom_ops/gpu_ops/flash_mask_attn/

影响面 Tag[OP]


📝 PR 规范检查

PR 描述中的 MotivationModifications 部分未填写,仅保留了模板占位符。请补充描述:

Motivation(建议填写):

修复两个 bug:1) DtoH 复制后未同步导致 CPU 可能读取到旧数据;2) KV 块未清零无效位置的共享内存,可能导致越界读取未初始化数据。

Modifications(建议填写):

  • get_block_shape_and_split_kv_block.cu: 在 DtoH 复制后添加 cudaStreamSynchronize 确保数据一致性
  • mainloop_attn.hpp: 添加 KV 块边界检查,清零无效位置的共享内存

另外,PR 标题使用了 [Bug Fix] 标签(带空格),官方规范中是 [BugFix](无空格),建议确认团队使用的标签格式。


问题

级别 文件 概述
🟡 建议 PR 描述 Motivation 和 Modifications 未填写
🟡 建议 PR 标题 标签格式使用 [Bug Fix],建议确认应为 [BugFix]

总体评价

代码修改整体合理:

  1. get_block_shape_and_split_kv_block.cu

    • 添加 cudaStreamSynchronize(stream) 修复了 DtoH 复制后立即读取 CPU 数据的潜在数据竞争问题
    • 函数末尾的同步确保所有 GPU 操作和内存复制完成
  2. mainloop_attn.hpp

    • 添加 KV 块边界检查逻辑,当 seq_len 不是 kBlockN 整数倍时,正确清零无效位置的共享内存,避免读取未初始化数据

未发现阻塞性问题,但 PR 描述需要完善以帮助后续代码审查和维护。

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