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

Abierto
#2,686 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@Sahilkumar-r ya está trabajando en esto.

Desde el 18/11/2026.

  • #2688 de @Sahilkumar-r — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
python

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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)
Lenguaje dominante
Python
Estrellas
654
Forks
258
Merge medio
2 d 7 h
PR fusionados (30 d)
39

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de pymc-devs/pytensor

Todos los issues de pymc-devs/pytensor

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.