Numba multivariate_normal raises LinAlgError on a NaN covariance

Aperta
#2,576 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
numpy, python

Direzione di ricerca

Start by reading the Numba dispatch for pt.random.multivariate_normal and the Numba linalg Ops for SVD, eigenvalue decomposition, and Cholesky; compare their behavior on the NaN covariance shown in the issue with the JAX and Python backends. Check the existing tests for these methods and backends. Done means the Numba behavior matches the expected NaN results for each method without breaking finite covariance cases.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

linalg numba random variables

pt.random.multivariate_normal raises LinAlgError under the numba backend when its covariance contains NaN, for every method. JAX returns NaN draws, and so do the numba linalg Ops on the same input. The numba dispatch factors the covariance with numba's np.linalg.svd, eigh or cholesky, which raise on non-finite input. The Python backend follows numpy, which raises for svd and cholesky and returns NaN for eigh.

import numpy as np
import pytensor
import pytensor.tensor as pt

cov = pt.matrix("cov")
nan_cov = np.full((2, 2), np.nan)

for method in ["svd", "eigh", "cholesky"]:
    draw = pt.random.multivariate_normal(np.zeros(2), cov, method=method)
    print(pytensor.function([cov], draw, mode="JAX")(nan_cov))  # [nan nan]
    pytensor.function([cov], draw, mode="NUMBA")(nan_cov)  # LinAlgError

print(pytensor.function([cov], pt.linalg.svd(cov, compute_uv=False), mode="NUMBA")(nan_cov))  # [nan nan]
Lingua principale
Python
Stelle
654
Fork
258
Merge medio
2g 7h
PR unite (30g)
39

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pymc-devs/pytensor

Tutte le issue di pymc-devs/pytensor

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.