Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Qcoder compileNew to Visual Studio Code? Get it now.
Qcoder compile

Qcoder compile

QCFlow

|
7 installs
| (0) | Free
A quantum programming plugin supporting multiple compiler options
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

qcoder-compile

中文 · English


中文

一个支持多编译器选择的量子编程插件,旨在为开发者提供多种量子编译框架的统一调用。

功能特性

  • 多编译器支持:支持 Qiskit、QPanda、QLLVM 等多种量子编译框架,可同时进行编译对比
  • 远程编译支持:支持本地编译与远程 SSH 编译两种模式,远程编程为默认模式
  • 智能环境检测:自动检测系统中的 Python 环境和虚拟环境(venv、conda、pyenv 等)
  • 灵活配置:支持自定义编译器参数和优化选项
  • 进度显示:编译过程带进度条和详细的日志输出
  • 编译器配置管理:支持默认配置和自定义配置,权限分级管理
  • 动态字段显示:根据编译器类型智能显示/隐藏相关配置字段
  • QIR 模拟器支持:集成 QIR 模拟器运行功能,支持量子电路仿真验证

支持的编译器类型

1. **QLLVM **
  • 直接输入文件类型 (qasm, originir, qcis)
  • 设备类型选择 (NISQ/FTQC)
  • 后端类型配置 (qasm-backend, originquantum, tianyan, zheda)
  • 优化等级控制 (O0/O1)
  • 基础门组定制
  • QPU 配置文件指定 (originquantum: wukong72, tianyan: tianyan176, zheda: topology_13*12)
  • 初始比特映射
  • 详细编译信息输出
  • MLIR/QIR 中间表示调试
  • C/C++ 可执行文件路径配置(可选,支持系统 PATH 自动查找)
2. Qiskit (IBM)
  • 优化等级配置 (0-3)
  • 后端类型选择 (自定义, ibm平台, scaleway)
  • 布局方法选择 (trivial, dense, noise_adaptive, sabre)
  • 耦合图配置
  • 基础门组定制
  • 初始布局配置
  • Python 解释器路径配置
3. QPanda (本源量子)
  • 后端类型选择 [自定义, 本源芯片: wokong180, wukong102_401, wukong72,(请注意, 计算后端会不定期更新)]
  • 拓扑结构配置
  • 初始映射设置
  • 优化等级 (0-2)
  • 基础门组定义
  • 纯分解模式支持
  • Python 解释器路径配置

主要命令

  • 打开量子编译器设置 (qcoder-compile.openCompilerSettings):配置编译器相关参数
  • 编译当前量子电路文件 (qcoder-compile.compileCurrentFile):对当前打开的量子电路文件进行多编译器并行编译
  • 运行量子电路 (QIR 模拟器) (qcoder-compile.runQirSimulator):在 QIR 模拟器上运行量子电路并获取仿真结果

使用方式

基本使用

  1. 打开量子电路文件

    • 支持 .qasm、.py、.qccs 格式文件
  2. 右键菜单操作

    • 在编辑器中右键点击上述格式文件
    • 选择对应的量子电路编译操作
  3. 编译器配置

    • 通过"打开量子编译器设置"命令进入配置界面
    • 启用需要的编译器
    • 配置各编译器的专属参数

编译模式

本地编译

直接在本地 Python 环境中执行编译任务。支持:

  • 自动检测系统中的 Python 解释器
  • 扫描项目级虚拟环境(venv、.venv、env 等)
  • 扫描 Conda 环境(~/.conda/envs、~/anaconda/envs 等)
  • 优先使用编译器配置中指定的 Python 路径
远程编译

通过 SSH 连接到远程服务器执行编译,支持:

  • 远程 Python 环境配置
  • 编译结果自动回传
QIR 模拟器运行

使用 QIR 模拟器执行量子电路仿真,支持:

  • 自动检测 QIR 模拟器可执行文件
  • 支持系统 PATH 自动查找
  • 显示仿真结果和状态信息

输出查看

编译结果会显示在专用的"量子电路编译日志"输出通道中,包括:

  • ✓/✗ 标记每个编译器的成功/失败状态
  • 详细的错误信息和堆栈跟踪
  • 电路元数据(量子比特数、深度等)
  • 编译耗时统计
  • 生成的输出文件路径
  • 编译器版本信息

系统要求

  • Visual Studio Code: >= 1.110.0
  • Node.js: >= 18.x
  • Python: qpanda(>= 3.8 && <= 3.11), qiskit(>= 3.5)

Python 依赖

根据使用的编译器类型,需要安装相应的 Python 包:

# Qiskit
pip install qiskit qiskit-ibm-runtime

# QPanda
pip install qpanda3

# QLLVM
# 安装Qcoder后会提示是否安装qllvm

