Skip to main content

Python package (fuzzybits)

The Monte Carlo engine is installable as fuzzybits (import name and distribution name). Wheels are self-contained:

  • Linux x86_64 (manylinux_*): AdaptiveCpp runtime (libacpp-rt, libacpp-common, CUDA/OpenMP backend plugins) and, for the generic variant, the SSCP JIT pieces (llvm-to-backend, libLLVM, libdevice.10.bc, opt/llc). NVIDIA driver libraries (libcuda.so*) are not bundled; a CUDA ≥ 12.8 driver is required for GPU runs.
  • macOS 26 Apple Silicon (macosx_*_arm64): AdaptiveCpp ACPP_REF_METAL runtime with Metal + OpenMP backends and SSCP JIT (libllvm-to-metal, opt/llc/ld64.lld, libLLVM, Homebrew liblld/libomp), delocate-repaired with @loader_path rpaths. There is no separate libmc.dylib (INTERFACE mc → libscram). Metal kernel JIT currently rejects double until #17/#30; OpenMP CPU is the working backend. Built on GitHub-hosted macos-26.

Wheels are built with MALLOC_TYPE=malloc — no LD_PRELOAD.

Publishing to PyPI is #36 and is gated on a legal review. Until then, install a locally built wheel.

Install a wheel

pip install dist/fuzzybits-*.whl
python -c "import fuzzybits; print(fuzzybits.__version__, fuzzybits.list_devices())"
fzb --help

No PYTHONPATH or LD_PRELOAD. The wheel installs an fzb console script that matches the native CLI's compile / inspect / run flag surface so scripts can use either binary. Docker images keep the native /usr/local/bin/fzb (the pip script is overwritten after install).

Migration from mcscram_native / mcscram_server

import mcscram_native is removed. Use import fuzzybits (fuzzybits.compile, fuzzybits.inspect, fuzzybits.run, fuzzybits.Session, or fuzzybits.native() for bindings that are not yet public). The mcscram_server package and mcscram-server console script are gone; use fuzzybits_server / fuzzybits-server.

Variants follow #29:

wheel native module AdaptiveCpp flow when to use
generic (default) fuzzybits._native_generic SSCP JIT sm_86 / sm_120 / CPU
cuda-sm70 fuzzybits._native_cuda_sm70 clang CUDA SMCP AOT + embedded PTX Volta (V100)

