Skip to content
Open
102 changes: 102 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# MQT Core

- Acts as the high-performance backbone for the [Munich Quantum Toolkit (MQT)](https://mqt.readthedocs.io/).
- Provides core data structures and algorithms (IR, DD, ZX, QASM 3.0, MLIR) for quantum design automation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Provides core data structures and algorithms (IR, DD, ZX, QASM 3.0, MLIR) for quantum design automation.
- Provides tools and methods (IRs, DD, ZX, OpenQASM, MLIR, QIR, QDMI, NA, Qiskit, etc.) for quantum design automation, including simulation, compilation, verification as well as HPCQC integration.

Trying to rephrase this a little.

- Distinguishes between **circuit qubits** (logical/virtual) and **device qubits** (physical) to avoid ambiguity.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Distinguishes between **circuit qubits** (logical/virtual) and **device qubits** (physical) to avoid ambiguity.

Feels overly detailed and not too important for most day to day use.

- Maintains a C++20 core with an architecturally separate Python extension layer.
- Locates C++ sources in `src/` and `include/`, Python bindings in `python/`, tests in `test/`, and documentation in `docs/`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not fully correct and complete.
Yes, most of the C++ code is in src and include, but the entire MLIR codebase is under mlir.
The Python bindings actually reside in bindings, while the Python package code lives in python/mqt/core.

- Refer to [index.md](docs/index.md) for the complete documentation entry point.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given how an LLM won't be able to access a built version of the docs, this feels slightly unnecessary.

Suggested change
- Refer to [index.md](docs/index.md) for the complete documentation entry point.


## Environment & Capabilities

- **Platform**: Operating in a Linux environment with support for x86_64 (amd64) and arm64.
- **Python Context**: Version 3.10+ managed via **uv** for strict isolation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **Python Context**: Version 3.10+ managed via **uv** for strict isolation.
- **Python Context**: Version 3.10+ managed via **uv**.

I don't particularly know what the "strict isolation" part means here.

- **C++ Context**: C++20 standard required; **LLVM 21.1+** mandatory for MLIR dialects.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **C++ Context**: C++20 standard required; **LLVM 21.1+** mandatory for MLIR dialects.
- **C++ Context**: C++20 standard required; **LLVM 21.1+** mandatory for MLIR infrastructure.

- **Tooling Access**: Full access to `cmake`, `ctest`, `pytest`, `ruff`, and `nox`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **Tooling Access**: Full access to `cmake`, `ctest`, `pytest`, `ruff`, and `nox`.
- **Tooling Access**: Full access to `cmake`, `ctest`, `uv`, and `nox`.

Pytest is only available if the project is synced, and ruff is part of the linting setup and not available explicitly. In contrast, uv can be assumed to be available.

- **Constraint**: Avoid network-dependent tasks during builds; rely on `uv` lockfiles and pre-synced dependencies.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is very hard to enforce. Since we use FetchContent, any CMake build will most likely try to fetch some of the dependencies.
How to set up a full no-network build is yet to be documented.
Thus, I think this sentence can be removed here.


## Repository Mapping

- `include/mqt/core/`: C++ header files (Internal & Public interfaces).
- `src/mqt/core/`: C++ implementation logic.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not correct. the corresponding directory does not even exist.

- `python/mqt/core/`: Python package foundation.
- `python/mqt/core/ir/`: Public Python bindings package for Circuit IR.
- `python/mqt/core/dd.pyi`: Public Python bindings module for Decision Diagrams.
- `python/mqt/core/na/`: Public Python bindings package for Neutral Atom logic.
Comment on lines +22 to +25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wildly different in granularity than the rest. The C++ part also does not show any modules for example.

- `test/`: Comprehensive test suites (C++ and Python).
- `docs/`: Knowledge base for installation, contribution, and technical references.

## Tasks

### C++ Workflows

- Configure Release build: `cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_MQT_CORE_TESTS=ON`.
- Configure Debug build: `cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DBUILD_MQT_CORE_TESTS=ON`.
Comment on lines +33 to +34
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Optional: Em dash style for consistency.

The static analysis tool suggests using em dashes (—) instead of colons for enumeration consistency. This is purely a stylistic preference and the current format is perfectly clear.

✍️ Optional style improvement
-- Configure Release build: `cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_MQT_CORE_TESTS=ON`.
-- Configure Debug build: `cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DBUILD_MQT_CORE_TESTS=ON`.
+- Configure Release build — `cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_MQT_CORE_TESTS=ON`.
+- Configure Debug build — `cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DBUILD_MQT_CORE_TESTS=ON`.
🧰 Tools
🪛 LanguageTool

[typographical] ~33-~33: Consider using an em dash and a white space in dialogues and enumerations.
Context: ...+ Workflows - Configure Release build: `cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUI...

(DASH_RULE)


[typographical] ~34-~34: Consider using an em dash and a white space in dialogues and enumerations.
Context: ...ORE_TESTS=ON. - Configure Debug build: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DBUILD...

(DASH_RULE)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@AGENTS.md` around lines 33 - 34, Replace the colon after "Configure Release
build" and "Configure Debug build" with an em dash (—) for consistent em-dash
style in the two bullet lines; edit the two lines that currently read "Configure
Release build: `...`" and "Configure Debug build: `...`" to use an em dash
before the inline code block instead of a colon.

Comment on lines +33 to +34
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the -DBUILD_MQT_CORE_TESTS=ON is not explicitly necessary as it defaults to ON

- Build the library: `cmake --build build --parallel`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, this is not correct as-is and needs an integer after the --parallel.
Generally, the better advice would probably be to use ninja as a generator (-G Ninja) in the CMake configure step, which automatically parallelizes.

- Run C++ tests: `ctest --test-dir build -C Release --output-on-failure`.
- Run a single C++ test: `ctest --test-dir build -C Release -R <test_name>`.
Comment on lines +36 to +37
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably be good to also highlight the new label for running the MLIR tests introduced in #1513 (ctest -L mqt-mlir-unittests)

- Locate C++ artifacts in `build/src/` (libraries) and `build/test/` (test executables).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not particularly complete. All the MLIR build output will be in build/mlir for example.


### Python Workflows

- Build the Python package: `uv build`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not locally build the Python package; it builds an sdist and a wheel.
The right command here would be uv sync

- Locate Python build artifacts in `build/{wheel_tag}/{build_type}` or the project `build/` folder.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels redundant as one includes the other.

- Execute full test suite: `uvx nox -s tests`.
- Run targeted tests: `uv run pytest test/python/dd/`.
- Filter Python tests: `uvx nox -s tests -- -k "<test_name>"`.
- Test minimum dependency versions: `uvx nox -s minimums`.
- Verify Qiskit compatibility: `uvx nox -s qiskit`.
Comment on lines +44 to +48
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably also show the versions that run a single python version, e.g., uvx nox -s tests-3.13.
These should probably be the default, as they are quicker to execute than the tests on all platforms.


### Quality, Docs & Stubs

- Run pre-commit checks: `uvx prek run -a` or `uvx nox -s lint`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Run pre-commit checks: `uvx prek run -a` or `uvx nox -s lint`.
- Run prek checks: `uvx nox -s lint`.

probably best to not list too many alternatives.

- Build documentation (Doxygen + Sphinx + MLIR): `uvx nox -s docs`.
- Locate documentation output in `docs/_build/html`.
- Generate type stubs: `uvx nox -s stubs`.
- Note: Stub files (`.pyi`) must **never** be edited manually.
- Check [contributing.md](docs/contributing.md) for comprehensive PR workflows and testing philosophies.

## Tools

- Use **C++20** and **Python 3.10+** as the strict minimum language versions.
- Use **CMake 3.24+** and **scikit-build-core** for the build system.
- Use **uv** as the mandatory package manager; never use `pip` or manual `venv`.
- Use **nanobind** (~2.11.0) for Python bindings; do not use `pybind11`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Use **nanobind** (~2.11.0) for Python bindings; do not use `pybind11`.
- Use **nanobind** for Python bindings; do not use `pybind11`.

Feels like information that quickly becomes outdated.

- Use **ruff** for linting and formatting, with `ALL` rules enabled by default.
- Use **ty** for static type checking as the mandatory replacement for `mypy`.
- Use **LLVM 21.1+** for MLIR-based compilation dialects.
- Use **clang-format** and **typos** for C++ style and project-wide spell checking.
Comment on lines +61 to +68
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These all sound like orders, while they should probably be descriptions of what the repository is using in terms of tooling.


## Development Guidelines

- Always prioritize C++20 `std::` features over custom implementations.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Always prioritize C++20 `std::` features over custom implementations.
- Always prioritize C++20 STL features over custom implementations.

It might be worth mentioning that within the MLIR part of the codebase (mlir/...) we prefer LLVM datastructures and methods (llvm::SmallVector, llvm::function_ref, etc.) over the C++ STL.

- Use Google-style docstrings for Python and Doxygen comments for C++.
- Ensure Python code is fully typed and passes `ty` static analysis.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is okay as a general statement, but I think the agent file itself needs to provide some more actionable advice that is to the point. Something like

- Run `uvx nox -s lint` after performing changes and ensure that it passes without error.
``

- Follow existing code style by checking neighboring files for patterns.
- Add or update tests for every code change, even if not explicitly requested.
- Review [CHANGELOG.md](docs/CHANGELOG.md) and [UPGRADING.md](docs/UPGRADING.md) before making breaking changes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above also holds here. This needs to be actionable. The agent shall review the guides... and then what?


## Documentation Reference

- Deep dive into the Internal Representation: [mqt_core_ir.md](docs/mqt_core_ir.md).
- Understand Decision Diagram internals: [dd_package.md](docs/dd_package.md).
- Explore ZX-calculus algorithms: [zx_package.md](docs/zx_package.md).
- Access the online API reference: [MQT Core Docs](https://mqt.readthedocs.io/projects/core/en/latest/).
Comment on lines +79 to +84
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Documentation Reference
- Deep dive into the Internal Representation: [mqt_core_ir.md](docs/mqt_core_ir.md).
- Understand Decision Diagram internals: [dd_package.md](docs/dd_package.md).
- Explore ZX-calculus algorithms: [zx_package.md](docs/zx_package.md).
- Access the online API reference: [MQT Core Docs](https://mqt.readthedocs.io/projects/core/en/latest/).

Does not feel too useful for day to day use.


## Self-Review Checklist

- Did you run `uvx nox -s lint` and ensure all checks (ruff, typos, ty) pass?
- Did you verify all your changes with at least one automated test (pytest or ctest)?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Did you verify all your changes with at least one automated test (pytest or ctest)?
- Did you verify all your changes with at least one automated test (pytest or googletest)?

ctest is only the test runner. googletest is the framework we use for testing

- Did you update/add tests for new functionality to maintain coverage?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels redundant with the point above.

- Did you use exact terminology (**circuit qubits** vs **device qubits**)?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Did you use exact terminology (**circuit qubits** vs **device qubits**)?

Not needed based on the comment at the very top.

- Did you regenerate Python stubs via `uvx nox -s stubs` if bindings were modified?
- Did you check for manual changes to `.pyi` files (which are forbidden)?
- Did you include the correct license headers and SPDX identifiers?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is automatically handled by prek. no need to state this here

Suggested change
- Did you include the correct license headers and SPDX identifiers?


## Rules

- Adhere to the ruff philosophy: Start with `ALL` rules and selectively disable in `pyproject.toml`.
- Enforce term capitalization: `nanobind`, `CMake`, `ccache`, `GitHub`, `NumPy`, `pytest`, `MQT`, and `TUM`.
- Include MIT license and SPDX headers in every source file.
- Avoid modifying templated files locally; contribute to [MQT templates](https://github.com/munich-quantum-toolkit/templates).
- Verify all CI checks locally; if `uvx nox -s lint` fails, the code is not ready for PR.
Comment on lines +96 to +102
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it is repeating some information from above incompletely.

Loading