Skip to main content

Selene Logo

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 run or run_shots on 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.1

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 selene-sim 0.3.1
File
selene_sim-0.3.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
selene_sim-0.3.1-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details
selene_sim-0.3.1-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details
selene_sim-0.3.1-py3-none-macosx_12_0_x86_64.whl Python 3 none macOS 12.0+ x86-64 Details
selene_sim-0.3.1-py3-none-macosx_12_0_arm64.whl Python 3 none macOS 12.0+ ARM64 Details

Total release size: 73.1 MB

Release files / selene_sim-0.3.1-py3-none-win_amd64.whl

Download URL selene_sim-0.3.1-py3-none-win_amd64.whl
Size 13.7 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
734a17efe5ad1ff1cea3fa10c276555fc2519861dfab56d52512b768d8ee070f
BLAKE2b-256 checksum
How to use checksums
b2d0ab4020e2fd6e6fa7ac6988b982f19797a7118112d352f7bf65a07d817e31
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.1-py3-none-manylinux_2_28_x86_64.whl

Download URL selene_sim-0.3.1-py3-none-manylinux_2_28_x86_64.whl
Size 8.5 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
c5e3f86368e8c31c582aeccb9b00d88ce6ba2e5c039cb6c77ee9fba1a6c6ecae
BLAKE2b-256 checksum
How to use checksums
1a6fa6e2513271fbde46e9c6dfd5a9f4758cdcfa9f2fc19e039935e8a7f0c45d
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.1-py3-none-manylinux_2_28_aarch64.whl

Download URL selene_sim-0.3.1-py3-none-manylinux_2_28_aarch64.whl
Size 8.1 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
b2224b92a124a144dd57eb2f1a5ed36e6f05be9de3d147a22a3b3e5e3d84294d
BLAKE2b-256 checksum
How to use checksums
91261e8f7630bb777b7d7d32b30ae4f0e82bfcfbb557d2e472f126cb50334ace
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.1-py3-none-macosx_12_0_x86_64.whl

Download URL selene_sim-0.3.1-py3-none-macosx_12_0_x86_64.whl
Size 21.7 MB
Tags Python 3 macOS 12.0+ x86-64
SHA-256 checksum
How to use checksums
70e30e296d27dbed793280c1e159bdcbb0fa32ebbf593d3f2ff12ffcebacd4c6
BLAKE2b-256 checksum
How to use checksums
8919ac15b85e7845ab30810c41d249f3895aa43369978ba7c7a3c15e13afc3f4
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.1-py3-none-macosx_12_0_arm64.whl

Download URL selene_sim-0.3.1-py3-none-macosx_12_0_arm64.whl
Size 21.1 MB
Tags Python 3 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
80449c0db35cc290547f0a9551c97fe321b538e97aeee822ad7c4b040ae44439
BLAKE2b-256 checksum
How to use checksums
00c5b4e3f6bbcc22361bf6280d935986c929b13cc68371ebb962ab35e4856962
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.14

Release history Release notifications | RSS feed

0.3.4

5 release files

0.3.3

5 release files

0.3.2

5 release files

This release

0.3.1 This release

5 release files

0.3.0

5 release files

0.2.18

5 release files

0.2.17

5 release files

0.2.16

5 release files

0.2.15

5 release files

0.2.14

5 release files

0.2.13

5 release files

0.2.11

5 release files

0.2.10

5 release files

0.2.9

5 release files

0.2.8

5 release files

0.2.7

5 release files

0.2.6

5 release files

0.2.5

5 release files

0.2.4

5 release files

0.2.3

5 release files

0.2.2

5 release files

0.2.1

5 release files

0.2.0

5 release files

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