with_data fails with a list on the jax backend

Open
#372 0 comments 0 reactions 0 assignees View on GitHub

@RaphaelFakhri is already working on this.

Since Nov 5, 2026.

  • #373 by @RaphaelFakhri — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
numpy, python
Domain
backend

Research direction

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.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Python
Stars
214
Forks
31
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pymc-devs/nutpie

All issues in pymc-devs/nutpie

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.