microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
.github/copilot-instructions.md
89lines · modecode
| 1 | # Copilot instructions for the `qsharp` repo |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | This repo contains the Microsoft Quantum Development Kit (QDK), which provides tooling for the Q# language. Q# is an open-source programming language designed for developing and running quantum algorithms. This repo is publicly available at https://github.com/microsoft/qsharp . |
| 6 | |
| 7 | ## Architecture |
| 8 | |
| 9 | Most of the core components are implemented in Rust. These components are packaged in two ways: |
| 10 | |
| 11 | 1. Compiled as a native Python module and packaged into the `qsharp` Python package |
| 12 | 2. Compiled into WebAssembly and packaged into the `qsharp-lang` npm package |
| 13 | |
| 14 | ## Repo Contents |
| 15 | |
| 16 | **Rust** |
| 17 | |
| 18 | - **allocator/**: A copy of `mimalloc`, used for memory allocation in the Rust components of the QDK |
| 19 | - **compiler/**: Core compiler and language processing components |
| 20 | - **qsc/**: Core compiler logic |
| 21 | - **qsc_ast/**: Abstract syntax tree definition and utilities |
| 22 | - **qsc_circuit/**: Circuit diagram representation and generation |
| 23 | - **qsc_codegen/**: Code generation utilities (QIR, Q#) |
| 24 | - **qsc_data_structures/**: Common data structures used by the compiler |
| 25 | - **qsc_doc_gen/**: Documentation generation tools |
| 26 | - **qsc_eval/**: Runtime evaluation and simulation |
| 27 | - **qsc_fir/**: Flat IR |
| 28 | - **qsc_formatter/**: Q# code formatter |
| 29 | - **qsc_frontend/**: Compiler frontend components |
| 30 | - **qsc_hir/**: High-level Intermediate Representation |
| 31 | - **qsc_linter/**: Code quality and style checking |
| 32 | - **qsc_lowerer/**: IR lowering transformations |
| 33 | - **qsc_parse/**: Q# parser |
| 34 | - **qsc_partial_eval/**: Partial evaluation and optimization |
| 35 | - **qsc_passes/**: HIR passes |
| 36 | - **qsc_project/**: Project system and manifest handling |
| 37 | - **qsc_qasm/**: OpenQASM compiler frontend |
| 38 | - **qsc_rca/**: Resource counting and analysis |
| 39 | - **qsc_rir/**: Runtime Intermediate Representation |
| 40 | - **fuzz/**: Fuzz testing infrastructure for the compiler |
| 41 | - **language_service/**: Q# language service for editor features |
| 42 | - **noisy_simulator/**: Simulator for quantum noise modeling |
| 43 | - **resource_estimator/**: Quantum Resource Estimator implementation |
| 44 | - **wasm/**: WebAssembly bindings for core components |
| 45 | |
| 46 | **Build & Release** |
| 47 | - **docker/**: Docker container configurations |
| 48 | |
| 49 | **Python** |
| 50 | |
| 51 | - **pip/**: The `qsharp` Python package |
| 52 | - **jupyterlab/**: JupyterLab extension for Q# |
| 53 | - **widgets/**: Q# Jupyter widgets |
| 54 | |
| 55 | **Q# Content** |
| 56 | |
| 57 | - **katas/**: Quantum computing tutorials and exercises |
| 58 | - **library/**: Q# standard and domain-specific libraries |
| 59 | - **chemistry/**: Chemistry-specific quantum operations |
| 60 | - **core/**: Q# core library |
| 61 | - **fixed_point/**: Fixed-point arithmetic support |
| 62 | - **qtest/**: Testing utilities |
| 63 | - **rotations/**: Quantum rotation operations |
| 64 | - **signed/**: Signed arithmetic operations |
| 65 | - **std/**: Q# standard library |
| 66 | - **samples/**: Example Q# programs demonstrating language features |
| 67 | - **samples_test/**: Tests for sample code |
| 68 | |
| 69 | **JavaScript/TypeScript** |
| 70 | |
| 71 | - **npm/**: The `qsharp-lang` npm package |
| 72 | - **playground/**: Q# Playground website |
| 73 | - **vscode/**: Visual Studio Code extension for Q# |
| 74 | |
| 75 | ## Development workflow |
| 76 | |
| 77 | - `./build.py` runs full CI checks, including lints and unit tests. |
| 78 | - `./build.py --wasm --npm --vscode` to only build the VS Code extension, including its dependencies the WASM module and the `qsharp-lang` npm package. |
| 79 | - `./build.py --pip` to only build the `qsharp` Python package. |
| 80 | - When working in Rust parts of the codebase, using `cargo` commands is usually more efficient than building via `./build.py`. |
| 81 | - Many lints can be auto-fixed via `cargo clippy --fix`. |
| 82 | - When working in JavaScript/TypeScript parts of the codebase, using `npm` commands is usually more efficient than building via `./build.py`. |
| 83 | |
| 84 | ## Coding Standards |
| 85 | |
| 86 | Before opening a PR, ensure the following. |
| 87 | |
| 88 | - Code **must** be formatted by running `cargo fmt` and `npm run prettier:fix`. |
| 89 | - `./build.py` without any command-line arguments **must** run without errors or warnings. |
| 90 | |