with_data fails with a list on the jax backend

Aperta
#372 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@RaphaelFakhri ci sta già lavorando.

Dal 5/11/2026.

  • #373 di @RaphaelFakhri — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
numpy, python
Ambito
backend

Direzione di ricerca

Read CompiledPyMCModel.with_data and compare its conversion of new values with the JAX backend's PyFuncModel.with_data, which currently stores values as given. Reproduce the failure with the supplied model and list input, then check that sampling works after the value is handled consistently with the existing NumPy array input. An open linked pull request (#373) already addresses this issue.

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

Descrizione

On a model compiled with backend="jax" (and freeze_model=False), passing a list to with_data makes sampling fail. The numba backend accepts the same call, and the PyMC usage guide shows compiled.with_data(x=[4, 5, 6]).

CompiledPyMCModel.with_data (numba) converts each new value with np.array(new_val, dtype=old_val.dtype). The jax backend returns a PyFuncModel, whose with_data stores the value as given, so the list reaches the jax logp function unchanged.

Reproduction

import numpy as np
import pymc as pm
import nutpie

with pm.Model() as model:
    x = pm.Data("x", np.array([1.0, 2.0, 3.0]))
    beta = pm.Normal("beta")
    pm.Normal("y", mu=beta * x, sigma=0.1, observed=np.array([4.0, 5.0, 6.0]))

compiled = nutpie.compile_pymc_model(model, backend="jax", freeze_model=False)
nutpie.sample(compiled.with_data(x=[4, 5, 6]), chains=1)
RuntimeError: All initialization points failed

Caused by:
    Logp function returned error: ... TypeError("multiply requires ndarray or scalar arguments, got <class 'list'> at position 1.")

The same error occurs with gradient_backend="jax". Passing np.array([4, 5, 6]) works.

Lingua principale
Python
Stelle
214
Fork
30
Merge medio
3h 50m
PR unite (30g)
1

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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/nutpie

Tutte le issue di pymc-devs/nutpie

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.