Skip to main content

Quantinuum's open source emulator for hybrid quantum computation

Project description

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
  • 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


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.2.0a3-py3-none-win_amd64.whl (2.4 MB view details)

Uploaded Python 3Windows x86-64

selene_sim-0.2.0a3-py3-none-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

selene_sim-0.2.0a3-py3-none-macosx_11_0_x86_64.whl (3.5 MB view details)

Uploaded Python 3macOS 11.0+ x86-64

selene_sim-0.2.0a3-py3-none-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: selene_sim-0.2.0a3-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.10

File hashes

Hashes for selene_sim-0.2.0a3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 86750047ca10acd316bcda9f495acc224a01e3213bfe063aa40a615880bee6e9
MD5 d8b40da501a7a4c4430e4c0ff8aea228
BLAKE2b-256 53e54a8849fd496eb8714bedb19e17d35584aaa4d16ed6b80c3ef0d8fd1fdb99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for selene_sim-0.2.0a3-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0ea58e9aec106911b27c9011c3c9cb9be6f0ea69702e4ff3cbe90d5d3b5b5e5b
MD5 2aa1c57e904177ed2818f9081eac9345
BLAKE2b-256 3f218ecf0cb40d84e646f0178fed6f5d8610a043ca3b49abf0ad8cc412fe8bfd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for selene_sim-0.2.0a3-py3-none-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 bbea7e9092da62384304acede828b8d732f19e06d8b9b7ecc410f943f534ceba
MD5 27171b7e283a2ba3cbc1d94f4279248a
BLAKE2b-256 b136804c7c182fc4dd71d09d51616b8180aa5550947568b38b2a92f22105651e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for selene_sim-0.2.0a3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 86b08e0add1ac2b6cf7f27faf7c6533b662c0255d4983df25bd18ccaa0605f7a
MD5 b498ae1a0f2647a369e1621e76df0454
BLAKE2b-256 228f89bcf31c17ded84d9d0433bf4b64d305cdd42fecd314e09725f17dd982cd

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