Skip to content

Circuit Editor Bug Bash Instructions

Scott Carda edited this page May 26, 2025 · 3 revisions

Creating a Q# Project with a Circuit File

  1. Create an Empty Project Folder

    • In your file system, create a new, empty folder for your Q# project.
  2. Open the Folder in VS Code

    • Launch VS Code.
    • Use File > Open Folder... to open your new project folder.
  3. Create a Q# Project

    • In the VS Code file explorer, right-click the empty folder.
    • Select "Create Q# Project" from the context menu.
    • This will scaffold the necessary project files and folders.
  4. Add a Circuit File

    • Inside the src folder, add a new file with the .qsc extension (for example, MyCircuit.qsc).
    • You can now open this file and use the Circuit Editor to design your quantum circuit.

Editor Scenarios to test

Test each action and note any unexpected behavior or UI issues.

  1. File Operations

    • Create a new circuit file.
    • Open an existing circuit file.
    • Open an empty circuit file.

Example of an empty or new circuit file:

image

  1. Gate Operations

    • Add a gate from the toolbox by dragging a gate from the toolbox onto the circuit.
    • Remove a gate by dragging it off the circuit or using its context menu. Context menus for gates and other circuit elements can be found by right-clicking the element.
    • Add controls to a gate using the gate's context menu.
    • Remove controls by dragging them off the circuit or using context menu on gate or control.

Example of populating a circuit:

CE - drag and drop 6

  1. Qubit Operations

    • Add qubits by dragging gates onto the ghost line.
    • Move qubit lines by dragging the qubit state label on the left of the circuit. Try swapping and reordering qubits with and without gates.
    • Verify trailing (bottom) qubit lines are removed.
    • Verify non-trailing empty qubit lines are allowed.
    • Delete qubits by dragging the qubit line off the circuit.

Example of moving qubits:

CE - drag and drop qubits

  1. Gate Movement

    • Try moving gates onto existing gates/controls (should be blocked except swapping with own control).
    • Move gates into new/existing columns (start, middle, and end of circuit).
    • Verify empty columns are removed.
    • Move gates with controls (controls move with gate).
    • Make copies of a gate by moving it while holding down the Ctrl key.

Example of gate movement:

CE - drag and drop 5

  1. Gate Arguments

    • Add a gate that requires arguments (prompt appears).
    • Test argument validation (empty, invalid, valid input). Only simple arithmetic expressions are allowed.
    • Edit arguments by clicking on the argument on the gate or through the gate's context menu.
    • Use Pi button or enter "pi".

Example of Adding a gate with an argument:

CE - arguments

  1. Measurement Gates

    • Add multiple measurement gates to the same qubit.
    • Move measurement gates and verify lines update correctly.

Example of measurement lines readjusting:

CE - measurement gates

Test Q# Interoperability

Circuits defined in circuit files are exposed to Q# as operations. In the same project as the circuit file, find the Main.qs file and the Main operation or entry point. In the Main operation's body, start typing the name of the circuit file and you should see an auto-completion popup for the circuit operation with the image symbol next to it. Select the auto-completion and Q# will insert the import statement into your code and complete the name of the circuit operation. The import statement will look something like import MyCirucit.MyCircuit;. Please test the following scenarios:

  1. An empty circuit operation will take no arguments. Otherwise it will take a single qubit register in the form of a Qubit array. The description of the circuit should tell the user how many qubits are expected in the array. If less than the necessary qubits are provided, a runtime error should occur.

  2. If the circuit contains no measurements or reset gates (blue gates in the default VS Code theme), then the operation will be adjointable and controllable.

  3. The operation will return Unit unless there are measurement gates in the circuit. If there is one measurement, it will return a single Result for that measurement. If there are multiple measurements, it will return a Result array. The order of results in the array correspond to the order of the measurements in the circuit, by column left-to-right first, then if multiple measurements are in the same column, top-to-bottom within a column.

  4. The signature of the circuit operation should update in real time with edits to the circuit file.

  5. The Q# program should run with calls to the circuit file.

Clone this wiki locally