inplace_elemwise retries an input it already rejected, once per Elemwise output
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 半天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
- 领域
- compilers, performance
调研方向
The retry loop is in InplaceGraphOptimizer.try_inplace_on_node, which calls tried_inputs.discard(i) after an InconsistencyError; the inplace_elemwise rewrite in pytensor/tensor/rewriting/elemwise.py drives it. Run the 400-output snippet with the py linker and time it, then compare against the excluded-rewrite run. Done when compile time drops substantially and the in-place node count in the test suite is unchanged.
由索引模型根据 Issue 内容生成。
描述
inplace_elemwise, the rewriter that lets Elemwise nodes overwrite their inputs, takes time close to cubic in the number of outputs of a fused Elemwise whose inputs can't be destroyed. When an attempt raises InconsistencyError, InplaceGraphOptimizer.try_inplace_on_node calls tried_inputs.discard(i) and offers the same input to the next output. Every reason DestroyHandler rejects a destroy depends on the input, not the output, so each retry fails, and each one replaces and reverts all of the node's outputs.
import time
import pytensor
import pytensor.tensor as pt
from pytensor.compile.mode import Mode
x = pt.matrix("x", shape=(7, 7))
X = x @ x
outputs = [pt.exp(X + k) for k in range(400)] # fused into one Elemwise with 400 outputs
y = pt.join(0, X, *outputs) # reads X and every output, so X can't be destroyed
start = time.perf_counter()
pytensor.function([x], y, mode=Mode(linker="py", optimizer="fast_run"))
print(f"{time.perf_counter() - start:.1f} s") # 13.1 s
# workaround: Mode(linker="py", optimizer="fast_run").excluding("inplace_elemwise") compiles in 0.4 s
inplace_elemwise alone takes 0.07, 0.38, 2.15 and 13.8 s at 50, 100, 200 and 400 outputs. In a real graph with a 364-output Elemwise feeding a 1114-input Scan, rewriting took 66 s. With the retry removed it took 30 s, and the compiled graph had the same 1369 nodes and 210 in-place nodes.
- 主要语言
- Python
- 星标
- 655
- 派生
- 266
- 平均合并
- 3 天 23 小时
- 30 天内合并 PR
- 43
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pymc-devs/pytensor 的其他 Issue
-
BUG: cumsum and cumprod keep bool and small integer dtypes, so cumsum(x > 0) is wrong可能已有人在做 @rishabhsai 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
Docs of mode still mentions C/CVM as the default with FAST_RUN可能已有人在做 @ADITYASINGH1206 于 13 天前认领。 未关闭docs
难度 2/5 1-3 小时 新手友好度 62/100
pymc-devs/pytensor#2641 · 1 条评论 ·
维护者通常 1 天内回复
-
Update conditions page in docs可能已有人在做 @caxaxa 于 3 天前认领。 未关闭docs
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
BUG: geomspace returns wrong sign for the endpoints when start and stop are negative可能已有人在做 @mayuriphad 于 32 天前认领。 未关闭
难度 2/5 1 小时以内 新手友好度 85/100
维护者通常 1 天内回复
-
Reciprocal.impl computes np.float32(1.0) / x: float32 precision for float64 scalars under NEP 50 (Python linker)可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
pymc-devs/pytensor#2430 · 1 条评论 ·
维护者通常 1 天内回复
查看 pymc-devs/pytensor 的全部 Issue
相似的 Issue
-
triage
难度 1/5 1-3 小时 新手友好度 88/100
kornia/kornia-rs#1416 · 1 条评论 ·
维护者通常 2 天内回复
-
ui
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
PolicyEngine/ai-inequality#64 ·
维护者通常 1 天内回复
-
LinearGaussianStateSpace.dist splits states and observations wrongly when the transition varies over time可能已有人在做 @PabloRoque 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
pymc-devs/pymc-extras#839 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复