Skip to main content

C++ accelerated FPM quantum simulation primitives with Python bindings

Project description

fpm-qsim

C++ accelerated FPM quantum-simulation primitives exposed as a Python extension module.

Install from PyPI:

pip install fpm-qsim

Use it from Python:

import fpm_cpp as fpm

Layout

.
├── src/
│   ├── fpm_core.hpp          # Header-only C++17 FPM core
│   └── fpm_cpp_bindings.cpp  # pybind11 extension bindings
├── scripts/
│   └── build.sh              # Manual Linux/macOS/WSL build helper
├── tests/
│   ├── smoke_test.py         # Fast installed-wheel smoke test
│   └── equivalence_test.py   # Reference equivalence checks
├── pyproject.toml            # PyPI build metadata
├── setup.py                  # Extension build configuration
├── MANIFEST.in               # Source distribution contents
└── README.md

Example

import numpy as np
import fpm_cpp as fpm

rho0 = np.array([[0.5, 0.5], [0.5, 0.5]], dtype=np.complex128)

rho1 = fpm.lindblad_step(
    rho0,
    gamma=0.1,
    dt=1.0,
    method="exact",
    use_omp=False,
)

traj = fpm.simulate(
    rho0,
    gamma=0.05,
    dt=1.0,
    n_steps=1000,
    method="exact",
    use_omp=True,
)

fpm.bounded_gamma(29.3)

Build From Source

PyPI installs prebuilt wheels when available. If no wheel matches your platform, pip builds from source and requires:

  • Python 3.9+
  • NumPy
  • pybind11
  • A C++17 compiler

Manual local build:

python -m pip install pybind11 numpy
./scripts/build.sh
python tests/smoke_test.py

On Windows, normal pip install fpm-qsim builds with MSVC when a matching wheel is unavailable.

API Surface

The extension module is fpm_cpp.

Core functions:

  • lindblad_step(rho, gamma, dt=1.0, method="exact", use_omp=True)
  • simulate(rho0, gamma, dt=1.0, n_steps=1, method="exact", use_omp=True)
  • kappa_from_gamma(gamma, dt=1.0)
  • kappa_exact(gamma, dt=1.0)
  • gamma_from_kappa(kappa, dt=1.0)
  • bounded_gamma(gamma_raw, gamma_max=GAMMA_MAX)
  • gamma_from_energy(daemon, gate_power, load=None, dt=1.0, C_N=1.0, bounded=True)

State and accounting:

  • DaemonState
  • ConservationLedger
  • exp_route_cost(taylor_order=8)
  • bill_exp_route_cost(ledger, daemon, taylor_order=8, cost_per_op=1e-5)

Constants:

  • GAMMA_MAX
  • FALSIFICATION_THRESHOLD
  • ENERGY_FLOOR_FRACTION
  • ISOTROPIC_WEIGHT_LIMIT

Verification

After installing or building locally:

python tests/smoke_test.py

tests/equivalence_test.py is retained for reference comparison workflows that also have the old Python implementation available.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fpm_qsim-0.2.1.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fpm_qsim-0.2.1-cp314-cp314-win_amd64.whl (140.2 kB view details)

Uploaded CPython 3.14Windows x86-64

File details

Details for the file fpm_qsim-0.2.1.tar.gz.

File metadata

  • Download URL: fpm_qsim-0.2.1.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for fpm_qsim-0.2.1.tar.gz
Algorithm Hash digest
SHA256 8179d897238f13222dc79de657310beaedfd1ac6ca03415ad6f53e7e074e1dfb
MD5 bb01ad14650a09e22fb51f214df60acf
BLAKE2b-256 cd4c353cca5d39007c8f57dc66983efc351405373303d941f1a444e63290d813

See more details on using hashes here.

File details

Details for the file fpm_qsim-0.2.1-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: fpm_qsim-0.2.1-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 140.2 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for fpm_qsim-0.2.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 2b9c32e1385553a91875a6d82e4eaf8ed88d0c724e55dfc249f717152ae466cd
MD5 f002d83a30ab43e5c8faaa66c5ae3373
BLAKE2b-256 a3e7a630036747bcaad79c5ad51ca233c10cafe6d4b1e5b73140863e93101fee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page