Git Product home page Git Product logo

codecrap / inspire-experiments Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 2.0 10.15 MB

:boom: Helper library to conveniently run, save and analyze quantum experiments on QuTech's Quantum Inspire

Home Page: https://www.quantum-inspire.com/

License: GNU General Public License v3.0

Python 0.27% Jupyter Notebook 99.73%
experiments physics qasm qiskit quantum quantum-computing quantum-physics quantum-software qubits superconducting-qubits transmon quantum-inspire

inspire-experiments's Introduction

Readme Card

inspire-experiments

Helper library to conveniently run, save and analyze quantum experiments on QuTech's Quantum Inspire

Python 3.10 Jupyter Notebook License GitHub last commit GitHub release (latest SemVer including pre-releases) GitHub (Pre-)Release Date

Repo Visitors GitHub forks

This package is mostly focused on using the Starmon-5 hardware backend, but is easily applicable/extendable to using other backends of Quantum Inspire. The main thing is that in most places, it is assumed/hardcoded that the backend has 5 qubits.

Here we use Qiskit to generate the experiment circuits and send jobs just for convenience, but it is also possible to use Quantum Inspire's native cQUASM language as shown in this example. The main difference for the user is that one would have to operate on strings instead of objects to make the circuit (Qiskit can create a QASM representation of its circuit objects).

Installation

To use this package, just clone it locally to a directory of your choice

❯ git clone [email protected]:codecrap/inspire-experiments.git

and install it as local package in your python environment (-e for editable)

❯ python -m  pip install -e ./inspire-experiments

Usage

Login

Once you have stored your API token locally (check the Knowledge Base for how to do that) you can login using

from inspire_experiments import *
api, backend = inspire_login()

and check for the Starmon-5 backend's status using

print(get_starmon_status())

Sending jobs

After building the circuit you wish to run and sending the job using

job = qiskit.execute(circuit, shots=2**14, optimization_level=0, backend=backend)

This method will return immediately after posting the job to the API, but this doesn't mean the job is already done. It only gives you back a handle to the job. The next time you try to access job.result(), the command will not return until job.status() is FINISHED. This will either take ~40-60 seconds if the job started to execute immediately, or longer if there are other jobs in the queue (unfortunately it is currently not possible to get any information about the status of the queue from the API). If you changed your mind, you can terminate a job with job.cancel().

Note that passing optimization_level=0 above is needed to disable the optimization part of the Qiskit circuit transpiler and interpret your circuit literally as is (except for the mapping to hardware topology, check the Qiskit PassManager source code for details).

Saving data

You can save the results with

ExperimentData.save_job_result(job, exp_name="my_experiment_V1", header=get_file_header(circuit))

By default the ExperimentData class saves data as CSV and JSON files under ./data/ in the current directory.

By passing the output of get_file_header() as the optional header argument, each file will contain a text representation of the circuit that was used in the job. This is useful to help remember which data belongs to which experiment.

Loading data

To load back experiment data saved earlier, simply call

ExperimentData.get_csv_data("my_experiment_V1_RAW.csv")

This will return an array of binary strings representing the measurement result of each in little endian format.

If the circuit contains multiple subsequent measurements on any qubit, the result format will be such that each row of the array contains all shots corresponding to one (or several) measurements executed at the same time. To understand the scheduling of measurements (and other operations) see the scheduling section of the Knowledge Base.

Examples & more

Check the ./notebooks directory for more detailed and advanced usage examples of actual experiments you can run.

For more documentation about Quantum Inspire itself, visit the Knowledge Base. It also contains detailed examples of experiments that you can run yourself from Jupyter Notebooks (which are hosted here).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.