Skip to content

[Feature] Support cute cpp Encoder FA4#7016

Open
mpgemm wants to merge 6 commits intoPaddlePaddle:developfrom
mpgemm:fa4-opt
Open

[Feature] Support cute cpp Encoder FA4#7016
mpgemm wants to merge 6 commits intoPaddlePaddle:developfrom
mpgemm:fa4-opt

Conversation

@mpgemm
Copy link

@mpgemm mpgemm commented Mar 25, 2026

Motivation

新增优化后的 C++ FA4 算子,支持 NVIDIA SM100 硬件,并将其集成至 FLASH_MASK_ATTN 后端。

Modifications

  1. 新增 blackwell_ops 包依赖。(未上传,支持 Encoder,Decoder FA4)
  2. 新增 flash_attn_v4 算子 (Encoder FA4)。
  3. flash_attn_v4 算子集成到 flash_mask_attn_backend 中。

Usage or Command

# 安装依赖(需要添加三方包 blackwell_ops,目前暂未上传)
python -m pip install -r requirements.txt 

# 安装 FastDeploy
bash build.sh 1 python false [100]

# 启动服务
export FD_ATTENTION_BACKEND=FLASH_MASK_ATTN

python -m fastdeploy.entrypoints.openai.api_server \
      --model $MODEL_PATH \
      --max-model-len 131072 \
      --max-num-seqs 128 \
      --gpu-memory-utilization 0.9 \
      --tensor-parallel-size 1 \
      --port 8112 \
      --engine-worker-queue-port 8113 \
      --metrics-port 8114 \
      --cache-queue-port 8115 \
      --scheduler-port 8117

Accuracy Tests

[tests/operators/test_flash_mask_attn.py] 中加入正确性验证

image

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

paddle-bot bot commented Mar 25, 2026

Thanks for your contribution!

@paddle-bot paddle-bot bot added the contributor External developers label Mar 25, 2026
@CLAassistant
Copy link

CLAassistant commented Mar 25, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 53.84615% with 6 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@482f951). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...ecutor/layers/attention/flash_mask_attn_backend.py 40.00% 3 Missing ⚠️
...del_executor/layers/attention/ops/flash_attn_v4.py 57.14% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #7016   +/-   ##
==========================================
  Coverage           ?   73.92%           
==========================================
  Files              ?      400           
  Lines              ?    56413           
  Branches           ?     8926           
==========================================
  Hits               ?    41706           
  Misses             ?    11728           
  Partials           ?     2979           
Flag Coverage Δ
GPU 73.92% <53.84%> (?)

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
Collaborator

@RichardWooSJTU RichardWooSJTU left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants