Working in the lab · Chapter 6 of 14

Circuit builder & emulator

Draw the same file; scrub an ideal statevector.

~3 min read3 sectionssame text as the guide inside the lab
All chapters

Keys are written for macOS, the way the lab prints them — on Windows and Linux read ⌘ as Ctrl, ⌥ as Alt, ⇧ as Shift, ↵ as Enter.Keys are shown for Windows / Linux to match your platform — on a Mac, Ctrl is ⌘ and Alt is ⌥. Every binding: Keyboard shortcuts.

Every .qasm tab carries a Code | Circuit toggle. Both are projections of one file: edit the picture and the text changes; reopen and the picture is re-derived from the QASM. Your choice sticks across files — though a search hit or a Problems row opens Code, since it names a line of text.

Building

  • Palette along the top, in teaching order: H X Y Z · S S† T T† √X · Rx Ry Rz P · CX CZ CP SW CCX · M (measure) ‖ (barrier). Hover a chip for what it does.
  • An empty circuit, and your first edit on any circuit, gets a one-line how-to under the palette. An empty .qasm also offers Start a 2-qubit circuit — header, qelib1.inc include and a two-qubit register, written only when you press it.
  • Place a gate: click a chip then a wire, or drag the chip onto the wire. For CX/CZ/CP/SW/CCX click control then target (the strip says what it awaits), or drag and pick the other end.
  • Move / copy / retarget: drag a placed gate to another column or wire, or a control or target dot to another.
  • Angles: placing Rx, Ry, Rz, P or CP opens the editor at once, holding pi/2 — type to replace it, Enter or Escape keeps it, ⌘Z before you type undoes the placement. Later: double-click the gate or click its angle. Chips pi, pi/2, pi/4, pi/8, -pi/2, or any expression the parser reads.
  • Right-click a gate for Edit angle…, Duplicate (or ⌥-drag), Delete, Insert column left / right, Delete this column; on an empty cell, insert or delete a column.
  • + qubit / ✕ qubit add or remove the last wire (up to 24; it must be empty to remove).
  • ↶ undo / ↷ redo — ⌘Z / ⇧⌘Z. Delete or Backspace removes the selected gate; arrow keys walk between gates; Escape cancels a drag, closes a menu, deselects.
  • Those keys answer the circuit only while it holds focus: placing or selecting a gate gives it focus, and so does a click on the canvas. Arriving from elsewhere, click the canvas first.
  • Zoom − / + from 50 % to 150 %.

An impossible drop shows why it bounced.

What the builder will not draw

Custom gate definitions, more than one quantum or classical register, and OpenQASM 3 keep you in Code with the parser's own sentence and the line number. A picture that omits statements would be a lie with good typography.

The status strip counts what is drawn — gates, depth (barriers excluded), measured wires — and stops there. Nothing in the builder simulates anything…

…except the emulator

∿ emulate turns on an ideal statevector emulator: no noise, no shot sampling, up to 16 qubits in the browser. A bigger circuit is refused, named the platform simulator it fits (the catalogue's go to 22 qubits) and given a button to the Run rail. Then:

  • ⏮ ◀ ▶ ▶| and a scrubber step column by column; col k/N says where you are, and an empty cell jumps to "after this column". The play button is hidden under reduce motion.
  • P(|1⟩) per qubit — one bar per wire.
  • Basis states — the top 8 of 2^n, qubit 0 rightmost.
  • On a measuring column the bars are readout probabilities: the state is not collapsed, and the panel says so.

A circuit the emulator cannot finish shows how far it got and why.

Related: Run a circuit · For researchers · Keyboard shortcuts