Skip to content

Conversation

SigureMo
Copy link
Member

@SigureMo SigureMo commented Apr 24, 2025

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,以满足各方需求

… as unified in dynamic and static mode and support custom op
@SigureMo SigureMo requested review from zrr1999 and gouzil as code owners April 24, 2025 19:31
Copy link

paddle-bot bot commented Apr 24, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@SigureMo SigureMo requested review from Copilot and removed request for zrr1999 and gouzil April 24, 2025 19:31
Copy link
Contributor

@Copilot Copilot AI left a 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:

@SigureMo SigureMo requested review from zrr1999 and gouzil April 24, 2025 19:32
zyfncg
zyfncg previously approved these changes Apr 25, 2025
return skip_transform(func, sot=False, ast=True)


def skip_transform(
Copy link
Contributor

Choose a reason for hiding this comment

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

skip_transform这个词和yaml里的配置同名了,会不会对用户产生一些干扰?

Copy link

paddle-ci-bot bot commented May 10, 2025

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
@SigureMo SigureMo changed the title [SOT] Add new internal API paddle.jit.skip_transform to mark an API as unified in dynamic and static mode and support custom op [SOT] Add new internal API paddle.jit.marker.unified to mark an API as unified in dynamic and static mode and support custom op May 19, 2025
@SigureMo SigureMo requested a review from Copilot May 19, 2025 09:00
Copy link
Contributor

@Copilot Copilot AI left a 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(
Copy link
Preview

Copilot AI May 19, 2025

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.

SigureMo and others added 2 commits May 19, 2025 17:12
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@SigureMo SigureMo merged commit 21a4207 into PaddlePaddle:develop May 20, 2025
50 checks passed
@SigureMo SigureMo deleted the sot/add-new-internal-api-to-mark-an-api-as-unified-in-dygraph-and-static-mode-and-support-custom-op branch May 20, 2025 02:23
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 98.50746% with 1 line in your changes missing coverage. Please review.

Please upload report for BASE (develop@e902afd). Learn more about missing BASE report.

Files with missing lines Patch % Lines
python/paddle/jit/dy2static/utils.py 95.83% 1 Missing ⚠️
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.
📢 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.

co63oc pushed a commit to co63oc/Paddle that referenced this pull request May 22, 2025
… as unified in dynamic and static mode and support custom op (PaddlePaddle#72466)

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

4 participants