Skip to main content

Rigetti

Rigetti offers a direct access quantum cloud service that provides access to the latest Rigetti quantum computing resources.

strangeworks-rigetti

The strangeworks-rigetti package allows users to run construct and solve problems using pyQuil, the Rigetti quantum computing library. Rigetti documentation lives at https://docs.rigetti.com/qcs/

PyPI version

📑 Package Documentation

​ To get started, make sure you have Python 3.10 or 3.11 (installation) and are familiar with setting up and using virtual environments.

Installation​

pip install -U pip && pip install strangeworks-rigetti

Authentication

First, authenticate via the Strangeworks SDK with your api-key taken from the Portal homepage:

import strangeworks as sw
from strangeworks_rigetti import get_qc

sw.authenticate(api_key)

Backends

Get a quantum computing resource using the Rigetti SDK extension by supplying a quantum computing backend name, and a qvm setting

CompanyProcessorQubitsFrameworkProcessors
RigettiSimulator9Rigetti9q-square-qvm

Disclaimer: This list of backends is subject to change at any time.

qc = get_qc(
"9q-square-qvm", as_qvm=True
) # as_qvm=False will produce a billable transaction when using hardware

Example

import pyquil
from pyquil.gates import CNOT, MEASURE, H

import strangeworks as sw
from strangeworks_rigetti import get_qc

sw.authenticate(api_key)

qc = get_qc(
"9q-square-qvm", as_qvm=True
)

program = pyquil.Program()
program = program.inst(H(0))
program = program.inst(CNOT(0, 1))
ro = program.declare("ro", "BIT", 2)
program = program.inst(MEASURE(0, ro[0]))
program = program.inst(MEASURE(1, ro[1]))
program.wrap_in_numshots_loop(10)

res = qc.run(program, circuit_type="qasm")

print(res)

🥳 Success! You may view your job in the portal.

😅 Something went wrong? Find us in Slack!