macOS Metal is an experimental extra wheel (#87); backend="metal" is accepted and should raise a Python exception until #30 lands.

Import selection (override with fuzzybits.init(variant=...) or FUZZYBITS_VARIANT): cuda-sm70 if that extension is installed and an sm_70 device is present, otherwise generic.

This phase ships one variant per wheel under the same distribution name, so pip will replace one with the other. The import machinery still auto-selects if both .so files are present (future fuzzybits-native-* split).

API

import fuzzybits

fuzzybits.init(backend="auto")          # "cuda" | "omp" | "metal" | "auto"; also FUZZYBITS_BACKEND
print(fuzzybits.__version__)
print(fuzzybits.list_devices())

result = fuzzybits.probability(
    "model.xml",
    trials=1e7,
    pdag_c=2,
    no_kn=True,
    policy="wald",
)
print(result.estimate, result.ci, result.std_err)

pcfb = fuzzybits.compile("model.xml", pdag_c=2, no_kn=True)   # -> bytes
summary = fuzzybits.inspect(pcfb)  # fzb inspect --json keys + diagnostics
print(summary["queries"], summary["diagnostics"])

rows = fuzzybits.run(pcfb, trials=1e6, backend="auto")        # list[QueryResult]
print(rows[0].name, rows[0].estimate, rows[0].hits, rows[0].n)

with fuzzybits.Session(pcfb, backend="auto") as session:
    print(session.sample_shape)
    graph = session.graph()              # reconstructed PDAG, same keys as Pdag.to_graph()
    plan = session.execution_plan()      # same keys as Pdag.to_execution_plan()
    for obs in session.passes(max_passes=8):
        tally = obs.nodes[obs.target_index]
        print(obs.pass_index, tally.num_one_bits, tally.total_bits)
        if tally.total_bits >= 1_000_000:
            break                        # early stop; Session.close() on __exit__

compile / compile_file lower OpenPSA/MEF to a pcfb 1.1 buffer (the same host path as fzb compile). inspect always runs pcfb::validate and returns its diagnostics (empty iff the circuit is core-1.1 conforming). run is the one-shot fzb run equivalent: list[QueryResult(name, estimate, ci_low, ci_high, n, hits)]. Session reconstructs the PDAG and streams raw per-pass popcounts (num_one_bits / total_bits, pass index, trials per pass) so a host-side convergence loop can replace run_compile + layer_manager.single_pass_all without changing results.

The wheel now links fuzzybits_compile, pcfb, and the runtime into the native extension (libmc already carries run.cc). Native fzb / scram-cli binaries are not packed into the wheel; pip users get the Python fzb console script instead.

Results are deterministic for a given model and trial count (Philox counters). seed= raises NotImplementedError on probability, compile, run, and Session (#65).

init() must run before AdaptiveCpp initialises. The first call to list_devices / probability / compile / run / Session performs a lazy init("auto"). The JIT kernel cache defaults to ~/.cache/fuzzybits/acpp (ACPP_APPDB_DIR); set that variable yourself to override.

CLI (fzb on the wheel)

fzb compile model.xml [more.xml ...] [-c N] [--no-kn] [-o model.pcfb]
fzb inspect model.pcfb [--validate] [--json] [--exact]
fzb run model.pcfb --trials N [--seed S] [--backend auto|cuda|omp|metal] [--json]
fzb --help
fzb --version

--json keys match the native fzb inspect --json / fzb run --json payloads. --seed is rejected unless it is 372 (the scram-cli default), same as native (#65).

Build wheels from source

Requires the pinned toolchain in toolchain.env (AdaptiveCpp v25.10.0, clang 20, CUDA 12.8.1). CMake is driven by scikit-build-core using the same cache variables as CMakePresets.json (generic by default).

pip install . --config-settings=cmake.define.ACPP_TARGETS=generic
# or the Volta AOT variant:
pip install . --config-settings=cmake.define.ACPP_TARGETS=cuda:sm_70 \
              --config-settings=cmake.define.ACPP_USE_ACCELERATED_CPU=off \
              --config-settings=cmake.define.ACPP_STDPAR=off \
              --config-settings=cmake.define.ACPP_EXTRA_COMPILE_OPTIONS=--cuda-include-ptx=sm_70

Containerised build (remote daemon, writes dist/ on the client):

# 1. AdaptiveCpp+clang toolchain (full profile — SSCP)
docker --context xerxes build -f Dockerfile.cuda12.8 \
  --build-arg ACPP_COMPILER_FEATURE_PROFILE=full \
  --target adaptivecpp-clang \
  -t fuzzybits-acpp:full .

# 2. generic + cuda-sm70 wheels
docker --context xerxes build -f docker/wheel.Dockerfile \
  --build-arg TOOLCHAIN_IMAGE=fuzzybits-acpp:full \
  --build-arg FUZZYBITS_VARIANT=generic \
  --output type=local,dest=dist/generic .

docker --context xerxes build -f docker/wheel.Dockerfile \
  --build-arg TOOLCHAIN_IMAGE=fuzzybits-acpp:full \
  --build-arg FUZZYBITS_VARIANT=cuda-sm70 \
  --output type=local,dest=dist/cuda-sm70 .

auditwheel repair on Ubuntu 24.04 tags manylinux_2_39. A manylinux_2_28 rebuild is a follow-up. Driver libs are passed to --exclude libcuda.so.1. Approximate wheel sizes (cp312, x86_64): generic and cuda-sm70 are both ~66 MB, dominated by libLLVM.so.20.1 (~153 MB uncompressed) for SSCP JIT.

macOS 26 arm64 (GitHub-hosted macos-26; Intel Macs cannot produce this wheel). Host compiler is AppleClang; LLVM 20 is AdaptiveCpp's CLANG_EXECUTABLE_PATH. Override pyproject's Linux clang-20 compilers:

export MACOSX_DEPLOYMENT_TARGET=26.0
pip wheel . -w dist --no-deps \
  --config-settings=cmake.define.CMAKE_C_COMPILER=/usr/bin/clang \
  --config-settings=cmake.define.CMAKE_CXX_COMPILER=/usr/bin/clang++ \
  --config-settings=cmake.define.ACPP_TARGETS=generic \
  --config-settings=cmake.define.AdaptiveCpp_DIR=$ACPP_PREFIX/lib/cmake/AdaptiveCpp
delocate-wheel --lib-sdir lib --require-archs arm64 -w dist wheelhouse/fuzzybits-*.whl

Hosted path: scripts/ci/macos-wheel-build.sh + scripts/ci/macos-smoke.py.

Tests

pip install pytest
pytest tests/python -q -m "not gpu"     # OpenMP, small trial counts
pytest tests/python/test_pcfb_gpu.py -q # CUDA bit-identity (separate interpreter)

Metadata

Release files for fuzzybits 0.17.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for fuzzybits 0.17.0
File Interpreter ABI Platform Actions
fuzzybits-0.17.0-cp312-cp312-manylinux_2_39_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.39+ x86-64 Details for fuzzybits-0.17.0-cp312-cp312-manylinux_2_39_x86_64.whl
fuzzybits-0.17.0-cp312-cp312-macosx_26_0_arm64.whl CPython 3.12 CPython 3.12 macOS 26.0+ ARM64 Details for fuzzybits-0.17.0-cp312-cp312-macosx_26_0_arm64.whl

Total release size: 105.4 MB

Release files / fuzzybits-0.17.0-cp312-cp312-manylinux_2_39_x86_64.whl

Download URL fuzzybits-0.17.0-cp312-cp312-manylinux_2_39_x86_64.whl
Size 66.1 MB
Tags CPython 3.12 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
bcf281b0cf71e45b1348140d38acdfc22416aa16685cd75813594d961c611313
BLAKE2b-256 checksum
How to use checksums
4080376e453637f6dc517d1329449b32f22860705c8b0d3e42e78570bd963735
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / fuzzybits-0.17.0-cp312-cp312-macosx_26_0_arm64.whl

Download URL fuzzybits-0.17.0-cp312-cp312-macosx_26_0_arm64.whl
Size 39.3 MB
Tags CPython 3.12 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
90d0c13a23bec671a444ed7c8c193ce11c4be2ad53aedb38383b7462a13fa5e1
BLAKE2b-256 checksum
How to use checksums
934a0d341bc2b8d938eec8892e46f7c0db65d8a2eda8aa50ee8fd55b9515b778
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for fuzzybits 0.17.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fuzzybits-0.17.0-cp312-cp312-manylinux_2_39_x86_64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page