Working with the editor

Layout

The following description assumes you are working on a computer or laptop. On mobile devices the various panes may be shown beneath each other instead of next to each other in order to fit the screen.

When you work on a quantum algorithm the main editor is shown. The left pane is the code window where your QASM code is shown. The right pane shows a list of available qubit operations, and the bottom pane shows the circuit visualizer.

At the top left of the editor you find links to go to the results view or back to the editor view. In the center, the filename of your current project is shown and on the right side a RUN button is shown to execute the algorithm. Other sections of this guide provide more information on executing your algorithms and displaying and downloading your results.

Editor

A typical QASM program could look like this:

        
          version 1.0

# number of qubits for this backend is limited to 5 Qubits
qubits 2

{prep_z q[0] | prep_z q[1]}

# Create a superposition state for qubit 0
H q[0]

# Entangle both qubits using a CNOT gate
CNOT q[0], q[1]
        
      

The editor automically checks your code for obvious problems such as syntax errors, multiple operations on the same qubit at the same time, out-of-range errors, etc. Syntax highlighting is used to easily discriminate between instructions, operands, comments etc.

Note that syntax errors are signaled in the editor by a clear warning, but this does not prevent the code from being saved or executed. As a user you could still try and execute an algorithm with syntax errors, however these will result in execution errors.

Although the editor may catch the most obvious syntax errors, your code could still contain other problems which result in execution errors. Your code could also contain coding errors resulting in unexpected results which require debugging your code.

All code is automatically saved to file. The paragraph managing your projects provides more information on working with different projects and returning to previous versions.

Visualization of the algorithm

The circuit diagram corresponding to the QASM code is shown beneath the editor pane. The circuit is automatically rendered from the code in real time. Both the code display and the circuit visualization use differing colors to distinguish initialization and measurement operations from qubit operations and comments.

If your algorithm contains many lines of code, the rendering of the circuit could take some time. For very long algorithms our Software Development Kit (SDK) may be more appropriate.

q[0]
 
 
 
 
q[1]
 
 
 
 

In the editor you can type your own code or copy and paste existing algorithms. From the operations list on the right you can copy QASM instructions to your clipboard and paste them anywhere in your code .