diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5ab1d1b..e35ef8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,3 @@ -# This file is autogenerated by maturin v1.8.2 -# To update, run -# -# maturin generate-ci --pytest --platform all --zig github -# name: CI on: @@ -31,16 +26,32 @@ jobs: target: aarch64 steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: "3.12" - name: Install uv uses: astral-sh/setup-uv@v5 + - uses: actions/setup-python@v5 + with: + python-version: | + 3.10 + 3.11 + 3.12 + # Leave out 3.13 on aarch due to an issue in pyo3/rust-numpy 0.23.4 + - name: Build wheels + uses: PyO3/maturin-action@v1 + if: ${{ matrix.platform.target == 'aarch64' }} + with: + target: ${{ matrix.platform.target }} + args: --release --out dist --interpreter 3.10 3.11 3.12 --zig + sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} + manylinux: auto + before-script-linux: | + dnf install -y clang-libs clang || sudo apt install llvm-dev libclang-dev clang - name: Build wheels uses: PyO3/maturin-action@v1 + if: ${{ matrix.platform.target == 'x86_64' }} with: target: ${{ matrix.platform.target }} - args: --release --out dist --find-interpreter --zig + # No py3.13 yet... + args: --release --out dist --interpreter 3.10 3.11 3.12 --zig sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} manylinux: auto before-script-linux: | @@ -160,7 +171,11 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: | + 3.10 + 3.11 + 3.12 + # 3.13 leave out 3.13 due to a segfault architecture: ${{ matrix.platform.target }} - name: Install uv uses: astral-sh/setup-uv@v5 @@ -211,7 +226,10 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: | + 3.10 + 3.11 + 3.12 - name: Install uv uses: astral-sh/setup-uv@v5 - uses: maxim-lobanov/setup-xcode@v1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 022267a..bdf5a0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,19 @@ All notable changes to this project will be documented in this file. -## [0.13.3] - 2025-02-11 +## [0.13.4] - 2025-02-18 + +### Bug Fixes + +- Add lock for pymc init point func (Adrian Seyboldt) + + +### Ci + +- Make sure all python versions are available in the builds (Adrian Seyboldt) + + +## [0.13.3] - 2025-02-12 ### Bug Fixes @@ -44,6 +56,18 @@ All notable changes to this project will be documented in this file. - Reformat some code (Adrian Seyboldt) +### Build + +- Bump some dependency versions (Adrian Seyboldt) + + +### Ci + +- Use ubuntu_latest on aarch64 (Adrian Seyboldt) + +- Update CI script using maturin (Adrian Seyboldt) + + ## [0.13.2] - 2024-07-26 ### Features @@ -178,8 +202,6 @@ All notable changes to this project will be documented in this file. ### Ci -- Fix uploads of releases (Adrian Seyboldt) - - Fix architectures in CI (Adrian Seyboldt) @@ -227,6 +249,11 @@ All notable changes to this project will be documented in this file. - Set the number of parallel chains dynamically (Adrian Seyboldt) +### Ci + +- Fix uploads of releases (Adrian Seyboldt) + + ## [0.9.2] - 2024-02-19 ### Bug Fixes diff --git a/Cargo.lock b/Cargo.lock index d6363e2..4fe15a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -334,9 +334,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.13" +version = "1.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7777341816418c02e033934a09f20dc0ccaf65a5201ef8a450ae0105a573fda" +checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9" dependencies = [ "shlex", ] @@ -408,18 +408,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.28" +version = "4.5.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e77c3243bd94243c03672cb5154667347c457ca271254724f9f393aee1c05ff" +checksum = "92b7b18d71fad5313a1e320fa9897994228ce274b60faa4d694fe0ea89cd9e6d" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.27" +version = "4.5.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b26884eb4b57140e4d2d93652abfa49498b938b3c9179f9fc487b0acc3edad7" +checksum = "a35db2071778a7344791a4fb4f95308b5673d219dee3ae348b86642574ecc90c" dependencies = [ "anstyle", "clap_lex", @@ -1356,7 +1356,7 @@ dependencies = [ [[package]] name = "nutpie" -version = "0.13.3" +version = "0.13.4" dependencies = [ "anyhow", "arrow", @@ -1716,9 +1716,9 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "11.3.0" +version = "11.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6928fa44c097620b706542d428957635951bade7143269085389d42c8a4927e" +checksum = "529468c1335c1c03919960dfefdb1b3648858c20d7ec2d0663e728e4a717efbc" dependencies = [ "bitflags", ] @@ -1889,9 +1889,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "smallvec" -version = "1.13.2" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" [[package]] name = "static_assertions" @@ -2014,9 +2014,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" [[package]] name = "ucd-trie" diff --git a/Cargo.toml b/Cargo.toml index 16f7ac9..cc452c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nutpie" -version = "0.13.3" +version = "0.13.4" authors = [ "Adrian Seyboldt ", "PyMC Developers ", diff --git a/python/nutpie/compile_pymc.py b/python/nutpie/compile_pymc.py index 7e344c0..53f3176 100644 --- a/python/nutpie/compile_pymc.py +++ b/python/nutpie/compile_pymc.py @@ -1,5 +1,6 @@ import dataclasses import itertools +import threading import warnings from collections.abc import Iterable from dataclasses import dataclass @@ -31,7 +32,7 @@ def intrinsic(f): from pytensor.tensor import TensorVariable, Variable -def rv_dict_to_flat_array_wrapper( +def _rv_dict_to_flat_array_wrapper( fn: Callable[[SeedType], dict[str, np.ndarray]], names: list[str], shapes: list[tuple[int]], @@ -509,6 +510,8 @@ def compile_pymc_model( return_transformed=True, ) + initial_point_fn = _wrap_with_lock(initial_point_fn) + if backend.lower() == "numba": if gradient_backend == "jax": raise ValueError("Gradient backend cannot be jax when using numba backend") @@ -530,7 +533,18 @@ def compile_pymc_model( raise ValueError(f"Backend must be one of numba and jax. Got {backend}") -def _compute_shapes(model): +def _wrap_with_lock(func: Callable) -> Callable: + lock = threading.Lock() + + @wraps(func) + def wrapper(*args, **kwargs): + with lock: + return func(*args, **kwargs) + + return wrapper + + +def _compute_shapes(model) -> dict[str, tuple[int, ...]]: import pytensor from pymc.initial_point import make_initial_point_fn @@ -663,7 +677,7 @@ def _make_functions( num_free_vars = count - initial_point_fn = rv_dict_to_flat_array_wrapper( + initial_point_fn = _rv_dict_to_flat_array_wrapper( pymc_initial_point_fn, names=joined_names, shapes=joined_shapes )