Build, edit, and inspect quantum circuits

Overview

The steps to build your quantum circuits are:

  1. open Circuit Composer,

  2. either drag-and-drop instructions or enter OpenQASM code, and

  3. inspect your circuit’s components using Circuit Inspector.

Open Circuit Composer

  1. If you are not currently signed in to IBM Quantum Experience, select the Sign in button in the upper right corner. Then, you can either sign in or Create an IBMid account.

  2. Open Circuit Composer by selecting the circuit icon on the left-hand navigation of IBM Quantum Experience.

  3. Select the New Circuit button.

  4. Name your experiment by clicking on the words Untitled Experiment, deleting them, and typing in your own title. Save the name by pressing return, or by selecting the pencil icon.

  5. To build a circuit, you can either drag-and-drop instructions, or you can enter OpenQASM code into the Circuit Editor.

Build your circuit with drag-and-drop

  • Drag and drop instructions from the quantum instruction palette onto the quantum and classical wires.

  • Once instructions are on the quantum circuit, you can continue to drag and drop them to new positions.

  • To delete an instruction from a wire, select the instruction, and an x will appear. Select the x to delete the instruction.

  • To add more quantum or classical wires, select the Settings tab (gear icon) along the left side of Circuit Composer.

Build your circuit with OpenQASM code

  • To open the Circuit Editor, select the code icon tab (</>) along the left side of Circuit Composer.

  • See the Instruction glossary for OpenQASM references to quantum operations.

  • For more information on using the OpenQASM language, including example lines of code, see the original research paper, Open Quantum Assembly Language.

Inspect your circuit, step-by-step

The Circuit Inspector de-mystifies the inner workings of the circuits you create. It provides a customizable step-by-step view of a simulation of your circuit, so that you can see the state of the qubits as the computation evolves.

Circuit Inspector.
  • Select the visualizations tab to the left of the editor (labeled with a histogram).

  • To move step-by-step through visualizations of your circuit’s components, select Inspect in the upper left corner to access the Circuit Inspector. (Note that you cannot select Inspect until you have added at least one instruction to Circuit Composer.) Control the movement of the inspector using the forward and rewind buttons.

    Controls to step forward and backward, and to jump to a circuit's beginning or end.

    Inspector controls, in order: jump to the beginning of a circuit, step backward, play from one break point to the next, step forward, jump to the end of a circuit.

  • With breakpoints, you can define groups of operations to inspect, by selecting one or more instructions in your circuit to mark a breakpoint. A colored overlay on an instruction indicates that a breakpoint is set. Once breakpoints are defined, you can select the play button to observe the steps in sequence. To remove a breakpoint, re-select the instruction, and the colored overlay disappears.

  • To learn more about interpreting the visualizations, see Visualizations.

  • To close the Inspector and return to editing your circuit, select the x in the upper right corner.

Randomness in the simulator

Each time you open the Circuit Inspector, the simulator creates randomness by generating results based on a seed. The seed is the initial value introduced into the algorithm that generates pseudorandom numbers. Because the seed is fixed during your Circuit Inspector session, your results will be repeatable. However, when you close the Inspector and re-open it, the seed will have a new value, so you may see a different result.

Run your circuit

When you are ready to save your circuit, run it on a quantum backend, and interpret the results, visit this link for more information: Run circuits and view results.