PaddlePaddle / PaddlePaddle/Paddle
`paddle.jit.to_static(full_graph=True)` aborts on `program_guard` with `paddle.equal`
Open
@huangjiyi is already working on this.
Since Jul 13, 2026.
- Dominant language
- C++
- Stars
- 24.1k
- Forks
- 6k
- Avg merge
- 4d 17h
- Merged PRs (30d)
- 60
Description
bug描述 Describe the Bug
The following function works in eager mode, but wrapping the same function with paddle.jit.to_static(..., full_graph=True) aborts the Python process.
The failure happens when paddle.static.program_guard is used together with paddle.equal inside the converted function. Even if this mixed static/eager pattern is unsupported, the process should not abort. It would be better to raise a normal Python-level error explaining that this usage is unsupported.
Minimal reproduction
import os
os.environ.setdefault("FLAGS_enable_pir_api", "1")
import paddle
def fn(x):
main_program = paddle.static.Program()
startup_program = paddle.static.Program()
with paddle.static.program_guard(main_program, startup_program):
y = paddle.equal(x, paddle.zeros_like(x))
return y, paddle.count_nonzero(y)
x = paddle.to_tensor([[0.0, 1.0], [2.0, 0.0]], dtype="float32")
print("paddle", paddle.__version__, flush=True)
print("eager:", [t.numpy().tolist() for t in fn(x)], flush=True)
static_fn = paddle.jit.to_static(fn, full_graph=True)
out = static_fn(x)
print("static:", [t.numpy().tolist() for t in out], flush=True)
Observed output
paddle 3.3.1
eager: [[[True, False], [False, True]], 2]
EXIT_CODE=-1073740791
W0603 23:21:21.354051 12940 eager_utils.cc:3584] Paddle static graph(PIR) not support input out tensor for now!!!!!
Destroyed a op_result that is still in use by pd_op.cast. The owner op type is: pd_op.equal (at ..\paddle\pir\src\core\op_result_impl.cc:37)
其他补充信息 Additional Supplementary Information
Paddle Version: 3.3.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.