编译器配置管理

输入格式与编译器兼容性

概述

本插件支持多种前端输入格式,并将它们转换为后端编译器能够处理的中间表示(QASM),最终输出目标硬件或模拟器可执行的代码。下图展示了整体的处理流程:

输入格式 → [自动/手动检测] → QASM 转换 → 编译器选择 → 输出文件

对于originir, qcis的输入文件,会qllvm能直接输入。

兼容性

下表列出了每种输入格式可使用的编译器,以及是否需要进行转换。

输入格式 QLLVM Qiskit QPanda 转换说明
QASM ✅ 支持 ✅ 支持 ✅ 支持 直接使用, 无需转换
Qiskit ✅ 支持 ✅ 支持 ✅ 支持 自动转换为 QASM 后再交给编译器
QPanda ✅ 支持 ✅ 支持 ✅ 支持 自动转换为 QASM 后再交给编译器
OriginIR ✅ 支持 ❌ 不支持 ❌ 不支持 直接输入给 QLLVM(需添加 -input-backend originir 参数)
QCIS ✅ 支持 ❌ 不支持 ❌ 不支持 直接输入给 QLLVM(需添加 -input-backend qcis 参数)

动态字段显示

不同编译器类型只显示相关的配置字段,防止误配置:

在本地编译勾选的情况下: | 编译器类型 | 可执行文件路径 | Python 解释器路径 | 专用参数区域 | |-----------|--------------|----------------|------------| | Qiskit | ❌ 隐藏 | ✅ 显示 | ✅ 显示 | | QPanda | ❌ 隐藏 | ✅ 显示 | ✅ 显示 | | QLLVM | ✅ 显示 | ❌ 隐藏 | ✅ 显示 |

在默认远程编译的情况下: | 编译器类型 | 可执行文件路径 | Python 解释器路径 | 专用参数区域 | |-----------|--------------|----------------|------------| | Qiskit | ❌ 隐藏 | ❌ 隐藏 | ✅ 显示 | | QPanda | ❌ 隐藏 | ❌ 隐藏 | ✅ 显示 | | QLLVM | ❌ 隐藏 | ❌ 隐藏 | ✅ 显示 |

QLLVM 专用参数详解

设备类型 (-qrt 参数)

指定目标量子设备类型,影响编译优化策略:

  • nisq: NISQ(含噪声中等规模量子设备),默认值
  • ftqc: FTQC(容错量子计算)
后端类型 (-qpu 参数)

指定目标后端代码生成器:

  • qasm-backend: 通用 QASM 后端,输出 .qasm 文件
  • originquantum: 本源量子设备,输出 .json 文件
  • tianyan: 天衍量子设备,输出 .py 文件
  • zheda: 浙大量子设备,输出 .txt 文件
优化等级

控制编译优化强度和策略:

  • O0: 不优化(调试用)
  • O1: 固定优化序列(日常使用,推荐)
基础门组 (-basicgate 参数)

指定基础门集合,默认值:rx,ry,rz,h,cz 常用组合:

  • [rx,ry,rz,h,cx]: 使用 CX 门替代 CZ 门
  • [su2,x,y,z,cz]: 对接测控系统
高级参数
  • -qpu-config <config_file>: 拓扑配置文件路径
  • -initial-mapping <list>: 初始比特映射(如 [0,1,2])
调试标志
  • -emitmlir: 输出 MLIR 中间表示
  • -emitqir: 输出 QIR 中间表示
  • --verbose: 详细输出模式
  • -circuit-state: 输出电路状态信息
  • -pass-count: 显示 Pass 计数统计
  • -sabre-cpp: 使用 C++ 实现的 SABRE 算法

更多信息

相关文档

  • VS Code 扩展开发文档
  • 量子计算入门指南
  • QLLVM 文档
  • Qiskit 文档
  • QPanda 文档
Q: 如何验证 Python 环境是否正确安装依赖?

A: 插件会自动检测并显示检测结果。也可以手动执行:

pip list | grep qiskit    # Linux/Mac
pip list | findstr qiskit # Windows
Q: QIR 模拟器如何使用?

A: 1. 在设置中配置 QIR 模拟器可执行文件路径(可选,支持系统 PATH 自动查找) 2. 打开量子电路文件(.qasm、.py、.qccs) 3. 点击编辑器标题栏的"运行量子电路"按钮或右键菜单选择对应命令 4. 查看输出面板中的仿真结果

Q: 远程编译失败怎么办?

A: 检查以下几点:

  1. SSH 连接是否正常(手动测试)
  2. 远程主机是否安装了 Python 和对应编译器
  3. 远程路径配置是否正确
  4. 认证方式(密钥/密码)是否匹配

English

