Skip to content

[Graph Optimization][BugFix][CI] Fix 0size bug && add unitest#5495

Merged
DrRyanHuang merged 5 commits intoPaddlePaddle:developfrom
cattidea:add_sot_cinn_unitest_and_opt_level_up_to_2
Dec 11, 2025
Merged

[Graph Optimization][BugFix][CI] Fix 0size bug && add unitest#5495
DrRyanHuang merged 5 commits intoPaddlePaddle:developfrom
cattidea:add_sot_cinn_unitest_and_opt_level_up_to_2

Conversation

@DrRyanHuang
Copy link
Collaborator

@DrRyanHuang DrRyanHuang commented Dec 10, 2025

Motivation

#5078 导致所有 SOT+CUDAGraph 模型启动失败:

if ids_remove_padding.shape[0] == 0:
return paddle.empty([0, self.embedding_dim], dtype=self.embeddings.weight.dtype)

上面的 .shape[0] == 0 会引入一个 memcpy_h2d 操作,导致 CUDAGraph 无法启动

目前可通过 forward_meta.is_zero_size 规避

if forward_meta is not None and forward_meta.is_zero_size:
    return paddle.empty([0, self.embedding_dim], dtype=self.embeddings.weight.dtype)

Caution

当前PR只是一个临时解决方案,当输入真的是 0 size 的时候,SOT会重新组网,虽然不会打断,但会存在两张整图
由于我们之前做过约束,仅允许存在一张图,FastDeploy 会直接报错退出
由于目前非 EP 场景不存在 0 size输入,而SOT也没有开始适配EP场景,所以目前无需担心
后续需要分布式算子支持0size输入,之后再移除 ForwardMeta 中的 is_zero_size

Modifications

  • 添加单测 test_EB_Lite_sot_serving 添加到 base 的 yaml 中了
  • 修改单测 test_EB_VL_Lite_sot_serving 启动参数,graph_opt_level = 2 SOT => CINN
  • ForwardMeta 添加 is_zero_size

Usage or Command

python -m fastdeploy.entrypoints.openai.api_server \
       --model $MODEL \
       --port $PORT \
       --metrics-port $MPPPPP \
       --engine-worker-queue-port $EWQPPP \
       --tensor-parallel-size 1 \
       --max-model-len 32768 \
       --max-num-seqs 128 \
       --graph-optimization-config '{"graph_opt_level":2, "use_cudagraph":true}' \
       --quantization wint4 \
       --enable-mm \
       --max-num-batched-tokens 172 \
       --enable-chunked-prefill \
       --kv-cache-ratio 0.71 \
       --quantization wint4 \
       --reasoning-parser ernie-45-vl 

Accuracy Tests

NO NEED

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 Dec 10, 2025

Thanks for your contribution!

@codecov-commenter
Copy link

codecov-commenter commented Dec 10, 2025

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@9f4512c). Learn more about missing BASE report.

Files with missing lines Patch % Lines
fastdeploy/model_executor/layers/embeddings.py 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #5495   +/-   ##
==========================================
  Coverage           ?   60.27%           
==========================================
  Files              ?      329           
  Lines              ?    41116           
  Branches           ?     6261           
==========================================
  Hits               ?    24784           
  Misses             ?    14443           
  Partials           ?     1889           
Flag Coverage Δ
GPU 60.27% <80.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.

SigureMo
SigureMo previously approved these changes Dec 10, 2025
Copy link
Collaborator

@gongshaotian gongshaotian left a comment

Choose a reason for hiding this comment

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

LGTM

@DrRyanHuang DrRyanHuang merged commit e58fed3 into PaddlePaddle:develop Dec 11, 2025
15 of 17 checks passed
@DrRyanHuang DrRyanHuang deleted the add_sot_cinn_unitest_and_opt_level_up_to_2 branch December 11, 2025 08:25
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