QVM Creation Template

View on QuantumAI Run in Google Colab View source on GitHub Download notebook

This notebook includes a couple of clean and succinct code blocks that you can build on or copy and paste elsewhere in order to make use of the Quantum Virtual Machine without worrying about how it works inside.

Install Cirq and qsim

Create a Quantum Virtual Machine.

Instantiate a cirq.SimulatedLocalEngine that uses the Virtual Engine Interface.

Your quantum virtual machine rainbow is ready, here is the qubit grid: 
========================

                  (3, 2)
                  │
                  │
         (4, 1)───(4, 2)───(4, 3)
         │        │        │
         │        │        │
(5, 0)───(5, 1)───(5, 2)───(5, 3)───(5, 4)
         │        │        │        │
         │        │        │        │
         (6, 1)───(6, 2)───(6, 3)───(6, 4)───(6, 5)
                  │        │        │        │
                  │        │        │        │
                  (7, 2)───(7, 3)───(7, 4)───(7, 5)───(7, 6)
                           │        │        │
                           │        │        │
                           (8, 3)───(8, 4)───(8, 5)
                                    │
                                    │
                                    (9, 4)

Create a device-ready circuit.

To learn how to create a device ready circuit, have a look at the QVM Circuit Preparation page.

# create your device ready circuit here!
q0 = cirq.GridQubit(4, 1)
your_circuit = cirq.Circuit([(cirq.X**0.5)(q0), cirq.measure(q0)])
print(your_circuit)
(4, 1): ───X^0.5───M───

Execute Your circuit on the Quantum Virtual Machine.

Circuit successfully executed on your quantum virtual machine rainbow
QVM runtime: 0.04357s (3000 reps)
You can now print or plot "results"