A quantum programming plugin supporting multiple compiler options, designed to provide developers with a unified interface for various quantum compilation frameworks.

Features

  • Multi-Compiler Support: Supports multiple quantum compilation frameworks such as Qiskit, QPanda, and QLLVM, allowing simultaneous compilation comparisons.
  • Remote Compilation Support: Supports both local compilation and remote SSH compilation modes, with remote programming as the default mode.
  • Intelligent Environment Detection: Automatically detects Python environments and virtual environments (venv, conda, pyenv, etc.) on the system.
  • Flexible Configuration: Supports custom compiler parameters and optimization options.
  • Progress Display: Compilation process includes progress bars and detailed log output.
  • Compiler Configuration Management: Supports default and custom configurations with permission-level management.
  • Dynamic Field Display: Intelligently shows/hides relevant configuration fields based on the compiler type.
  • QIR Simulator Support: Integrates QIR simulator functionality for quantum circuit simulation and verification.

Supported Compiler Types

1. QLLVM
  • Direct input file types (qasm, originir, qcis)
  • Device type selection (NISQ/FTQC)
  • Backend type configuration (qasm-backend, originquantum, tianyan, zheda)
  • Optimization level control (O0/O1)
  • Basic gate set customization
  • QPU configuration file specification (originquantum: wukong72, tianyan: tianyan176, zheda: topology_13*12)
  • Initial qubit mapping
  • Detailed compilation information output
  • MLIR/QIR intermediate representation debugging
  • C/C++ executable path configuration (optional, supports automatic discovery via system PATH)
2. Qiskit (IBM)
  • Optimization level configuration (0-3)
  • Backend type selection (custom, ibm platform, scaleway)
  • Layout method selection (trivial, dense, noise_adaptive, sabre)
  • Coupling map configuration
  • Basic gate set customization
  • Initial layout configuration
  • Python interpreter path configuration
3. QPanda (Origin Quantum)
  • Backend type selection [custom, Origin chip: wokong180, wukong102_401, wukong72, (note: compute backends are subject to periodic updates)]
  • Topology configuration
  • Initial mapping setting
  • Optimization level (0-2)
  • Basic gate set definition
  • Pure decomposition mode support
  • Python interpreter path configuration

Main Commands

  • Open Quantum Compiler Settings (qcoder-compile.openCompilerSettings): Configure compiler-related parameters.
  • Compile Current Quantum Circuit File (qcoder-compile.compileCurrentFile): Perform multi-compiler parallel compilation on the currently open quantum circuit file.
  • Run Quantum Circuit (QIR Simulator) (qcoder-compile.runQirSimulator): Run the quantum circuit on the QIR simulator and obtain simulation results.

Usage

Basic Usage

  1. Open a Quantum Circuit File

    • Supports .qasm, .py, .qccs file formats.
  2. Right-Click Menu Operations

    • Right-click on the above file formats in the editor.
    • Select the corresponding quantum circuit compilation operation.
  3. Compiler Configuration

    • Enter the configuration interface via the "Open Quantum Compiler Settings" command.
    • Enable the required compilers.
    • Configure the specific parameters for each compiler.

Compilation Modes

Local Compilation

Execute compilation tasks directly in the local Python environment. Supports:

  • Automatic detection of Python interpreters on the system.
  • Scanning of project-level virtual environments (venv, .venv, env, etc.).
  • Scanning of Conda environments (~/.conda/envs, ~/anaconda/envs, etc.).
  • Priority usage of the Python path specified in the compiler configuration.
Remote Compilation

Connect to a remote server via SSH to execute compilation, supporting:

  • Configuration of remote Python environments.
  • Automatic retrieval of compilation results.
QIR Simulator Execution

Use the QIR simulator to perform quantum circuit simulation, supporting:

  • Automatic detection of the QIR simulator executable.
  • Support for automatic discovery via system PATH.
  • Display of simulation results and status information.

Output Viewing

Compilation results are displayed in the dedicated "Quantum Circuit Compilation Log" output channel, including:

  • ✓/✗ markers indicating success/failure status for each compiler.
  • Detailed error messages and stack traces.
  • Circuit metadata (qubit count, depth, etc.).
  • Compilation time statistics.
  • Paths to generated output files.
  • Compiler version information.

System Requirements

  • Visual Studio Code: >= 1.110.0
  • Node.js: >= 18.x
  • Python: qpanda(>= 3.8 && <= 3.11), qiskit(>= 3.5)

Python Dependencies

Depending on the compiler type used, the corresponding Python packages need to be installed:

# Qiskit
pip install qiskit qiskit-ibm-runtime

# QPanda
pip install qpanda3

# QLLVM
# After installing Qcoder, you will be prompted whether to install qllvm.

Compiler Configuration Management

