microsoft/qdk

Public

mirrored fromhttps://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
9c33427155ee7a0d2f2beebc2f03d7c4609b6e4f

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.github/copilot-instructions.md

106lines · modecode

1# Copilot instructions for the `qsharp` repo
2
3## Overview
4
5This 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
9All internal source code for the compiler and related tooling has been moved under the `source/` directory at the repository root. This does not include Q# libraries (`library/`), samples (`samples/`), katas (`katas/`), or any standard files and folders typically found at the root of a repository (such as configuration, documentation, or build scripts).
10
11Most of the core components are implemented in Rust. These components are packaged in two ways:
12
131. Compiled as a native Python module and packaged into the `qsharp` Python package
142. Compiled into WebAssembly and packaged into the `qsharp-lang` npm package
15
16## Repo Contents
17
18**Rust**
19
20- **allocator/**: A copy of `mimalloc`, used for memory allocation in the Rust components of the QDK
21- **compiler/**: Core compiler and language processing components
22 - **qsc/**: Core compiler logic
23 - **qsc_ast/**: Abstract syntax tree definition and utilities
24 - **qsc_circuit/**: Circuit diagram representation and generation
25 - **qsc_codegen/**: Code generation utilities (QIR, Q#)
26 - **qsc_data_structures/**: Common data structures used by the compiler
27 - **qsc_doc_gen/**: Documentation generation tools
28 - **qsc_eval/**: Runtime evaluation and simulation
29 - **qsc_fir/**: Flat IR
30 - **qsc_formatter/**: Q# code formatter
31 - **qsc_frontend/**: Compiler frontend components
32 - **qsc_hir/**: High-level Intermediate Representation
33 - **qsc_linter/**: Code quality and style checking
34 - **qsc_lowerer/**: IR lowering transformations
35 - **qsc_parse/**: Q# parser
36 - **qsc_partial_eval/**: Partial evaluation and optimization
37 - **qsc_passes/**: HIR passes
38 - **qsc_project/**: Project system and manifest handling
39 - **qsc_openqasm_compiler/**: OpenQASM compiler frontend
40 - **qsc_openqasm_parser/**: OpenQASM parser frontend
41 - **qsc_rca/**: Resource counting and analysis
42 - **qsc_rir/**: Runtime Intermediate Representation
43- **fuzz/**: Fuzz testing infrastructure for the compiler
44- **language_service/**: Q# language service for editor features
45- **noisy_simulator/**: Simulator for quantum noise modeling
46- **resource_estimator/**: Quantum Resource Estimator implementation
47- **wasm/**: WebAssembly bindings for core components
48
49**Build & Release**
50
51- **docker/**: Docker container configurations
52
53**Python**
54
55- **pip/**: The `qsharp` Python package
56- **jupyterlab/**: JupyterLab extension for Q#
57- **widgets/**: Q# Jupyter widgets
58
59**Q# Content**
60
61- **katas/**: Quantum computing tutorials and exercises
62- **library/**: Q# standard and domain-specific libraries
63 - **chemistry/**: Chemistry-specific quantum operations
64 - **core/**: Q# core library
65 - **fixed_point/**: Fixed-point arithmetic support
66 - **qtest/**: Testing utilities
67 - **rotations/**: Quantum rotation operations
68 - **signed/**: Signed arithmetic operations
69 - **std/**: Q# standard library
70- **samples/**: Example Q# programs demonstrating language features
71- **samples_test/**: Tests for sample code
72
73**JavaScript/TypeScript**
74
75- **npm/**: The `qsharp-lang` npm package
76- **playground/**: Q# Playground website
77- **vscode/**: Visual Studio Code extension for Q#
78 - **src/**: Product source
79 - **test/**: Integration tests
80
81## Development Workflow
82
83- `./build.py` runs full CI checks, including lints and unit tests.
84- `./build.py --wasm --npm --vscode` only builds the VS Code extension, including its dependencies the WASM module and the `qsharp-lang` npm package.
85- `./build.py --pip` only builds the `qsharp` Python package, including its native dependencies.
86- Pass `--no-check` to `./build.py`, in combination with any other command line options, to skip the lints and formatting checks.
87- When working in Rust parts of the codebase, using `cargo` commands is usually more efficient than building via `./build.py`.
88 - Many lints can be auto-fixed via `cargo clippy --fix`.
89- When working in JavaScript/TypeScript parts of the codebase, using `npm` scripts is usually more efficient than building via `./build.py`.
90
91## Coding Standards
92
93- When adding new tests, follow the patterns established in existing tests in the same file or suite. Often, tests will use helper functions for brevity and readability. Design your tests to reuse these helpers where possible.
94- Before opening a PR, ensure the following.
95 - Code **must** be formatted by running `cargo fmt` and `npm run prettier:fix`.
96 - `./build.py` without any command-line arguments **must** run without errors or warnings.
97
98## Specific Guidelines for Parts of the Codebase
99
100### VS Code Integration Tests (`vscode/test/`)
101
102- `npm test` from the `vscode/` directory runs the integration tests.
103 - `npm test -- --suite=language-service`: Run only the `language-service` test suite
104- Tests use the VS Code for Web testing framework (`@vscode/test-web`), which uses `playwright` under the covers to automate headless Chrome.
105- `mocha` interface is used to declare tests, `chai` for asserts. No mocking library is used. Do _not_ add dependencies to the test suite.
106- Tests run in the real VS Code environment, in the extension host, which means they can directly interact with the VS Code API.