Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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)

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

selene_sim-0.3.0a3-py3-none-win_amd64.whl (11.3 MB view details)

Uploaded Python 3Windows x86-64

selene_sim-0.3.0a3-py3-none-manylinux_2_28_x86_64.whl (5.4 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

selene_sim-0.3.0a3-py3-none-manylinux_2_28_aarch64.whl (5.2 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

selene_sim-0.3.0a3-py3-none-macosx_11_0_x86_64.whl (5.3 MB view details)

Uploaded Python 3macOS 11.0+ x86-64

selene_sim-0.3.0a3-py3-none-macosx_11_0_arm64.whl (5.1 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file selene_sim-0.3.0a3-py3-none-win_amd64.whl.

File metadata

  • Download URL: selene_sim-0.3.0a3-py3-none-win_amd64.whl
  • Upload date:
  • Size: 11.3 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for selene_sim-0.3.0a3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 6de31f3c52e79e9497ea052e2c16b482fd9d636a5428c377d0551ff8566b6bd9
MD5 202fc0279bee8b00eb7a284a82bcc5e5
BLAKE2b-256 1575f5489d5ff4b8177fb5ec49330f37d080c14e7791099bbce5237a3bbb0d0f

See more details on using hashes here.

File details

Details for the file selene_sim-0.3.0a3-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for selene_sim-0.3.0a3-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1fbdd24fac12e4dede6d1943f2b751454725ac4f352174ed65e9577bbc96075f
MD5 7e113c58e431c3f767a826a99bac2552
BLAKE2b-256 00c1c0cda4b551cf2ab174ac2d33941477eae4c716f1fa05ab61cbc77de34dcd

See more details on using hashes here.

File details

Details for the file selene_sim-0.3.0a3-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for selene_sim-0.3.0a3-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bb071811a243bd7b5bab8fc6fe2d8d51eeab9bd24773bade772715d3c426db27
MD5 9867eaa939808061e3776ffb630111ab
BLAKE2b-256 f879acd5bedc86f0395fa2b6bcaeb75692f558ef84a671e03f8476b345f912ab

See more details on using hashes here.

File details

Details for the file selene_sim-0.3.0a3-py3-none-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for selene_sim-0.3.0a3-py3-none-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 69582236646ef6e241a7349cc107218312291176643bc3605150093d50ba000d
MD5 099da44cf2f0c415331d3f076eb7edfd
BLAKE2b-256 579f717f652321a6bf5bb4b3af6d1ad57464e97eb6610aa15fa60d4881da4c8b

See more details on using hashes here.

File details

Details for the file selene_sim-0.3.0a3-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for selene_sim-0.3.0a3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 69be5a353958d06e75d55d1543dea18565bc290135b076dd758bf12640b3bbd2
MD5 f53e94476f3d2d974bd92e7cf770bd7e
BLAKE2b-256 e72cddf51d843fc81a7550f3daf3aeb392466e1dce9240d5ad24d414ce801581

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 Sentry Error logging StatusPage Status page