-
Notifications
You must be signed in to change notification settings - Fork 119
Circuit Editor
The Circuit Editor is a new feature in the Quantum Development Kit that allows users to create, edit, and visualize quantum circuits directly within their Q# projects. This tool enhances the quantum development experience by providing a graphical interface to design quantum circuits alongside Q# code.
- Create and Edit Circuits: Users can easily create and modify quantum circuits, adding or removing qubits and operations as needed.
- Interoperability: The Circuit Editor integrates seamlessly with Q# projects, allowing for a smooth workflow between code and circuit diagrams.
- Visualization: Visualize quantum circuits to better understand quantum algorithms.
- Create or open an exiting Q# project.
- Add a new circuit file with the extension
.qsc
. - Open that file in VS Code. The editor is the default view for
.qsc
files.
The Circuit Editor in the Quantum Development Kit offers a range of features to enhance your quantum development experience. Here are some features you can explore:
- Adding Operations from the Toolbox: Add quantum operations from the toolbox into your circuit by click-and-drag.
- Removing Operations: Remove any unwanted operations from your circuit, either by dragging the operation out of the circuit, or right-click to bring up a context menu on the operation and select the "Delete" option.
- Moving Operations Around the Circuit: Rearrange the operations in your circuit by click-and-drag.
- Adding/Removing Qubits: Add or remove qubits to your with the "Add/Remove Qubit Lines" buttons.
- Adding/Removing Controls on Operations: Controls can be added or removed from operations by right-clicking the operation to bring up the context menu. From there you can select the "Add control" and "Remove control" options and selected the qubit line to add/remove a control. Controls can be also be removed through the "Remove control" option on their own context menu, or by dragging the control dot off the circuit. Controls should not be supported on Measurement or Reset gates.
- Adjointing Operations: Operations can be adjointed via the "Toggle Adjoint" option on their context menu.
- Copying Operations: When dragging an operation, if the user holds down the Ctrl key when placing the operation, it will copy the operation instead of moving it.
- Operation Arguments: An argument can be added to operations by the "Edit Argument" option on their context menu. Users will be prompted to enter text that will be interpreted as a Q# expression at runtime for the first-most argument to the operation.
Circuit files define operations that can be referenced elsewhere in the same Q# project in Q# code. They will appear like any other operation and are supported by the language service with features like completions, signature help, and go-to definition. The circuit file will define a namespace based on the file name, similar to how Q# files do, and the circuit described by the file will define an operation of the same name under that same namespace. For example, to reference the circuit defined in Foo.qsc in your Q# code, you'd use the following import statement: import Foo.Foo;
. In the future, we'd like to add the ability to support naming the circuit (and Q# operation) independently and support multiple circuits per file, resulting in multiple operations under the namespace.
- View Generated Q#: Easily view the Q# that is generated from a circuit in a readonly tab/panel.
- Conditional Branching and Loops: Add complex logic to circuits with conditional operations and looping constructs.
- Custom Gates: Create and use custom gates, including gates defined in Q#, in circuits for more customizability in designing quantum circuits.
- Integration with Jupyter Notebooks: Be able to create and edit circuits in a notebook.
- Standalone Circuit: Run circuits on their own, without having to have a Q# project.
- Circuit Editor Experience Issue: Tracking issue for Circuit Editor features and tasks.