Description
pt.linalg.slogdet cannot be built at all for a batched input, on any backend — this is not backend-specific. slogdet_specialization rewrites Blockwise{Det} into a bare SLogDet, whose make_node asserts x.ndim == 2, so the rewrite fails and the graph then dies on the same assertion.
import numpy as np
import pytensor
import pytensor.tensor as pt
A = pt.tensor("A", shape=(4, 3, 3), dtype="float32")
Av = np.broadcast_to(np.eye(3, dtype="float32") * 2, (4, 3, 3)).copy()
print(pytensor.function([A], pt.linalg.det(A), mode="CVM")(Av)) # [8. 8. 8. 8.]
print(pytensor.function([A], pt.linalg.slogdet(A), mode="CVM")(Av))
# Rewrite failure due to: slogdet_specialization
# node: Blockwise{Det, (m,m)->()}(A)
# File "pytensor/tensor/linalg/summary.py", line 95, in make_node
# assert x.ndim == 2
# AssertionError
Batched det works, so the asymmetry is just that slogdet_specialization does not wrap SLogDet in a Blockwise when the input it matched was itself batched.
Found while fixing #2385 — noting it separately since it is not an MLX issue.
Description
pt.linalg.slogdetcannot be built at all for a batched input, on any backend — this is not backend-specific.slogdet_specializationrewritesBlockwise{Det}into a bareSLogDet, whosemake_nodeassertsx.ndim == 2, so the rewrite fails and the graph then dies on the same assertion.Batched
detworks, so the asymmetry is just thatslogdet_specializationdoes not wrapSLogDetin aBlockwisewhen the input it matched was itself batched.Found while fixing #2385 — noting it separately since it is not an MLX issue.