scan_checkpoints: argument-handling bugs and tests that cannot fail
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 55/100
調査の方向性
Start with pytensor.scan.scan_checkpoints and tests/scan/test_checkpoints.py, especially the referenced setup_method lines. Read the scan handling of non_sequences, until, recurrent outputs, and sequences, then compare its behavior with scan_checkpoints using the reproducers. Fix each listed failure and make the tests assert meaningful non-underflowing values and exercise both return_updates settings.
索引モデルが issue の本文から書いたものです。
説明
-
scan_checkpointsraisesTypeErrorwhennon_sequencesis empty -
scan_checkpointsignoresuntiland returns wrong values -
scan_checkpointsfails whenNoneprecedes a recurrent state inoutputs_info -
scan_checkpointsreplaces entries of the caller'ssequenceslist -
test_checkpoints.pycompares values that underflow to about 1e-64 -
TestScanCheckpointnever builds itsreturn_updates=Falsegraph
reproducers
non_sequences empty:
import pytensor.tensor as pt
from pytensor.scan import scan_checkpoints
x0 = pt.vector("x0")
A = pt.matrix("A")
scan_checkpoints(
lambda x: pt.tanh(A @ x),
outputs_info=[x0],
n_steps=10,
save_every_N=3,
return_updates=False,
)
# TypeError: <lambda>() takes 1 positional argument but 2 were given
until ignored:
import pytensor.tensor as pt
from pytensor.scan import scan, scan_checkpoints, until
x0 = pt.scalar("x0")
A = pt.scalar("A")
def step(x, A):
return x * A, until(x * A > 50)
kwargs = dict(outputs_info=[x0], non_sequences=[A], n_steps=20, return_updates=False)
reference = scan(step, **kwargs)
checkpointed = scan_checkpoints(step, save_every_N=4, **kwargs)
print(reference.eval({x0: 1.0, A: 2.0})) # [ 2. 4. 8. 16. 32. 64.]
print(checkpointed.eval({x0: 1.0, A: 2.0})) # [ 16. 64. 128. 256. 512.]
None before a recurrent state:
import pytensor.tensor as pt
from pytensor.scan import scan_checkpoints
x0 = pt.vector("x0")
A = pt.matrix("A")
def step(x, A):
x_new = pt.tanh(A @ x)
return x_new.sum(), x_new
scan_checkpoints(
step,
outputs_info=[None, x0],
non_sequences=[A],
n_steps=10,
save_every_N=3,
return_updates=False,
)
# ValueError: The initial state ... has 2 dimension(s), while the corresponding
# variable in the result of the inner function of scan (`fn`) has 0 dimension(s)
Caller's sequences list modified:
import pytensor.tensor as pt
from pytensor.scan import scan_checkpoints
s = pt.vector("s")
x0 = pt.scalar("x0")
A = pt.scalar("A")
sequences = [s]
scan_checkpoints(
lambda s_t, x, A: x * A + s_t,
sequences=sequences,
outputs_info=[x0],
non_sequences=[A],
save_every_N=3,
return_updates=False,
)
print(sequences[0] is s) # False
print(sequences[0]) # Join{axis=0}.0
Underflowing test values (test_forward_pass evaluates A**k / k! with A = range(10) and k = 101):
import math
import numpy as np
values = np.array([a**101 / math.factorial(101) for a in range(10)], dtype=float)
print(values.max()) # 2.536e-64
print(np.allclose(values, np.zeros_like(values))) # True
return_updates parametrization: pytest passes the test method as the second argument of setup_method, so return_updates there is always a truthy bound method.
- 主要言語
- Python
- スター
- 655
- フォーク
- 266
- 平均マージ
- 3日 23時間
- マージ済み PR(30日)
- 43
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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)再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 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 日以内に返信