Skip to content

[Feature] support nvfp4 tbo#7259

Merged
zhoutianzi666 merged 3 commits intoPaddlePaddle:developfrom
lizexu123:fp4-tbo
Apr 9, 2026
Merged

[Feature] support nvfp4 tbo#7259
zhoutianzi666 merged 3 commits intoPaddlePaddle:developfrom
lizexu123:fp4-tbo

Conversation

@lizexu123
Copy link
Copy Markdown
Collaborator

@lizexu123 lizexu123 commented Apr 8, 2026

Motivation

PR 概述:为 NVFP4 MoE 添加 TBO (Two Batch Overlap) 支持

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

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ lizexu123
❌ root


root seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@paddle-bot
Copy link
Copy Markdown

paddle-bot bot commented Apr 8, 2026

Thanks for your contribution!

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 7.50000% with 37 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@48d2bbe). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...deploy/model_executor/layers/quantization/nvfp4.py 7.50% 37 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #7259   +/-   ##
==========================================
  Coverage           ?   73.84%           
==========================================
  Files              ?      383           
  Lines              ?    53548           
  Branches           ?     8390           
==========================================
  Hits               ?    39543           
  Misses             ?    11238           
  Partials           ?     2767           
Flag Coverage Δ
GPU 73.84% <7.50%> (?)

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

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

📋 Review 摘要

PR 概述:为 NVFP4 MoE 添加 TBO (Thread Batching Optimization) 支持

变更范围model_executor/layers/quantization/nvfp4.py

影响面 Tag[Feature] [Quantization]

📝 PR 规范检查

✅ PR 标题 [Feature] support nvfp4 tbo 符合规范
✅ PR 描述填写了 Motivation 字段
⚠️ Checklist 未完成(未勾选任何选项)

建议补全 Checklist:

  • Add at least a tag in the PR title. [Feature]
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.

问题

级别 文件 概述
🟡 建议 nvfp4.py:708 global_values 全局字典只写入未读取,疑似调试代码遗留
🟡 建议 nvfp4.py:730 大量 tensor 被存储到全局字典,可能导致内存泄漏

总体评价

PR 实现了 NVFP4 MoE 的 TBO 支持,整体逻辑正确。与 fused_moe_blackwell_backend.pyfused_moe_deepgemm_backend.py 的实现模式保持一致。存在一处遗留的调试代码,建议删除以避免潜在内存泄漏问题。

if self.ep_prefill_runner.ep_engine.async_finish:
event.current_stream_wait()

global global_values
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 建议 global_values 全局字典只写入未读取,疑似调试代码遗留。

整个代码库中没有任何地方读取 global_values 中存储的 tensor。建议删除相关代码(第 708-731 行、797 行、807 行)或添加注释说明其调试用途。

global_values[thread_name]["recv_x_scale"] = recv_x_scale
global_values[thread_name]["recv_topk_idx"] = recv_topk_idx
global_values[thread_name]["recv_topk_weights"] = recv_topk_weights
global_values[thread_name]["handle"] = handle
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 建议 大量 tensor 被存储到全局字典但从未读取,可能导致内存泄漏。

global_values 是模块级全局变量,存储了 xrecv_x_valuehandle 等多个 tensor 对象。这些对象会被持续引用,在高并发场景下可能导致内存无法及时回收。

建议:如果这些存储确实用于调试,应在生产环境中移除;如果需要保留,考虑使用 weakref 或定期清理机制。

@zhoutianzi666 zhoutianzi666 merged commit 613f92e into PaddlePaddle:develop Apr 9, 2026
51 of 57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants