xtensor vectorize_graph raises max() iterable argument is empty when new_tensor_dims is given but no replacement is a plain tensor
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Start in pytensor/xtensor/vectorization.py near line 602, where vectorize_graph calls broadcast_shape with new_tensor_dim_lengths, which is empty when no plain tensor replacement exists. Run the two calls in the issue's snippet to reproduce the ValueError. The issue leaves open whether to skip the broadcast or raise a clearer error, so confirm the choice with maintainers before editing. Done means the chosen behaviour is implemented and a test covers new_tensor_dims with only xtensor replacements.
索引モデルが issue の本文から書いたものです。
説明
pytensor.xtensor.vectorization.vectorize_graph raises an unhelpful error when new_tensor_dims is not empty and every replacement is an XTensorVariable:
import numpy as np
from pytensor.xtensor import xtensor_constant
from pytensor.xtensor.type import xtensor
from pytensor.xtensor.vectorization import vectorize_graph
x = xtensor("x", dims=("date",), shape=(3,))
new = xtensor_constant(np.ones((4, 3)), dims=("sample", "date"))
vectorize_graph(x * 2.0, replace={x: new}) # dims ("sample", "date"), fine
vectorize_graph(x * 2.0, replace={x: new}, new_tensor_dims=("sample",))
# ValueError: max() iterable argument is empty
With new_tensor_dims set, vectorize_graph calls broadcast_shape(*new_tensor_dim_lengths, arrays_are_shapes=True) (pytensor/xtensor/vectorization.py:602), and new_tensor_dim_lengths only collects the batch shapes of plain tensor replacements. With none, it is empty, and broadcast_shape_iter fails on max().
Found in pymc-labs/pymc-marketing#3402, where extract_response_distribution replaces posterior variables declared with pymc.dims by xtensors and those declared with pymc by plain tensors. A model can have either kind or both, so the call passes new_tensor_dims=("sample",) only when at least one replacement is a plain tensor.
Should vectorize_graph skip the broadcast when there are no tensor replacements (the names then match nothing), or raise a ValueError that says new_tensor_dims was given without a tensor replacement?
PyTensor 3.3.8; vectorization.py is the same on main (daafd793).
- 主要言語
- 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 日以内に返信