[SOT] Dont use get_py_value
from Tensor default in MAKE_FUNCTION
to avoid breakgraph
#71048
+23
−1
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.
PR Category
Execute Infrastructure
PR Types
Bug fixes
Description
同 #71040 是在 DiT 上发现的问题
目前在 make function 且有 kwdefault 的情况下,如果默认值包含 tensor,会因为直接
get_py_value
触发BreakGraphError
而挂掉,因为MAKE_FUNCTION
并没有捕获BreakGraphError
,导致抛到了最外层但因为
MAKE_FUNCTION
自身的特殊性,在 python 3.13 下是MAKE_FUNCTION
后跟随若干SET_FUNCTION_ATTRIBUTE
实现的,如果在MAKE_FUNCTION
处打断,可能会产生一个非法的 Function(在 python 端还不确定),因此此处打断可能不太行不过这里注意到在之前的实现里,只有 kwdefault 会有问题,普通的 default 没有问题,因为该分支使用了
get_wrapped_items
,将 Variable 作为生成函数的 defaults,这样做在大多数情况没有问题,因为这个函数会 inline call,后面这些 defaults 也会转成 Variable因此在 kwdefault 里也用
get_wrapped_items
,但从长期来看,仍然是将FunctionVariable
表示改为持有多个 Variable 的形式(含 code、closure 等对应的 Variable),使得MAKE_FUNCTION
不可能发生 BreakGraph,因为只是 Variable 的组合,这样才是理想的状态PCard-66972