[Graph Optimization][CINN] Use CINN in PaddleOCR-VL ViT part#5223
Merged
SigureMo merged 18 commits intoDec 9, 2025
Conversation
|
Thanks for your contribution! |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #5223 +/- ##
==========================================
Coverage ? 60.04%
==========================================
Files ? 329
Lines ? 40980
Branches ? 6210
==========================================
Hits ? 24606
Misses ? 14517
Partials ? 1857
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
本 PR 为 PaddleOCR-VL 模型的 ViT 编码器部分引入了 CINN 编译支持,通过图优化提升推理性能。主要实现了三级图优化策略:level 0(纯动态图+fused ops)、level 1(SOT 动转静+native ops)、level 2(CINN 编译+native ops),其中 CINN 模式在性能测试中相比动态图有 12-37% 的提升。
- 将
SiglipEncoder的循环部分提取为_run_encoder_layer方法,支持to_static装饰和 CINN 编译 - 为 vision encoder 添加 warmup 逻辑和编译流程,目前仅支持 PaddleOCR-VL 模型
- 扩展端到端测试以覆盖动态图和 CINN 两种模式
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/e2e/test_paddleocr_vl_serving.py | 参数化测试以覆盖 graph_opt_level 0 和 2 两种配置 |
| fastdeploy/worker/model_runner_base.py | 添加 vision_encoder_compile 基类方法 |
| fastdeploy/worker/gpu_worker.py | 在 warm-up 流程中集成 vision encoder 编译 |
| fastdeploy/worker/gpu_model_runner.py | 实现 vision encoder 的 CINN 编译和 warmup 逻辑 |
| fastdeploy/model_executor/models/paddleocr_vl/siglip_ops.py | 添加动态形状处理和统一标记以支持静态图编译 |
| fastdeploy/model_executor/models/paddleocr_vl/siglip.py | 重构编码器,提取 _run_encoder_layer 用于 CINN 编译 |
| fastdeploy/engine/engine.py | 添加 SOT_ENABLE_COMPILE_TIME_LIMIT 环境变量 |
| fastdeploy/engine/async_llm.py | 添加 SOT_ENABLE_COMPILE_TIME_LIMIT 环境变量 |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
zyfncg
approved these changes
Dec 9, 2025
5 tasks
chang-wenbin
pushed a commit
to chang-wenbin/FastDeploy
that referenced
this pull request
Mar 2, 2026
…addle#5223) --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
xiaoguoguo626807
pushed a commit
to xiaoguoguo626807/FastDeploy
that referenced
this pull request
May 7, 2026
…addle#5223) --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
使用 CINN 加速 PaddleOCR ViT 部分,对其中
_run_encoder_layer装饰to_staticModifications
to_static装饰tests/e2e/test_paddleocr_vl_serving.py同时测动态图+CINNUsage or Command
目前开启 compile 与 LLM 部分方式相同:
graph_opt_level=0纯动态图,走 fused opsgraph_opt_level=1SOT 动转静,走 native ops,性能有所下降graph_opt_level=2CINN,走 native ops + CINN fusion,性能与 fused ops 持平且略有超越python -m fastdeploy.entrypoints.openai.api_server \ --model /root/paddlejob/tmpspace/MODELS/PaddlePaddle/PaddleOCR-VL \ --port 8295 \ --metrics-port 8296 \ --engine-worker-queue-port 8297 \ --cache-queue-port 55660 \ --max-model-len 16384 \ --max-num-batched-tokens 16384 \ --gpu-memory-utilization 0.7 \ --max-num-seqs 256 \ --workers 2 \ --graph-optimization-config '{"graph_opt_level":2, "use_cudagraph":true}'Accuracy Tests
无
Checklist
[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]]pre-commitbefore commit.releasebranch, make sure the PR has been submitted to thedevelopbranch, then cherry-pick it to thereleasebranch with the[Cherry-Pick]PR tag.