Assumption handler for Eye fails on a Blockwise Eye: unpacks batched output shape

オープン
#2,686 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Sahilkumar-r がすでに取り組んでいます。

2026年11月18日 から。

  • #2688 @Sahilkumar-r による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python

調査の方向性

Start with pytensor/assumptions/selection.py and the _eye handler; compare its shape unpacking with the delegation in pytensor/assumptions/blockwise.py. Reproduce the issue with the vectorized example in the report, then check that compiling it no longer logs the rewrite failure. Pull request #2688 is already open against this issue.

索引モデルが issue の本文から書いたものです。

説明

assumptions bug vectorization

Compiling a vectorized graph that adds pt.identity_like to a matrix before cholesky and cho_solve logs a rewrite failure from orthogonal_solve_to_transpose_matmul. The Blockwise handler in pytensor/assumptions/blockwise.py hands the batched node to the core Eye handler, _eye. That handler does rows, cols = node.outputs[0].type.shape, which raises ValueError on the 3D output.

import pytensor
import pytensor.tensor as pt


def jittered_cho_solve(F, v):
    L = pt.linalg.cholesky(F + pt.identity_like(F) * 1e-8)
    return pt.linalg.cho_solve((L, True), v)


F = pt.tensor("F", shape=(4, 2, 2))
v = pt.tensor("v", shape=(4, 2))
out = pt.vectorize(jittered_cho_solve, signature="(p,p),(p)->(p)")(F, v)
pytensor.function([F, v], out)  # logs "Rewrite failure due to: orthogonal_solve_to_transpose_matmul"
traceback
Rewrite failure due to: orthogonal_solve_to_transpose_matmul
node: Blockwise{CholeskySolve{lower=True, b_ndim=1, overwrite_b=False}, (m,m),(m)->(m)}(Blockwise{Cholesky{lower=True, overwrite_a=False}, (m,m)->(m,m)}.0, v)
TRACEBACK:
Traceback (most recent call last):
  ...
  File ".../pytensor/assumptions/blockwise.py", line 11, in _blockwise_delegate
    return infer_assumption_for_node(
  File ".../pytensor/assumptions/core.py", line 411, in infer_assumption_for_node
    output_states = fn(key, op, feature, fgraph, node, input_states)
  File ".../pytensor/assumptions/selection.py", line 89, in _eye
    rows, cols = node.outputs[0].type.shape
ValueError: too many values to unpack (expected 2, got 3)
主要言語
Python
スター
654
フォーク
258
平均マージ
2日 7時間
マージ済み PR(30日)
39

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pymc-devs/pytensor のほかの issue

pymc-devs/pytensor の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。