Numba multivariate_normal raises LinAlgError on a NaN covariance

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

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

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
58/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
numpy, python

調査の方向性

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.

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

説明

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]
主要言語
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 を短くまとめたダイジェスト。