pullback drops cotangents when f repeats a variable or contains wrt, breaking pushforward
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
The bug is in pullback in pytensor/gradient.py, which keeps one cotangent per repeated variable and lets output cotangents override gradients from other outputs; pushforward in the same module depends on it. Start by running the reproduction snippets in the issue and checking which inputs explicit_graph_inputs returns. Done means all three pushforward cases return both tangents and the pullback cases return every cotangent, without breaking existing gradient tests.
索引モデルが issue の本文から書いたものです。
説明
pytensor.gradient.pushforward drops tangents through Add and Sub, so the directional derivative of a + b depends on only one of the two tangents. The cause is pullback, which keeps only one cotangent per variable when f repeats a variable. It also lets the cotangent of a variable in f override the gradient reaching it through the other outputs. The default pushforward pulls back through a first pullback whose outputs for Add are the output cotangent itself, so it hits both cases.
import pytensor.tensor as pt
from pytensor.gradient import pullback, pushforward
from pytensor.graph.traversal import explicit_graph_inputs
x = pt.dscalar("x")
y_bar_1 = pt.dscalar("y_bar_1")
y_bar_2 = pt.dscalar("y_bar_2")
y = x**2
list(explicit_graph_inputs(pullback([y, y], x, [y_bar_1, y_bar_2]))) # [x, y_bar_2], expected [x, y_bar_1, y_bar_2]
list(explicit_graph_inputs(pullback([x, 2 * x], x, [y_bar_1, y_bar_2]))) # [y_bar_1], expected [y_bar_1, y_bar_2]
a = pt.dscalar("a")
b = pt.dscalar("b")
a_dot = pt.dscalar("a_dot")
b_dot = pt.dscalar("b_dot")
list(explicit_graph_inputs(pushforward(a + b, [a, b], [a_dot, b_dot]))) # [b_dot], expected [a_dot, b_dot]
list(explicit_graph_inputs(pushforward(a - b, [a, b], [a_dot, b_dot]))) # [a_dot], expected [a_dot, b_dot]
list(explicit_graph_inputs(pushforward(a + 2 * b, [a, b], [a_dot, b_dot]))) # [a_dot], expected [a_dot, b_dot]
This came up while computing sparse Jacobians from colored pushforwards for #2578.
- 主要言語
- Python
- スター
- 654
- フォーク
- 258
- 平均マージ
- 3日 41分
- マージ済み PR(30日)
- 42
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pymc-devs/pytensor のほかの issue
-
Docs of mode still mentions C/CVM as the default with FAST_RUN対応中かも @ADITYASINGH1206 が 8 日前に担当しました。 オープンdocs
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
pymc-devs/pytensor#2641 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
docs
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
BUG: geomspace returns wrong sign for the endpoints when start and stop are negative対応中かも @mayuriphad が 27 日前に担当しました。 オープン
難易度 2/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
Reciprocal.impl computes np.float32(1.0) / x: float32 precision for float64 scalars under NEP 50 (Python linker)再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
pymc-devs/pytensor#2430 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
pymc-devs/pytensor#2428 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
pymc-devs/pytensor の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
dgunning/edgartools#2019 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
topoteretes/cognee#6818 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
source_verification_agent: no outcome when the publisher confirms a work but its DOI resolves to a different record対応中かも @pinjun99 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Imbad0202/academic-research-skills#1159 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: DoubleMLData.from_arrays checks the treatment d with force_all_x_finite instead of force_all_d_finite対応中かも @leninworld が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
DoubleML/doubleml-for-py#471 ·
メンテナーはふだん 1 日以内に返信