feat: add MagiCompilerBackend with static/dynamic routing#685
Open
fangfangssj wants to merge 2 commits intoPaddlePaddle:developfrom
Open
feat: add MagiCompilerBackend with static/dynamic routing#685fangfangssj wants to merge 2 commits intoPaddlePaddle:developfrom
fangfangssj wants to merge 2 commits intoPaddlePaddle:developfrom
Conversation
Integrate magi_compiler as a new backend for graph_net_bench: - Static path (no sympy dynamic dims): TORCH_COMPILE + inductor via magi_compiler._api._magi_compile_class, bypassing the public API assert that requires non-empty dynamic_arg_dims - Dynamic path (sympy symbols in input_tensor_constraints.py): MAGI_COMPILE piecewise via magi_compiler.magi_compile _load_dynamic_arg_dims reads input_tensor_constraints.py from the model's source directory and extracts only the truly dynamic dims (args whose shape contains sympy.Basic symbols), avoiding ConstraintViolationError caused by magi_compiler's default heuristic marking all tensors as dim-0 dynamic. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks for your contribution! |
lixinqi
approved these changes
Mar 30, 2026
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.
Summary
MagiCompilerBackend,将magi_compiler接入graph_net_bench编译器测试框架input_tensor_constraints.py中无 sympy 动态维度):走TORCH_COMPILE + inductor,通过magi_compiler._api._magi_compile_class绕过公开 API 对非空dynamic_arg_dims的 assertMAGI_COMPILE piecewise,通过magi_compiler.magi_compile正常编译_load_dynamic_arg_dims读取模型目录下的input_tensor_constraints.py,仅提取含sympy.Basic的真实动态维度,避免 magi_compiler 默认启发式将所有 Tensor 标为 dim-0 动态导致的ConstraintViolationErrortest_compiler.py中注册magi_compiler编译器名Test plan
magi_compiler静态路径,status: success,~2.2x speedupmagi_compiler动态路径,status: success🤖 Generated with Claude Code