Context
PyMC 5.28 + PyTensor 2.38 + NumPy 2.4 have a compatibility bug where pm.LKJCholeskyCov and pm.LKJCorr fail with:
ValueError: not enough values to unpack (expected 5, got 3)
in pytensor/tensor/einsum.py. The einsum_path returns 3-tuples but PyTensor expects 5-tuples.
Current workaround
src/litterman/spec.py uses a manual Cholesky parameterization instead:
sd = pm.HalfCauchy("sigma_sd", beta=2.5, shape=n_vars)
L = pt.zeros((n_vars, n_vars))
L = pt.set_subtensor(L[np.diag_indices(n_vars)], sd)
if n_tril > 0:
tril_vals = pm.Normal("tril_offdiag", mu=0, sigma=0.5, shape=n_tril)
# fill lower triangle manually
What needs to happen
- Monitor PyMC/PyTensor releases for a fix to the LKJ einsum bug
- Once fixed, replace manual Cholesky with
pm.LKJCholeskyCov for cleaner parameterization
- Test that the LKJ version produces equivalent posteriors
Labels
tech-debt, upstream-dependency
Context
PyMC 5.28 + PyTensor 2.38 + NumPy 2.4 have a compatibility bug where
pm.LKJCholeskyCovandpm.LKJCorrfail with:in
pytensor/tensor/einsum.py. Theeinsum_pathreturns 3-tuples but PyTensor expects 5-tuples.Current workaround
src/litterman/spec.pyuses a manual Cholesky parameterization instead:What needs to happen
pm.LKJCholeskyCovfor cleaner parameterizationLabels
tech-debt, upstream-dependency