Skip to main content

Qubit Toaster backend for Qiskit

Allows running Qiskit code on Qubit Toaster - a high performance quantum circuit simulator.

More goodies at https://quantastica.com

Install

pip install quantastica-qiskit-toaster

Usage

Import ToasterBackend into your Qiskit code:

from quantastica.qiskit_toaster import ToasterBackend

Replace Aer.get_backend with ToasterBackend.get_backend.

Example

from qiskit import QuantumRegister, ClassicalRegister
from qiskit import QuantumCircuit, execute, Aer
from quantastica.qiskit_toaster import ToasterBackend

qc = QuantumCircuit()

q = QuantumRegister(2, "q")
c = ClassicalRegister(2, "c")

qc.add_register(q)
qc.add_register(c)

qc.h(q[0])
qc.cx(q[0], q[1])

qc.measure(q[0], c[0])
qc.measure(q[1], c[1])


# Instead:
#backend = Aer.get_backend("qasm_simulator")

# Use:
backend = ToasterBackend.get_backend("qasm_simulator")

# OR (to use statevector_simulator backend):
# backend = ToasterBackend.get_backend("statevector_simulator")

# OR (to specify custom toaster_host and toaster_port params
# default values are localhost and 8001 respectively):
# backend = ToasterBackend.get_backend(
#            "statevector_simulator",
#            toaster_host="192.168.1.2",
#            toaster_port=8888,
#        )

# OR (to use it directly via CLI instead of HTTP API)
# backend = ToasterBackend.get_backend(
#            "qasm_simulator",
#            use_cli=True)

job = execute(qc, backend=backend)
# To speed things up a little bit qiskit's optimization can be disabled
# by setting optimization_level to 0 like following:
#   job = execute(qc, backend=backend, optimization_level=0)
#
# To pass different optimization level to qubit-toaster use backend_options:
#   options = { "toaster_optimization": 3 }
#   job = execute(qc, backend=backend, backend_options=options)

job_result = job.result()

print(job_result.get_counts(qc))

Details

Syntax

ToasterBackend.get_backend( backend_name = None,
                            toaster_host=None, 
                            toaster_port=None, 
                            use_cli=False)

Arguments

  • backend_name can be:
    • qasm_simulator only counts will be returned
    • statevector_simulator both counts and state vector will be returned
    • If backend name is not provided then it will act as qasm_simulator
  • toaster_host - ip address of machine running qubit-toaster simulator
  • toaster_port - port that qubit-toaster is listening on
  • use_cli - if this param is set to True the qubit-toaster will be used directly (by invoking it as executable) instead via HTTP API. For this to work the qubit-toaster binary must be available somewhere in system PATH

Toaster's backend_options

  • toaster_optimization - integer from 0 to 7
    • 0 - automatic optimization
    • 1 - optimization is off
    • 7 - highest optimization

Running unit tests

First start qubit-toaster in HTTP API mode:

qubit-toaster -S

Running standard set of tests (excluding the slow ones):

python -m unittest -v

Running all tests (including the slow ones):

SLOW=1 python -m unittest -v

Specifying different toaster host/port:

TOASTER_HOST=192.168.1.2 TOASTER_PORT=8001  python -m unittest -v -f

Running tests by using CLI interface instead of HTTP:

USE_CLI=1 python -m unittest -v -f

That's it. Enjoy! :)

Download files

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

Source Distribution

quantastica-qiskit-toaster-0.9.22.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

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

quantastica_qiskit_toaster-0.9.22-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file quantastica-qiskit-toaster-0.9.22.tar.gz.

File metadata

  • Download URL: quantastica-qiskit-toaster-0.9.22.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.4

File hashes

Hashes for quantastica-qiskit-toaster-0.9.22.tar.gz
Algorithm Hash digest
SHA256 350f9c3d5a47378da156a09f945d946e7e3f0311f0c040a121ebdc7d4116ad12
MD5 b59eb897da2e91806b9397b656258b21
BLAKE2b-256 05ce4988ec273f00884822a2bc010fcc3f4ae6db77edd5680c78fef700d620b5

See more details on using hashes here.

File details

Details for the file quantastica_qiskit_toaster-0.9.22-py3-none-any.whl.

File metadata

  • Download URL: quantastica_qiskit_toaster-0.9.22-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.4

File hashes

Hashes for quantastica_qiskit_toaster-0.9.22-py3-none-any.whl
Algorithm Hash digest
SHA256 1881973db8c47aacc171c970530f45fbd64c2c15d17749b1a8cdcd01118897f6
MD5 fda1bb97fa4876851649f650daab769c
BLAKE2b-256 de8c7865c3b0ba84516d8769d94d5da7e703d10638f137dad467a2dba09f27ff

See more details on using hashes here.

Release history Release notifications | RSS feed

0.9.30

2 files

0.9.29

2 files

0.9.28

2 files

0.9.27

2 files

0.9.25

2 files

0.9.24

2 files

0.9.23

2 files

This release

0.9.22 This release

2 files

0.9.21

2 files

0.9.20

2 files

0.9.19

2 files

0.9.18

2 files

0.9.17

2 files

0.9.16

2 files

0.9.15

2 files

0.9.14

2 files

0.9.13

2 files

0.9.12

2 files

0.9.7

2 files

0.9.6

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page