microsoft/qdk
GitHub: microsoft/qdk
微软官方量子开发套件,提供 Q# 语言编译器、量子资源估算器及丰富的开发工具,帮助开发者在经典环境中编写、编译和评估量子程序。
Stars: 969 | Forks: 202
# Microsoft Quantum Development Kit
欢迎使用 Microsoft Quantum Development Kit!
本仓库包含 Q# 语言的工具,具体包括:
- **[编译器](./source/compiler/qsc/)**:核心编译器逻辑和命令行工具
- **[fuzz](./source/fuzz/)**:模糊测试基础设施
- **[jupyterlab](./source/jupyterlab/)**:JupyterLab 扩展
- **[language_service](./source/language_service/)**:Q# 语言服务和编辑器功能
- **[library](./library/)**:Q# 标准库
- **[npm](./source/npm/)**:Q# npm 包
- **[pip](./source/pip/)**:Q# Python pip 包
- **[playground](./source/playground/)**:用于与 Q# 交互的简单网站
- **[resource_estimator](./source/resource_estimator)**:Microsoft Quantum Resource Estimator 的实现
- **[vscode](./source/vscode/)**:Visual Studio Code 扩展
- **[wasm](./source/wasm/)**:WebAssembly 模块的绑定和逻辑
- **[widgets](./source/widgets)**:Q# Jupyter widgets Python 包
此外,`./katas` 和 `./samples` 目录中分别包含了教程和示例。
本仓库的代码为 上的 Q# 开发体验提供支持。
## 构建说明
要构建本仓库,需要安装一些依赖项。它们是:
- Python ()
- Rust ()
- 在所有平台上,必须安装 `wasm32-unknown-unknown` 才能构建基于 WASM 的组件
rustup target add wasm32-unknown-unknown
- 在 MacOS 上,请确保已安装 `aarch64` 和 `x86_64` target,否则会遇到链接错误。
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
- Node.js ( )
- 一个 [C 编译器](https://docs.rs/cc/latest/cc/#compile-time-requirements)
- wasm-bindgen (参见 )
- wasm-opt (参见 )
最后两项可以通过运行 `python ./prereqs.py --install` 安装到您的 HOME 目录下。
构建脚本会检查这些依赖项及其版本,如果不满足要求将会失败。(或者直接运行
`python ./prereqs.py` 来检查是否安装了最低要求的版本)。
要进行构建,请在根目录下运行 `python ./build.py`。默认情况下,这将对每个项目
执行 release 构建,包括运行测试以及代码检查(如 linting)等检查。请使用
`--help` 选项查看详细的用法说明。
### Playground
`playground` 是一个小型网站,用于加载 Q# 编辑器、编译器、示例、katas 以及标准库的文档。这是一种手动验证您对这些组件所做更改的方法。
要查看有关构建 playground 的说明,请参阅[在本地构建 Playground](./source/playground/README.md#building-the-playground-locally)。
### Python
在构建 Python 包(`pip` 和 `jupyterlab`)时,如果构建脚本没有检测到
当前的 Python 虚拟环境,它将自动在 `source/pip/.venv` 或
`source/jupyterlab/.venv` 下创建一个。在本地开发时,您可以通过运行 `source .venv/bin/activate` (Linux/MacOS) 或 `.venv/Scripts/activate.bat` (Windows) 来使用这些虚拟环境运行测试。
## 代码编辑
在本仓库中进行开发的最简单方法是使用 VS Code。当您打开项目根目录时,默认
情况下 VS Code 会建议您安装 `.vscode/extensions.json` 中列出的扩展。
这些扩展提供了用于编辑的语言服务,以及用于
确保代码满足要求的 linter 和 formatter(这些要求由 `build.py` 脚本和 CI 进行检查)。
这里推荐(但不强制)使用一些设置以使开发更容易。它们位于
`.vscode/*.shared.json` 文件中。如果安装了 [Workspace Config+](https://marketplace.visualstudio.com/items?itemName=swellaby.workspace-config-plus)
扩展,它将自动应用这些设置,以及
您自己对应的 `.vscode/*.local.json` 设置中的覆盖项。如果您不安装此扩展,您可以将
它们作为编辑您自己的 `.vscode/*.json` 设置文件的参考。(有关更多详细信息,请参阅该扩展的主页)。
## 调试
调试 VS Code 扩展最好在 VS Code 内部通过按 F5
(或从 VS Code 菜单中选择 `Run / Start Debugging`)启动来完成。如果使用了
上述提到的 `Workspace Config+` 扩展,将应用 `launch.shared.json`
文件,这包含一个命令行标志,用于启动名为 `dev` 的配置文件的开发实例。(如果不熟悉 VS Code 的配置文件,请参见
)。
这允许您在启用了所有常规
扩展(包括 QDK)的主 VS Code 实例中进行开发,但使用仅
包含用于测试的最小扩展(例如 GitHub Copilot、Python、
Jupyter)的 `dev` 配置文件。这避免了以下问题:在禁用所有扩展的情况下启动会
阻止您测试 Copilot、Python 等,而在启用默认
扩展的情况下启动会导致已安装的 QDK 与正在调试的 QDK 之间产生冲突。
默认情况下,调试器将启动一个在工作区中打开了 `./samples`
目录的 VS Code 实例。目录 `samples/scratch` 已通过 `.gitignore` 从仓库中排除,因此您可以在此
目录中处理临时文件,而不会使您的 `git diff` 变得混乱,也不会意外地将它们签入。
## 引用
如果您使用了 Q#、Microsoft Quantum Development Kit 或 Microsoft Quantum Resource Estimator,请按以下方式引用:
- Microsoft Quantum Development Kit:
```
@software{Microsoft_Quantum_Development_Kit,
author = {{Microsoft}},
license = {MIT},
title = {{Microsoft Quantum Development Kit}},
url = {https://github.com/microsoft/qdk} }
```
- Q# 编程语言:
```
@inproceedings{Svore_2018, series={RWDSL2018},
title={{Q\#: Enabling Scalable Quantum Computing and Development with a High-level DSL}},
url={http://dx.doi.org/10.1145/3183895.3183901},
DOI={10.1145/3183895.3183901},
booktitle={Proceedings of the Real World Domain Specific Languages Workshop 2018},
publisher={ACM},
author={Svore, Krysta and Geller, Alan and Troyer, Matthias and Azariah, John and Granade, Christopher and Heim, Bettina and Kliuchnikov, Vadym and Mykhailova, Mariia and Paz, Andres and Roetteler, Martin},
year={2018},
month=feb, collection={RWDSL2018} }
```
- Microsoft Quantum Resource Estimator:
```
@inproceedings{Microsoft_Quantum_Resource_Estimator,
author = {van Dam, Wim and Mykhailova, Mariia and Soeken, Mathias},
title = {{Using Azure Quantum Resource Estimator for Assessing Performance of Fault Tolerant Quantum Computation}},
year = {2023},
isbn = {9798400707858},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/3624062.3624211},
doi = {10.1145/3624062.3624211},
booktitle = {Proceedings of the SC '23 Workshops of The International Conference on High Performance Computing, Network, Storage, and Analysis},
pages = {1414–1419},
numpages = {6},
series = {SC-W '23} }
```
## 反馈
如果您对本仓库中的内容有任何反馈,请通过提交一个[新 issue](https://github.com/microsoft/qdk/issues/new/choose) 来告诉我们!
## 报告安全问题
安全问题和 bug 应按照我们的[安全问题文档](./SECURITY.md#reporting-security-issues)私下报告。
## 法律与许可
### 商标
本项目可能包含项目、产品或服务的商标或徽标。授权使用 Microsoft
商标或徽标受以下约束并必须遵循
[Microsoft 商标与品牌指南](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general)。
在本项目的修改版本中使用 Microsoft 商标或徽标不得引起混淆,
也不得暗示 Microsoft 的赞助。任何对第三方商标或徽标的使用均受这些
第三方的政策约束。
标签:AI工具, MITM代理, 可视化界面, 逆向工具, 通知系统