Skip to main content

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! :)

Metadata

Release files for quantastica-qiskit-forest 0.9.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for quantastica-qiskit-forest 0.9.12
File Size Uploaded
quantastica-qiskit-forest-0.9.12.tar.gz 9.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for quantastica-qiskit-forest 0.9.12
File Interpreter ABI Platform
quantastica_qiskit_forest-0.9.12-py3-none-any.whl Python 3 none any Details

Total release size: 20.8 kB

Release files / quantastica-qiskit-forest-0.9.12.tar.gz

Download URL quantastica-qiskit-forest-0.9.12.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cff962674843830d201a99fea4daff09b11a20f1c3635398d01ea8430a686d1f
BLAKE2b-256 checksum
How to use checksums
42a9f02778862aa380c0771a6a46a0fcf8049a17f673ee160e57d2aee9ac3f6a
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / quantastica_qiskit_forest-0.9.12-py3-none-any.whl

Download URL quantastica_qiskit_forest-0.9.12-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5db37a4426c38d3ee41b4e943b8e56df98242d0866ce7e1fdc55a908b8162209
BLAKE2b-256 checksum
How to use checksums
2219ddf896eddb8ae21f4693be1c4ea232a36c523dfbcf6025a035f68b6b9f69
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

0.9.21

2 release files

0.9.20

2 release files

0.9.19

2 release files

0.9.18

2 release files

0.9.17

2 release files

0.9.16

2 release files

0.9.13

2 release files

This release

0.9.12 This release

2 release files

0.9.10

2 release files

0.9.8

2 release files

0.9.7

2 release files

0.9.6

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page