Skip to content

Make pymc an optional dependency — install fails on macOS x86_64 due to dependency conflicts #1835

@jahma

Description

@jahma

Bug Description

A fresh pip install sbi (v0.26.0) fails on macOS x86_64 (Intel Mac) due to a cascade of dependency conflicts rooted in pymc being a hard dependency.

Related: #1816 (arviz breaking changes), #1626 (numpy 2.0 problems). This issue is about the broader problem that pymc (and its heavy transitive deps) shouldn't be required for the common case.

Steps to Reproduce

conda create -n sbi python=3.11 -y
conda run -n sbi pip install sbi

Failure 1: llvmlite build error

sbi -> arviz -> numba -> llvmlite, and llvmlite fails to build from source on macOS x86_64 (no pre-built wheel). This blocks installation entirely.

Failure 2: numpy 1.x vs 2.x conflict (after working around llvmlite)

Even after getting everything installed:

  • torch 2.2.2 (latest available on x86_64 macOS via pip) was compiled against numpy 1.x
  • pytensor >= 2.28 (required by pymc >= 5.28) requires numpy 2.x
  • Result: either torch crashes ("_ARRAY_API not found") or pytensor crashes ("No module named numpy.lib.array_utils")

Failure 3: Eager import of pymc blocks all of sbi

Even if a user only needs NPE (amortized inference, no MCMC), from sbi.inference import NPE triggers:

inference -> posteriors -> mcmc_posterior -> samplers.mcmc -> pymc_wrapper -> import pymc

So pymc is a hard runtime dependency for all users, not just those using PyMC-based MCMC.

Suggestion

  1. Make pymc an optional/extras dependency (e.g. pip install sbi[mcmc]). Most sbi users don't need PyMC-based samplers.
  2. Lazy-import pymc inside PyMCSampler rather than at module level in pymc_wrapper.py, so that import sbi works without pymc installed.
  3. This would also resolve SBI Dependency Arviz Introduced Breaking Changes #1816 since arviz is only pulled in transitively via pymc.

Environment

  • macOS 13.x, x86_64 (Intel)
  • Python 3.11.13 (conda)
  • sbi 0.26.0 (from git main)
  • torch 2.2.2 (latest available for this platform)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions