Skip to content

VS Code Extension

The Classiq Visual Studio Code extension allows users to access Classiq's platform with a textual model interface.

Installation

Install VS Code, and then install the Classiq extension from VS Code extension marketplace.

Usage

Classiq platform introduces Quantum Description Language (QDL). The following sections explain its basic functionality. For additional details and use cases, follow the User Guide and Reference Manual.

Running Commands

To run a VS Code command, press Cmd+Shift+P on macOS or Ctrl+Shift+P on Windows, enter the required inputs and press Enter.
For more details, follow VS Code command palette.

Authentication

To login, run Classiq login command in VS Code: Classiq: Login to Classiq. This will open a web browser which enables login using one of the available options.

Login screen

Upon a successful login, you will be redirected to VS Code. If the redirection is not successful, refresh the web page (in the browser).

Note: You will need to approve the redirection both in the browser and in VS Code.

Create the workspace

If this is your first time running the Classiq extension, add a working folder to your VS Code workspace using the Add Folder to Workspace... command from the VS Code File menu

Configuration

This step is for advanced usage and may be skipped.

To configure the extension behavior beyond its default configuration, navigate to the extension settings in corresponding VS Code tab. Follow VS Code settings and search for Classiq settings.

This extension contributes the following settings:

  • classiq.backendURI: set to a different backend URI, in case working against a proxy.

Synthesis and Analysis

Both services are served through the corresponding VS Code command.

To facilitate synthesis, create or edit a model file with a .qmod suffix. After a successful login, VS Code will apply the file syntax, and you will be able to enjoy auto-completion of the keywords. The command Classiq: Generate Quantum Circuit executed when the VS-Code focus is on the .qmod column will synthesize the circuit implementing the model defined in that column.

The analyzer’s outputs are served through both an additional VS Code column and a browser, so the analyze command will open an additional external browser window. To run the analyzer execute the Classiq: Analyze Quantum Circuit command when the VS-Code focus is on a qasm circuit column. Currently only OpenQASM is supported for analysis, so if you’d like to analyze the circuit you generate, make sure the output_format field in your .qmod file is set to qasm (this is currently the default format, but it may change in the future).


Example

Following a successful login, create the file state_preparation.qmod with the following content:

{
  "constraints": {
    "max_width": 4,
    "max_depth": 100
  },
  "logic_flow": [
    {
      "function": "StatePreparation",
      "function_params": {
        "probabilities": [0.05, 0.11, 0.13, 0.23, 0.27, 0.12, 0.03, 0.06],
        "error_metric": { "KL": { "upper_bound": 0.05 } }
      }
    }
  ]
}

Run Classiq: Generate Quantum Circuit, and supply a name for this model results (you will be prompted to do so). The resulting quantum circuit loads the requested distribution, and displays it graphically and textually in separate columns. It is also saved to a directory under (current workspace path)/classiq/(supplied name).

In that same directory, you will also find an interactive_circuit.html file, which you can open with a browser and explore the resulting circuit by clicking on the + or - signs in each block.

The resulting circuit can also be analyzed using the analyzer. Run Classiq: Analyze Quantum Circuit when VS-Code focus is on the output qasm column.


Updating Versions

Update Classiq's VS Code extension by clicking on the "Extensions" tab (on the left) -> right-click on "Classiq" extension -> Install Another Version.... Install the new version and reload VS Code. Validate the correct version is installed by right-clicking on Classiq's extension again.

alt text

Note that one may choose to automatically update all the VS Code extensions by selecting the Views and More Actions... button (...) from the top right extensions window (as shown in the image below) and then selecting Auto Update Extensions -> All Extensions options from the drop-down menu.

alt text

Help

Our documentation is accessible using the Classiq: Help command. You may also check the Troubleshooting section within the Advanced Usage chapter of this guide.

Credits

We credit the following Node.js packages:

  • spdx-exceptions which is used as a development dependency (through @openapitools/openapi-generator-cli).
  • caniuse-lite which is used as a development dependency (through webpack).