CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[SOT][Exception] breakgraph when using random.*
#73038
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
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
python/paddle/jit/sot/opcode_translator/executor/variables/callable.py
Outdated
Show resolved
Hide resolved
def __is_random_function(value) -> bool: | ||
import random | ||
|
||
return value.__qualname__ in [ |
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.
确认下,所有 value 都有 __qualname__
么?
>>> object().__qualname__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'object' object has no attribute '__qualname__'
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.
在这里搜了下看看:https://docs.python.org/3/reference/datamodel.html
所有的 function 和 type 都有 __qualname__
另外PEP3155,也说说明了在类和函数中添加 __qualname__
This PEP proposes the addition of a qualname attribute to functions and classes. For top-level functions and classes, the qualname attribute is equal to the name attribute. For nested classes, methods, and nested functions, the qualname attribute contains a dotted path leading to the object from the module top-level. A function’s local namespace is represented in that dotted path by a component named .
咱们的 from_value 部分有限制value是函数:
def from_value(value: Any, graph: FunctionGraph, tracker: Tracker):
if isinstance(value, (types.FunctionType)):
return UserDefinedFunctionVariable(value, graph, tracker)
if isinstance(
value, paddle.jit.dy2static.program_translator.StaticFunction
):
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.
记得加一下 PR 描述 |
@@ -250,6 +252,10 @@ def handle_psdb_function(self, /, *args, **kwargs): | |||
return None | |||
|
|||
def call_function(self, /, *args, **kwargs) -> VariableBase: | |||
if UserDefinedFunctionVariable.__is_random_function(self.value): |
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.
后续考虑统一到 #73059 的 force break 形式
PR Category
Execute Infrastructure
PR Types
Improvements
Description
之前在
import random
之后,由于存在try ... except ...
,所以导入 random 会 fallback现在SOT异常支持后,在模拟 random 中的函数导入,由于random的部分函数,都是实例
_inst = Random()
的方法所以此时使用 random 中的函数会报:
在执行:
所以目前现将
random.*
函数全部打断cc @SigureMo
PCard-66972