LogoLogo
  • Welcome to Quantum Cloud Services
  • Getting Started
    • Set up your environment
      • JupyterLab IDE
      • Install Locally
        • Quil SDK Docker Image
    • Quil SDK Overview
    • Running your first Quantum Program
  • Guides
    • Quil
      • What is Quil?
      • Language Support
      • Dynamic Control Flow
      • Customizing Program Readout
    • QPU vs. Simulator (QVM)
    • How to Use Rigetti QPUs
    • Access a QPU
      • QPU Reservations
      • On-Demand Access
      • QCS QPU Gateway
    • QCS Group Accounts
    • Interactive Tutorials
    • How Programs Are Built & Run
      • Execution and Request timeouts
    • The Lifecycle of a Program
    • The Rigetti QCS API
    • Using the QCS CLI
      • Using the Legacy QCS CLI
    • QCS Credentials
    • Benchmarking and Fidelity
  • Troubleshooting
    • Gathering Diagnostics
    • Report an Issue
  • Glossary
  • FAQ
  • References
    • pyQuil Reference
    • QCS API Specification
    • QCS CLI Reference
    • QCS Client Configuration
    • Quil / Quil-T Specification
    • quilc Reference
    • quil-rs Reference
    • QVM Reference
    • Rigetti Module for Cirq
    • Rigetti Provider for Qiskit
Powered by GitBook
On this page
  • Running the Image
  • Running Programs
  • Programs on Your Host Computer

Was this helpful?

  1. Getting Started
  2. Set up your environment
  3. Install Locally

Quil SDK Docker Image

PreviousInstall LocallyNextQuil SDK Overview

Last updated 1 year ago

Was this helpful?

We regularly publish images that contain the pre-installed. They will also start up and servers upon container start.

Running the Image

To use the image, just run the following in a terminal:

docker run --rm -it rigetti/forest

You'll then be presented with an IPython prompt, where you can easily write and execute Quil programs.

Running Programs

Try running a simple Quil program against a QVM by pasting the following into the IPython prompt:

from pyquil import get_qc, Program
from pyquil.gates import H, CNOT, MEASURE
from pyquil.quilbase import Declare

program = Program(
    Declare("ro", "BIT", 2),
    H(0),
    CNOT(0, 1),
    MEASURE(0, ("ro", 0)),
    MEASURE(1, ("ro", 1)),
).wrap_in_numshots_loop(10)

qc = get_qc("2q-qvm")

qc.run(qc.compile(program)).readout_data.get("ro")
from pyquil import get_qc, Program
from pyquil.gates import H, CNOT, MEASURE
from pyquil.quilbase import Declare

program = Program(
    Declare("ro", "BIT", 2),
    H(0),
    CNOT(0, 1),
    MEASURE(0, ("ro", 0)),
    MEASURE(1, ("ro", 1)),
).wrap_in_numshots_loop(10)

qc = get_qc("2q-qvm")

qc.run(qc.compile(program))

If all goes well, you'll see results similar to the following:

array([[1, 1],
       [0, 0],
       [0, 0],
       [0, 0],
       [1, 1],
       [0, 0],
       [1, 1],
       [0, 0],
       [1, 1],
       [0, 0]])

Programs on Your Host Computer

While typing programs into the IPython prompt can be instructive, it's often more useful to run programs that you're working on from your host computer.

For example, if you have a program located on your host computer at ~/pyquil/example.py, you can run the program using the rigetti/forest image with the following command:

docker run --rm -it -v ~/pyquil:/root/pyquil rigetti/forest python /root/pyquil/example.py

Avoiding Container Restarts

If you don't want to have to restart the container each time you run a program, you can start the container into a terminal instead:

docker run --rm -it -v ~/.qcs:/root/.qcs -v ~/pyquil:/root/pyquil rigetti/forest bash

Then, each time you need to run a program, you can execute it with the python command:

python ~/pyquil/example.py

Using JupyterLab

If you prefer to work with programs as Jupyter notebooks located on your host computer, you can run the rigetti/forest image with the following command (assuming notebooks are located in ~/pyquil on your host computer):

docker run --rm -it -p 8888:8888 -v ~/pyquil:/root/pyquil rigetti/forest bash -c "pip install jupyterlab && jupyter lab --ip 0.0.0.0 --no-browser --allow-root /root/pyquil"

You should see a JupyterLab server start up and print out a URL of the form:

http://127.0.0.1:8888/lab?token=...

You can then paste that URL into a browser on your host computer and start creating notebooks!

Notebooks saved to /root/pyquil in JupyterLab will be stored in ~/pyquil on your host computer.

If you'd like to use notebooks stored in a different location on your host computer, simply replace ~/pyquil with a different path in the command above.

If you're not familiar with using JupyterLab, we recommend .

this handy guide
Docker
quilc
QVM
Quil SDK
Docker Hub
Logo