By Chris Osborn, Quantum Software Engineer
Rigetti Quantum Cloud Services is the world’s only quantum-first cloud computing platform, with tightly coupled classical and quantum compute resources available over the cloud for incredibly fast hybrid quantum-classical programming.
One of the key innovations in QCS is the Quantum Machine Image, a virtual development and execution environment for quantum programming. Every QCS user has a dedicated QMI, hosted in close physical proximity to the QPUs in Rigetti’s quantum data center. This integrated platform eliminates the network latency found in web API access models, allowing you to iterate faster.
Each QMI comes pre-configured with our Forest SDK and QVM simulator to begin developing and testing your code. QMIs are also configured to host a Jupyter server so you can run preloaded example notebooks or begin writing new notebooks of your own. You can also upload third-party libraries and applications onto your QMI, such as those from our developer partners.
Get started programming in 5 simple steps
Create your QMI
During the account setup process you’ll be prompted to create your QMI by uploading your SSH public key. (Don’t worry if this is something you’re not familiar with, our in-app guides and documentation describe in detail how to do this.) After a few minutes, your QMI will be loaded and ready to use.
Access your QMI
Once you’ve created your QMI, you can fire it up from your account dashboard with one-click Jupyter web server access. Jupyter servers offer in-browser access to your files, and support Jupyter Notebooks (.ipynb files) for live, browser-based code editing and execution.
SSH Command Line Access
Alternatively, you can access your QMI with SSH, or secure shell login, via the ssh command from your terminal. The precise command, which requires the username and IP address of your QMI, can be found by clicking “Connect with Terminal” on the QMI card.
All of the files you found via Jupyter server access are found here as well. Check out the QCS docs to learn more about connecting with ssh, and about using Secure Copy (scp) to move files to and from your QMI.
Run code on the QVM Simulator from your QMI
An easy way to get started with QCS is to run a simple pyQuil program from a preloaded Jupyter notebook example on your QMI, and execute it on the QVM Simulator. Following the Jupyter link from your dashboard, open the file hello_qmi.ipynb.
This notebook imports a script, hello_qmi(), which simply prepares a program of +X/2 gates on some qubits for the QVM.
To run this function hello_qmi() from the Jupyter notebook, simply shift-enter through the import cells, and then the hello_qmi() cell in the notebook.
That’s all it takes to run your first pyQuil program from your QMI on the QVM Simulator!
PyQuil makes it easy to take code written for the QVM Simulator and run it on a real QPU. This is done by changing the target device name, which in our example can be optionally passed as an argument to hello_qmi(), as in hello_qmi(<some-qpu-name>). But first, we need to reserve time on a QPU.
Reserve time on a Rigetti quantum computer
QCS comes with an online reservation system, which means you have exclusive, uninterrupted, high-speed access to the QPU when you want to run your program. QCS also allows you to book reservations on subsets of a chip’s qubits, called lattices, from two qubits up to the size of the full chip, depending on what your program calls for. You can browse available QPUs and their lattices both via the QCS dashboard and the CLI in your QMI.
Once you’ve chosen your lattice, you can reserve time on a QPU either via the dashboard by clicking “Find availability”, or via the qcs reserve command from your QMI.
Run your code on the QPU
At the start of your reservation time, your QMI engages with the QPU you reserved. If you’ve SSH’d into your QMI, your terminal prompt will show your engagement status.You can now run pyQuil programs on the qubits in your selected lattice. As described above, the hello_qmi() sample function may optionally take a lattice name as its argument. Therefore, all we need to do is re-run our notebook, passing the lattice name to the hello_qmi function:
And that’s it! You’ve now run your code on a real quantum computer.
QCS also makes it possible to execute a program automatically when your reservation starts. With this feature, called execute-on-engage, all you need to do is put your script executable in the exec_on_engage.sh file in the home folder of your QMI.
More features for fast hybrid programming
In just minutes, we signed up for QCS, familiarized ourselves with our QMI, ran pyQuil programs on the QVM simulator, and then booked time and ran our code on a real QPU! This is just the beginning of your journey with QCS. Next, we take a look under the hood at some of the QCS features that unlock the full potential of the platform for fast hybrid programming.