Selene
Selene is a quantum computer emulation platform written primarily in Rust with a python frontend.
Selene is built with flexibility in mind. This includes:
- A plugin system for the addition of additional components including simulators, error models, quantum runtimes to be provided within Selene or as third party plugins
- Support for custom input formats and device APIs through the selene-core build system.
What's included
Out of the box, Selene provides first-class support for the HUGR ecosystem, including execution of Guppy programs in an emulation environment, making use of our open-source compiler. You can find many examples of guppy usage in our unit tests.
Selene provides a range of simulators, including:
- Statevector simulation using QuEST and the quest-sys crate.
- Stabilizer simulation using Stim
- Coinflip simulation with customisable bias
- Classical Replay, for running pre-recorded measurements without direct simulation
- Quantum Replay, for running pre-recorded measurements with postselection-based simulation
Error models that are currently provided include:
- An 'ideal' error model which adds no noise to simulations
- A depolarizing error model which adds noise to qubit initialisation, measurement, and single- and two-qubit gates
And we offer two example quantum runtimes, including:
- Simple, which executes the program as-is, without any modifications
- SoftRZ, which elides Z rotations through RXY gates, providing the same observable behaviour with fewer quantum operations
Usage example
Although examples are provided in our tests folder, here is a quick walkthrough to get you started with Selene, HUGR and Guppy.
- First, we define the guppy program that we're interested in emulating:
from guppylang import guppy
from guppylang.std.quantum import *
from hugr.qsystem.result import QsysShot, QsysResult
@guppy
def main() -> None:
# allocate 10 qubits
qubits = array(qubit() for _ in range(10))
# prepare the 10-qubit GHZ state (|0000000000> + |1111111111>)/sqrt(2)
h(qubits[0])
for i in range(9):
cx(qubits[i], qubits[i+1])
# measure all qubits
ms = measure_array(qubits)
# report measurements to the results stream
result("measurements", ms)
compiled_hugr = main.compile()
- Then we compile the resulting HUGR Envelope to LLVM IR or bitcode using the HUGR-QIS compiler
from selene_sim import build
runner = build(compiled_hugr)
- Then we can utilise
runorrun_shotson the resulting selene instance, choosing a simulator (in this case Quest or Stim) and an error model (in this case DepolarizingErrorModel) to run the program.
from selene_sim import Quest, Stim
# run a single shot with Quest, the statevector simulator
shot = QsysShot(runner.run(simulator=Quest(), n_qubits=10))
print(shot)
# run a single shot with Stim, the stabilizer simulator
shot = QsysShot(runner.run(simulator=Stim(), n_qubits=10))
print(shot)
# run_shots runs efficient multi-shot simulations
# n_processes provides multi-processing across shots
# deterministic results can be achieved by providing a random seed
shots = QsysShot(runner.run(
simulator=Stim(random_seed=5),
n_qubits=10,
n_shots=100,
n_processes=8
))
print(shots)
- As well as simulators, we can customise the emulation by providing an error model, such as the depolarizing error model:
from selene_sim import DepolarizingErrorModel
error_model = DepolarizingErrorModel(
random_seed=12478918,
p_init=1e-3,
p_meas=1e-2,
p_1q=1e-5,
p_2q=1e-6,
)
shots = QsysResult(runner.run_shots(
simulator=Stim(
random_seed=10
),
error_model=error_model,
n_qubits=10,
n_shots=20,
n_processes=4,
))
print(shots)
- And/or a runtime, such as the SoftRZRuntime, which elides physical RZ gates through subsequent RXY gates:
from selene_sim import SoftRZRuntime
shots = QsysResult(runner.run_shots(
simulator=Stim(),
runtime=SoftRZRuntime(),
error_model=error_model,
n_qubits=10,
n_shots=20
))
print(shots)
Metadata
Release files for selene-sim 0.3.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| selene_sim-0.3.8-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details for selene_sim-0.3.8-py3-none-win_amd64.whl |
| selene_sim-0.3.8-py3-none-manylinux_2_28_x86_64.whl | Python 3 | none | Linux glibc 2.28+ x86-64 | Details for selene_sim-0.3.8-py3-none-manylinux_2_28_x86_64.whl |
| selene_sim-0.3.8-py3-none-manylinux_2_28_aarch64.whl | Python 3 | none | Linux glibc 2.28+ ARM64 | Details for selene_sim-0.3.8-py3-none-manylinux_2_28_aarch64.whl |
| selene_sim-0.3.8-py3-none-macosx_12_0_x86_64.whl | Python 3 | none | macOS 12.0+ x86-64 | Details for selene_sim-0.3.8-py3-none-macosx_12_0_x86_64.whl |
| selene_sim-0.3.8-py3-none-macosx_12_0_arm64.whl | Python 3 | none | macOS 12.0+ ARM64 | Details for selene_sim-0.3.8-py3-none-macosx_12_0_arm64.whl |
Total release size: 75.1 MB
Release files / selene_sim-0.3.8-py3-none-win_amd64.whl
| Download URL | selene_sim-0.3.8-py3-none-win_amd64.whl |
|---|---|
| Size | 14.3 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b25e8ddb5091b27061313b20eb576fd893d5ae7fb12c89b55f2cbbe72934cb9c
|
|
BLAKE2b-256 checksum How to use checksums |
f521d282941c4d5e6b96d12721b9799eed10324bbb282e800b74fccaccc9c771
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Release files / selene_sim-0.3.8-py3-none-manylinux_2_28_x86_64.whl
| Download URL | selene_sim-0.3.8-py3-none-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 8.8 MB |
| Tags | Linux glibc 2.28+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
b680255c3c38aeb8ce3d88b2f18fcf52574eb0c328d02a1eee02844c3906a273
|
|
BLAKE2b-256 checksum How to use checksums |
2eb8935839331c7bf834bb3788ff28de8f5d5c4b7ed8fc396e3770eb120a5570
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Release files / selene_sim-0.3.8-py3-none-manylinux_2_28_aarch64.whl
| Download URL | selene_sim-0.3.8-py3-none-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 8.5 MB |
| Tags | Linux glibc 2.28+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
baa6aba0e312b4ff536b2a18980eccb63927dbf34e4ebbb54c58da34cfa9d0b6
|
|
BLAKE2b-256 checksum How to use checksums |
3cb23c1d71d9a32f9d0bf2c3e76c3299f8c2aa95817d03c1dc79cd49ed60e170
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Release files / selene_sim-0.3.8-py3-none-macosx_12_0_x86_64.whl
| Download URL | selene_sim-0.3.8-py3-none-macosx_12_0_x86_64.whl |
|---|---|
| Size | 22.1 MB |
| Tags | Python 3 macOS 12.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
978efb53dd011d91f71f6ad9461d2b24d9153d0eae6de64dee0b6f053070b51f
|
|
BLAKE2b-256 checksum How to use checksums |
14905affc3e5fbbe20c961b12bb72389631c91a644d4c3dbfc546d7a8ddba451
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Release files / selene_sim-0.3.8-py3-none-macosx_12_0_arm64.whl
| Download URL | selene_sim-0.3.8-py3-none-macosx_12_0_arm64.whl |
|---|---|
| Size | 21.4 MB |
| Tags | Python 3 macOS 12.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f13b55949e650fe878af67d692bc6edb4e71ad1c042591ce5679ef43b6d60a56
|
|
BLAKE2b-256 checksum How to use checksums |
8ee58d2d76e534b40926ce1d478fb35533e41409baa5f81a642752813ac603e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Security for selene-sim 0.3.8
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.