Qubit Toaster backend for Qiskit
Allows running Qiskit code on Qubit Toaster - a high performance quantum circuit simulator.
Install
pip install quantastica-qiskit-toaster
Usage
You need to install and run Qubit Toaster first. By default, this library expects Toaster running in server mode.
Now 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
# Instead:
#from qiskit import Aer
# Do:
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 127.0.0.1 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_namecan be:qasm_simulatoronly counts will be returned (default)statevector_simulatorboth 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 runningqubit-toastersimulator (default: 127.0.0.1)toaster_port- port thatqubit-toasteris listening on (default: 8001)use_cli- if this param is set toTruethequbit-toasterwill be used directly (by invoking it as executable) instead via HTTP API. For this to work thequbit-toasterbinary 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
- 2..7 - optimization is on. 7 is highest optimization level.
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
Find more goodies at https://quantastica.com
That's it. Enjoy! :)
Release files for quantastica-qiskit-toaster 0.9.30
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| quantastica-qiskit-toaster-0.9.30.tar.gz | 19.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| quantastica_qiskit_toaster-0.9.30-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.9 kB
Release files / quantastica-qiskit-toaster-0.9.30.tar.gz
| Download URL | quantastica-qiskit-toaster-0.9.30.tar.gz |
|---|---|
| Size | 19.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36a4bb3af3e5e5974fb0723e9adbd6b5f119f3d81afa0b32386821036b62d329
|
|
BLAKE2b-256 checksum How to use checksums |
db6ec96c05c3f212570704d07dea3cc2f978154821e7d5206db2e7737eb16010
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.9
|
Release files / quantastica_qiskit_toaster-0.9.30-py3-none-any.whl
| Download URL | quantastica_qiskit_toaster-0.9.30-py3-none-any.whl |
|---|---|
| Size | 23.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d1f7f966899658f9df7a7af5f807d5c73b90472390d80db99d6c74030e5ff532
|
|
BLAKE2b-256 checksum How to use checksums |
b9a026b7cb5c7fd06cd7d02e6e378936cf975173fc8f5b890ecc60c27f78fbf1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.9
|