Skip to main content

Quantastica quantum programming tools

Project description

Forest backend for Qiskit

Allows running Qiskit code on Rigetti simulators and quantum computers by changing only two lines of your Qiskit code.

More goodies at https://quantastica.com

Install

pip install quantastica-qiskit-forest

Usage

Import ForestBackend into your Qiskit code:

from quantastica.qiskit_forest import ForestBackend

And replace Aer.get_backend with ForestBackend.get_backend.

Example

from qiskit import QuantumRegister, ClassicalRegister
from qiskit import QuantumCircuit, execute, Aer

# Import ForestBackend:
from quantastica.qiskit_forest import ForestBackend

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 = ForestBackend.get_backend("qasm_simulator")

# OR:
# backend = ForestBackend.get_backend("statevector_simulator")
# backend = ForestBackend.get_backend("Aspen-7-28Q-A")
# backend = ForestBackend.get_backend("Aspen-7-28Q-A", as_qvm=True)
# ...

job = execute(qc, backend=backend)
job_result = job.result()

print(job_result.get_counts(qc))

Prerequisites

Running on your local Rigetti simulator

You need to install Rigetti Forest SDK and make sure that quilc compiler and qvm simulator are running:

Open new terminal and run:

quilc -S

And in one more new terminal run:

qvm -S -c

Running on Rigetti quantum computer

  • You need to get access to Rigetti Quantum Cloud Services (QCS)

  • In your Quantum Machine Image (QMI) install this package and Qiskit

  • Reserve a QPU lattice

  • Run your code via QMI terminal or Jupyter notebook served by your QMI

Details

Syntax

ForestBackend.get_backend(backend_name = None, as_qvm = False)

Arguments

backend_name can be:

  • any valid Rigetti lattice name

OR:

  • qasm_simulator will be sent to QVM as Nq-qvm (where N is number of qubits in the circuit)

  • statevector_simulator will be executed as WavefunctionSimulator.wavefunction()

If backend name is not provided then it will act as qasm_simulator

as_qvm boolean:

  • False (default)

  • True: if backend_name is QPU lattice name, then code will execute on QVM which will mimic QPU

That's it. Enjoy! :)

Project details


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-forest-0.9.14.tar.gz (10.3 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_forest-0.9.14-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file quantastica-qiskit-forest-0.9.14.tar.gz.

File metadata

  • Download URL: quantastica-qiskit-forest-0.9.14.tar.gz
  • Upload date:
  • Size: 10.3 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-forest-0.9.14.tar.gz
Algorithm Hash digest
SHA256 d80801fb9aa6fe26daaae5f13d36e5d5aeaab8bfc216a79e8d0c0d51d64b1993
MD5 a4c96afc4d38f5c4cd9109a9196cab29
BLAKE2b-256 a653719e388f9a57a832f3d299571e14a97a1b470c7503b52a19f8a4484af7e4

See more details on using hashes here.

File details

Details for the file quantastica_qiskit_forest-0.9.14-py3-none-any.whl.

File metadata

  • Download URL: quantastica_qiskit_forest-0.9.14-py3-none-any.whl
  • Upload date:
  • Size: 13.1 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_forest-0.9.14-py3-none-any.whl
Algorithm Hash digest
SHA256 497624c84851e1699d365cb857f0aec5236df731b9e281d99ec36289ec4928fe
MD5 e00813c84d40f912a81ddf90154f01ee
BLAKE2b-256 f2f99acc997327042c6ea02be81ea1cf053c76dfd3adccd403f1161e14f85de2

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