Quantinuum's open source emulator for hybrid quantum computation
Project description
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
- 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
Installation
To install selene, pip install selene-sim.
This will automatically install our core interfaces, the hugr compiler, bundled components, and the Selene python frontend.
Usage example
Although examples are provided in the python tests folder, here is an example of using Selene with HUGR and Guppy.
#################################
# Defining the program in Guppy #
#################################
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 = guppy.compile(main)
################################
# Building the selene instance #
################################
from selene_sim import build, Quest, Stim
runner = build(compiled_hugr)
# this instance can now be used with various runtime-configurable
# components. Let's start simple with two popular simulators.
shot = QsysShot(runner.run(simulator=Quest(), n_qubits=10))
print(shot)
shot = QsysShot(runner.run(simulator=Stim(), n_qubits=10))
print(shot)
# deterministic results can be achieved by providing a random seed
shot = QsysShot(runner.run(simulator=Stim(random_seed=5), n_qubits=10))
print(shot)
##############################
# add noise and run 20 shots #
##############################
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)
###################################################
# use a runtime that eliminates physical RZ 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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file selene_sim-0.2.0a4-py3-none-win_amd64.whl.
File metadata
- Download URL: selene_sim-0.2.0a4-py3-none-win_amd64.whl
- Upload date:
- Size: 2.4 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7121ca957e324950ba63c61be7e5b721d13e894e41adb5fef73de5b1698dc9e
|
|
| MD5 |
dea23ea613512d7cd3033dc9960b91fe
|
|
| BLAKE2b-256 |
ff8174b7fa3708ca67c03f5ba1a086015373b018fb1670287e54a9c9ceda4f10
|
File details
Details for the file selene_sim-0.2.0a4-py3-none-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: selene_sim-0.2.0a4-py3-none-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 3.9 MB
- Tags: Python 3, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
812804940dcf29b78017b8d735994e0e0baaf4d447980ead32f1f833691489ad
|
|
| MD5 |
0c71fab8bc652b84e16dd060aefed63a
|
|
| BLAKE2b-256 |
64e0309a04fb4c4e43a60c5ec08c4ad4a2d3f3450dd48bd91cc58f2c2a5f1b63
|
File details
Details for the file selene_sim-0.2.0a4-py3-none-macosx_11_0_x86_64.whl.
File metadata
- Download URL: selene_sim-0.2.0a4-py3-none-macosx_11_0_x86_64.whl
- Upload date:
- Size: 3.5 MB
- Tags: Python 3, macOS 11.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad0556f0c1043b82f586fc3ea94de28abff0efb41f2aaa6b3cca7b241f270bf4
|
|
| MD5 |
0c2627661951bba04e9b952500719c42
|
|
| BLAKE2b-256 |
4975a92b8d8b1880a23332a614f2cffde7712391a23e1a956a408ce87c05e7fe
|
File details
Details for the file selene_sim-0.2.0a4-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: selene_sim-0.2.0a4-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.4 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a450b029eefc5c966c314df41de5394acd8fd814e8cc776b662a0bf6a60b94c1
|
|
| MD5 |
8f2b5a6e5b905db31971faf25f945612
|
|
| BLAKE2b-256 |
c8b0b18bcaaf945ae8316fd3b7c732a9a5f6ead93e84e1b7ce062c0e77964e4a
|