Input Format and Compiler Compatibility

Overview

This plugin supports various frontend input formats and converts them into an intermediate representation (QASM) that backend compilers can process, ultimately outputting code executable on target hardware or simulators. The overall process flow is illustrated below:

Input Format → [Automatic/Manual Detection] → QASM Conversion → Compiler Selection → Output File

For originir and qcis input files, they can be directly fed into QLLVM.

Compatibility

The following table lists the available compilers for each input format and whether conversion is required.

Input Format QLLVM Qiskit QPanda Conversion Notes
QASM ✅ Supported ✅ Supported ✅ Supported Direct use, no conversion required.
Qiskit ✅ Supported ✅ Supported ✅ Supported Automatically converted to QASM before being passed to the compiler.
QPanda ✅ Supported ✅ Supported ✅ Supported Automatically converted to QASM before being passed to the compiler.
OriginIR ✅ Supported ❌ Not Supported ❌ Not Supported Direct input to QLLVM (requires adding -input-backend originir parameter).
QCIS ✅ Supported ❌ Not Supported ❌ Not Supported Direct input to QLLVM (requires adding -input-backend qcis parameter).

Dynamic Field Display

Different compiler types display only relevant configuration fields to prevent misconfiguration:

When local compilation is checked:

Compiler Type Executable Path Python Interpreter Path Compiler-Specific Parameters Area
Qiskit ❌ Hidden ✅ Displayed ✅ Displayed
QPanda ❌ Hidden ✅ Displayed ✅ Displayed
QLLVM ✅ Displayed ❌ Hidden ✅ Displayed

When remote compilation is the default:

Compiler Type Executable Path Python Interpreter Path Compiler-Specific Parameters Area
Qiskit ❌ Hidden ❌ Hidden ✅ Displayed
QPanda ❌ Hidden ❌ Hidden ✅ Displayed
QLLVM ❌ Hidden ❌ Hidden ✅ Displayed

QLLVM Specific Parameters Explanation

Device Type (-qrt Parameter)

Specifies the target quantum device type, affecting compilation optimization strategies:

  • nisq: NISQ (Noisy Intermediate-Scale Quantum devices), default value.
  • ftqc: FTQC (Fault-Tolerant Quantum Computing).
Backend Type (-qpu Parameter)

Specifies the target backend code generator:

  • qasm-backend: Generic QASM backend, outputs .qasm file.
  • originquantum: Origin Quantum devices, outputs .json file.
  • tianyan: Tianyan quantum devices, outputs .py file.
  • zheda: Zhejiang University quantum devices, outputs .txt file.
Optimization Level

Controls the strength and strategy of compilation optimizations:

  • O0: No optimization (for debugging).
  • O1: Fixed optimization sequence (recommended for daily use).
Basic Gate Set (-basicgate Parameter)

Specifies the basic gate set. Default value: rx,ry,rz,h,cz. Common combinations:

  • [rx,ry,rz,h,cx]: Uses CX gate instead of CZ gate.
  • [su2,x,y,z,cz]: Integrates with measurement and control systems.
Advanced Parameters
  • -qpu-config <config_file>: Path to the topology configuration file.
  • -initial-mapping <list>: Initial qubit mapping (e.g., [0,1,2]).
Debugging Flags
  • -emitmlir: Outputs MLIR intermediate representation.
  • -emitqir: Outputs QIR intermediate representation.
  • --verbose: Detailed output mode.
  • -circuit-state: Outputs circuit state information.
  • -pass-count: Displays pass count statistics.
  • -sabre-cpp: Uses C++ implementation of the SABRE algorithm.

More Information

Related Documentation

  • VS Code Extension Development Documentation
  • Quantum Computing Introductory Guide
  • QLLVM Documentation
  • Qiskit Documentation
  • QPanda Documentation
Q: How to verify that the Python environment has the required dependencies installed correctly?

A: The plugin will automatically detect and display the results. You can also manually execute:

pip list | grep qiskit    # Linux/Mac
pip list | findstr qiskit # Windows
Q: How to use the QIR simulator?

A:

  1. Configure the QIR simulator executable path in the settings (optional, supports automatic discovery via system PATH).
  2. Open a quantum circuit file (.qasm, .py, .qccs).
  3. Click the "Run Quantum Circuit" button in the editor title bar or select the corresponding command from the right-click menu.
  4. View the simulation results in the output panel.
Q: What if remote compilation fails?

A: Check the following:

  1. Is the SSH connection working properly (test manually)?
  2. Are Python and the required compilers installed on the remote host?
  3. Is the remote path configured correctly?
  4. Does the authentication method (key/password) match?

中文:开启你的量子编程之旅吧! 🚀 English: Enjoy quantum programming! 🚀

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft