Skip to content

The purpose of this extension is to provide language support for the Intel Quantum SDK. This includes syntax highlighting, visualization tools as well as other planned features.

License

Notifications You must be signed in to change notification settings

intel/vscode-quantum-sdk

Intel logo

Intel® Quantum SDK Extension for VS Code

The purpose of this extension is to extend the IDE tools for working with source code compiled by the Intel® Quantum Compiler. This includes IDE integration with an existing Intel Quantum Compiler from either a container or local installation of the SDK; as well as a circuit board generator for visualizing quantum code.

Note: See Set Up for instructions on installing a container engine or installing the SDK locally.

Generate Circuit Board

Generate Circuit from Kernel

Above every kernel in a valid Quantum C++ file there will be a View Circuit button. If a container engine or local SDK installation is set up then clicking this button will compile the C++ file, generate a circuit board, and display it to the user.

viewCircuitButton.png

Edit and Generate Circuit from Json

After the compiler generates a circuit board during compilation using the -P json flag, the information for the circuit will be written to kernelName.json in the output sub-directory. This file can be changed manually and then used to generate a circuit board using the |0⟩ button on the right side of the tab bar.

Note: For an indepth description of the circuit board json structure, see Circuit Json Structure

circuitUsageExample.png

Export Circuit as PNG

Click on the tab with the generated circuit board to make it the active window. On the right side of the tab bar there will be an export button. Clicking this button will open up a file explorer for saving the png.

Note: Exported images will be light or dark based on your VS Code theme. To change your theme in VS Code press Ctrl + Shift + P, enter Color Theme, then select a dark or light theme from the drop down list.

exportButton.png

Execute Code

In a valid Quantum C++ file there will be a |0⟩ button on the right side of the tab bar. If a container engine or local SDK installation is set up then clicking this button will compile the C++ file, execute the program, and display a log file with the output to the user. The log file will then be stored in .iqsdk/outputs/fileName.log

Note: See Set Up for instructions on installing a container engine or installing the SDK locally.

executeUsageExample.png

Set Up

The extension requires either a container engine (Docker / Podman) or a local installation of the Intel® Quantum Compiler.

  • Podman - Documentation and installation here.
  • Docker - Documentation and installation here.
  • Dev Containers - To remote into a container and run 'locally' from inside the container, search Dev Containers in the extension store.
  • IQSDK - To run the compiler locally see the Intel® Quantum Compiler

.iqsdk Folder

Whenever a function of the extension is used it will check for the .iqsdk folder. If the folder does not exist it will be generated.

This folder stores the following information:

  • Circuits folder - Circuit board json files
  • Outputs folder - Log files from execution
  • Compile.json - Options for the compiler
  • Terminal.log - Contains the output from the compiler after execution or circuit board generation.

Compiler Options

Active Options

active-circuit-option and active-execute-option. Sets which option will be used for circuit generation and file exectution.

Name

Defines the name of the option. Once defined the name can be used by either active-circuit-option or active-execute-option.

Remove

Boolean value that decides whether a container should be deleted after an event finishes.

Engine

Selects how the option will access the Intel® Quantum SDK.

  • podman
  • docker
  • local - Must set localSDKPath if this option is selected

Note: If vscode is remoted into a container, use the local option and set the localSDKPath to the full path from within the container.

Local SDK Path

Defines the full path to the Intel® Quantum SDK for options where the engine option is set to local.

Gate Color Methods

  • default - Colors by general function of the gate
  • clifford - Clifford gates are green, non-clifford gates are red, and prep/meas gates are blue
  • axis - Colors gates based on the axis they act upon
  • simple - Uses all colors on simple gates prep, meas, x, y, and z for a beginner friendly circuit board

Args

A list of flags to be passed to the compiler. For example:

	"args" : [
        "-v",
        "-O0"
    ]

Circuit Json Structure

IntelQuantumID: Tells the extension that this json represents a quantum circuit board

"IntelQuantumID": "Circuit-v1",

title: Sets the title of the circuit board

"title" : "Teleport |1⟩",

numQbits: Defines the size of the y-axis and the number of qbits to display

"numQbits" : 3,

qbitNames: Defines the name of each qbit. The drawer will dynamically size the circuit to accommodate longer names. Empty strings will be converted to |0⟩.

"qbitNames" : [
	"example_0",
	"example_1",
	""
],

gates: Defines the gates that will be displayed on the circuit board. Gates require a name and a list of qbits to act upon. There is also an option to add attributes which will be displayed when the user hovers over that specific gate. Notice that some gates such as MeasZ have a custom gate icon.

"gates" : [
	{
		"name" : "Prep",
		"qubits" : [0]
	}, ...
	{
		"name" : "H",
		"qubits" : [1],
		"attributes" : ["Gate: Hadamard", "Test: 1"]
	},
	{
		"name" : "X",
		"qubits" : [1,2]
	}, ...
	{
		"name" : "Z",
		"qubits" : [0,2]
	}, ...
	{
		"name" : "MeasZ",
		"qubits" : [0]
	}, ...
]

gateColorMethod: Chooses one of a few styles that describes how the gates should be colored. For options see Gate Color Methods

"gateColorMethod": "simple",

Syntax Highlighting

This extension extends the list of keywords that are highlighted by VSCode to include grammar from the Intel® Quantum SDK.

3rd Party Materials

Project Repo License
Panzoom https://github.com/anvaka/panzoom MIT
Html2Canvas https://github.com/niklasvh/html2canvas MIT

License

Copyright (c) 2023 Intel Corporation. All rights reserved.

Licensed under the MIT license.

About

The purpose of this extension is to provide language support for the Intel Quantum SDK. This includes syntax highlighting, visualization tools as well as other planned features.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors 6