CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[SOT] Add new internal API paddle.jit.marker.unified
to mark an API as unified in dynamic and static mode and support custom op
#72466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SOT] Add new internal API paddle.jit.marker.unified
to mark an API as unified in dynamic and static mode and support custom op
#72466
Conversation
… as unified in dynamic and static mode and support custom op
你的PR提交成功,感谢你对开源项目的贡献! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new internal API—paddle.jit.skip_transform—to mark APIs as unified between dynamic and static modes and to support custom op generation for SOT. In addition, the changes replace the less‐clear paddle.jit.not_to_static with the new API, add a TransformOptions mechanism (with ToStaticMode flags for SOT and AST) for finer control, and update tests to verify the new behavior.
- Updated tests in dygraph_to_static to call not_to_static() as a decorator using the new skip_transform behavior.
- Modified API functions (e.g. in paddle/jit/api.py) to delegate not_to_static to skip_transform.
- Extended utility modules (e.g. in paddle/jit/dy2static/utils.py) with TransformOptions for transformation mode checks.
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
File | Description |
---|---|
test/dygraph_to_static/test_convert_call.py | Updated tests to use the new skip_transform API via not_to_static() wrapper and renamed test methods accordingly. |
python/paddle/jit/api.py | Updated the implementation of not_to_static to call skip_transform and removed the ConversionOptions usage. |
python/paddle/jit/dy2static/utils.py | Introduced TransformOptions and ToStaticMode flags; added check_fn_need_transform to drive transformation decisions. |
Comments suppressed due to low confidence (3)
test/dygraph_to_static/test_convert_call.py:229
- Ensure that the test accurately reflects the new skip_transform behavior by verifying both SOT and AST modes are handled as expected; consider adding inline comments to clarify that not_to_static is now a wrapper around skip_transform.
paddle.jit.not_to_static()(self.net.sum)
python/paddle/jit/api.py:404
- [nitpick] Consider updating the docstring for not_to_static to clarify that it now uses skip_transform internally and to explain the meaning of configuring sot=False and ast=True.
return skip_transform(func, sot=False, ast=True)
python/paddle/jit/dy2static/utils.py:111
- [nitpick] Consider adding more detailed inline documentation within the TransformOptions class to clarify how the ToStaticMode flags (SOT and AST) control function transformation behavior.
class TransformOptions:
python/paddle/jit/api.py
Outdated
return skip_transform(func, sot=False, ast=True) | ||
|
||
|
||
def skip_transform( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skip_transform这个词和yaml里的配置同名了,会不会对用户产生一些干扰?
Sorry to inform you that 1b7facc's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
…s-unified-in-dygraph-and-static-mode-and-support-custom-op
paddle.jit.skip_transform
to mark an API as unified in dynamic and static mode and support custom oppaddle.jit.marker.unified
to mark an API as unified in dynamic and static mode and support custom op
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request introduces a new internal API “paddle.jit.marker.unified” to mark functions as already unified between dynamic and static modes, replacing the older “not_to_static” mechanism. The changes update several modules to use the new TransformOptions flag system and unified marker, update test cases accordingly, and remove legacy conversion options.
- Updated test cases to verify the new transform options behavior.
- Modified code paths in various modules (dy2static, opcode translator, utils, and API) to rely on the new unified marker.
- Removed the legacy ConversionOptions and not_to_static decorator in favor of the unified marker.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
test/dygraph_to_static/test_convert_call.py | Updated tests to use the new TransformOptions checks and adjusted not_to_static usage. |
python/paddle/utils/cpp_extension/extension_utils.py | Imported and applied the new unified marker in custom API generation. |
python/paddle/jit/sot/utils/utils.py | Added already_unified_in_dynamic_and_static_graph helper for unified behavior. |
python/paddle/jit/sot/utils/init.py | Exported the new already_unified_in_dynamic_and_static_graph function. |
python/paddle/jit/sot/opcode_translator/executor/variables/callable.py | Replaced is_paddle_api with the unified check to determine API wrapping. |
python/paddle/jit/sot/opcode_translator/executor/function_graph.py | Updated assertion to check unified status instead of legacy paddle API check. |
python/paddle/jit/marker.py | Introduced the new unified marker API along with a legacy not_to_static alias. |
python/paddle/jit/dy2static/utils.py | Refactored TransformOptions implementation with a Flag for transformation modes. |
python/paddle/jit/dy2static/program_translator.py | Updated static conversion check to use the new TransformOptions. |
python/paddle/jit/dy2static/convert_call_func.py | Modified conversion logic to use TransformOptions and removed legacy ConversionOptions. |
python/paddle/jit/api.py | Removed legacy not_to_static in favor of the marker version imported from marker. |
python/paddle/jit/init.py | Reorganized imports to align with the new marker API. |
Comments suppressed due to low confidence (1)
python/paddle/jit/dy2static/convert_call_func.py:241
- [nitpick] The log message still refers to 'paddle.jit.not_to_static' even though the new unified behavior is in use. Update the message to reflect the new marker API for consistency.
translator_logger.log(2, "%s is not converted when it is decorated by 'paddle.jit.not_to_static'.",
return unified(func, for_sot=False, for_ast=True) | ||
|
||
|
||
def unified( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The docstring for the 'unified' function could be expanded to explain in more detail the roles of the 'for_sot' and 'for_ast' parameters. This would help clarify how to use the API effectively.
Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #72466 +/- ##
==========================================
Coverage ? 98.50%
==========================================
Files ? 9
Lines ? 67
Branches ? 0
==========================================
Hits ? 66
Misses ? 1
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
… as unified in dynamic and static mode and support custom op (PaddlePaddle#72466) --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
PR Category
Execute Infrastructure
PR Types
New features
Description
为 SOT 添加 API
paddle.jit.marker.unified
,用于标记 API 本就是动静统一的,不需要 trace 进去,AST 同样,后续会替换掉语义不清晰的paddle.jit.not_to_static
,本 PR 不推动公开,后续会设计好之后再推进该 API 公开另外将其用在了生成的自定义算子函数上,确保 SOT 模拟过程中不会发生打断
SOT 后续会继续提供一系列 API,以满足各方需求