Skip to content

[Bug Fix] Fix some bugs#7220

Open
ming1753 wants to merge 1 commit intoPaddlePaddle:release/2.4from
ming1753:release/2.4
Open

[Bug Fix] Fix some bugs#7220
ming1753 wants to merge 1 commit intoPaddlePaddle:release/2.4from
ming1753:release/2.4

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 (release/2.4@dc095ea). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff               @@
##             release/2.4    #7220   +/-   ##
==============================================
  Coverage               ?   56.46%           
==============================================
  Files                  ?      333           
  Lines                  ?    42616           
  Branches               ?     6477           
==============================================
  Hits                   ?    24061           
  Misses                 ?    16684           
  Partials               ?     1871           
Flag Coverage Δ
GPU 56.46% <ø> (?)

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 11:08 CST

📋 Review 摘要

PR 概述:修复 GPU 算子中的同步问题和边界条件 bug

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

影响面 Tag[OP]

📝 PR 规范检查

PR 标题和描述存在以下问题:

  1. 标题 Tag 格式不正确[Bug Fix] 应改为 [BugFix](官方 Tag 列表中无空格)
  2. 描述部分未填写:Motivation 和 Modifications 部分为空

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

  • [BugFix] Fix some bugs

描述模板(可直接复制):

## Motivation
修复了以下 bug:
1. get_block_shape_and_split_kv_block.cu 中条件编译结构错误导致代码分支不正确
2. flash_mask_attn 中当 seq_len_k 不是 kBlockN 整数倍时可能读取未初始化的 shared memory

## Modifications
1. 修复 get_block_shape_and_split_kv_block.cu 中的条件编译结构,并添加 cudaStreamSynchronize 确保 DtoH copy 完成后再读取
2. 在 flash_mask_attn mainloop 中添加边界检查,清零最后一个 block 中无效的 V 数据

问题

未发现阻塞性问题。代码修复逻辑正确,但建议完善测试覆盖。

总体评价

代码修复正确,逻辑合理。两个 bug 修复都是必要的:

  1. 条件编译修复解决了编译分支错误
  2. 边界检查和清零避免了读取未初始化 shared memory 的潜在问题

建议完善 PR 描述并考虑补充边界条件测试。

@@ -290,10 +290,16 @@ void GetBlockShapeAndSplitKVBlock(
// Note (sunxin): Skip capturing the DtoH copy (it's time-consuming); CPU data
// is only for branching in attention.
#ifndef PADDLE_WITH_CUSTOM_DEVICE_METAX_GPU
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 建议 原代码中 #endif 位置不正确,导致条件编译结构错误。修复后代码逻辑正确,建议在 commit message 中说明此问题的影响。

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