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.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| selene_sim-0.3.3-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| selene_sim-0.3.3-py3-none-manylinux_2_28_x86_64.whl | Python 3 | none | Linux glibc 2.28+ x86-64 | Details |
| selene_sim-0.3.3-py3-none-manylinux_2_28_aarch64.whl | Python 3 | none | Linux glibc 2.28+ ARM64 | Details |
| selene_sim-0.3.3-py3-none-macosx_12_0_x86_64.whl | Python 3 | none | macOS 12.0+ x86-64 | Details |
| selene_sim-0.3.3-py3-none-macosx_12_0_arm64.whl | Python 3 | none | macOS 12.0+ ARM64 | Details |
Total release size: 74.2 MB
Release files / selene_sim-0.3.3-py3-none-win_amd64.whl
| Download URL | selene_sim-0.3.3-py3-none-win_amd64.whl |
|---|---|
| Size | 14.0 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6dc0062e925f91f93ab72fb47657f5699f1dfb9a4ed244d290f1a4f9f5664902
|
|
BLAKE2b-256 checksum How to use checksums |
370dc172c3a24ef7746ed18051ae4982ec744fb531f92a639e81c0fee4b50f8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / selene_sim-0.3.3-py3-none-manylinux_2_28_x86_64.whl
| Download URL | selene_sim-0.3.3-py3-none-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 8.7 MB |
| Tags | Linux glibc 2.28+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
fdb7799a1c071871dbf98166f79235098b3552b034c5e42a92ac2040d6e9c2fc
|
|
BLAKE2b-256 checksum How to use checksums |
b8261a0f14f9086d4cd2bf6197d95a93e280bf62e8a98e57b130f1105e9b257b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / selene_sim-0.3.3-py3-none-manylinux_2_28_aarch64.whl
| Download URL | selene_sim-0.3.3-py3-none-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 8.4 MB |
| Tags | Linux glibc 2.28+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
4b91099303590001695fd3ab4cb484f6dd146738c3f127314b2a98c0db652fd9
|
|
BLAKE2b-256 checksum How to use checksums |
6c16c9d5b08f949b82fefce803f536e6d293d17969c662824cf7c977f3f6f130
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / selene_sim-0.3.3-py3-none-macosx_12_0_x86_64.whl
| Download URL | selene_sim-0.3.3-py3-none-macosx_12_0_x86_64.whl |
|---|---|
| Size | 21.9 MB |
| Tags | Python 3 macOS 12.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
95f7b5a558e86dc046193d868bbc6e15943387d926c66db24fce12a28f1b51ce
|
|
BLAKE2b-256 checksum How to use checksums |
19b285ae553054af182d6783c6e2e09fce32c3f550d28e9176366cbf29fec83d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / selene_sim-0.3.3-py3-none-macosx_12_0_arm64.whl
| Download URL | selene_sim-0.3.3-py3-none-macosx_12_0_arm64.whl |
|---|---|
| Size | 21.3 MB |
| Tags | Python 3 macOS 12.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
4c0adb573987ee32555d2c9b2289da6599e193e9c4e4304c3ae37507fa15353e
|
|
BLAKE2b-256 checksum How to use checksums |
c55a63fc32c822e5641257ec0e506981a4722d1bcb249cd8fc1089d2105a1149
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|