Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
648ef99
✨ Implement DD functionality for static unitary QCO `func.func` programs
simon1hofmann Jul 17, 2026
73fc132
πŸ“ Update CHANGELOG to remove entry for DD `buildFunctionality` / `sim…
simon1hofmann Jul 17, 2026
60aa8c7
🚨 Fix linter warnings
simon1hofmann Jul 17, 2026
f0e89c0
β˜‚οΈ Increase coverage
simon1hofmann Jul 17, 2026
70e7060
β˜‚οΈ Increase coverage
simon1hofmann Jul 17, 2026
69354d5
β˜‚οΈ Increase coverage
simon1hofmann Jul 17, 2026
027645c
πŸ‡ Address rabbit's comments
simon1hofmann Jul 17, 2026
6d231c2
Apply suggestions from code review
simon1hofmann Jul 17, 2026
98535b0
🎨 Suggestions from code review
Jul 17, 2026
570cc43
🚨 Fix linter warnings
Jul 17, 2026
fb2a83b
Merge branch 'main' into feat/dd-qco-functionality
simon1hofmann Jul 20, 2026
8e98fd5
Merge branch 'main' into feat/dd-qco-functionality
simon1hofmann Jul 22, 2026
b0190e6
🎨 pre-commit fixes
pre-commit-ci[bot] Jul 22, 2026
7332e3c
Merge origin/main into PR #1915 review branch
burgholzer Jul 22, 2026
42e1af9
Document QCO DD functionality
burgholzer Jul 22, 2026
e9f20ff
Separate QCO DD functionality library
burgholzer Jul 22, 2026
20210d9
Use direct DD construction for dense two-qubit gates
burgholzer Jul 22, 2026
5495c0a
Fix DD input ownership during QCO simulation
burgholzer Jul 22, 2026
34e1a7f
Reject non-canonical returned-qubit order
burgholzer Jul 22, 2026
32c8038
Verify full-width dense DD semantics
burgholzer Jul 22, 2026
b5dca90
Format QCO DD remediation
burgholzer Jul 22, 2026
d435a74
Consume DD simulation input on prepare failure
burgholzer Jul 22, 2026
2a394ce
Use the unitary interface compile-time check
burgholzer Jul 22, 2026
50acd4e
Support RCCX in QCO DD construction
burgholzer Jul 22, 2026
394d8aa
Include the DD node definition in tests
burgholzer Jul 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ releases may include breaking changes.

### Added

- ✨ Add decision diagram-based construction and simulation of static unitary
QCO functions ([#1915]) ([**@simon1hofmann**])
- ✨ Add native relative-phase CCX (`rccx`) support across the IR, DD package,
ZX diagrams, OpenQASM import/export, and Python/Qiskit bindings ([#1886])
([**@simon1hofmann**])
Expand Down Expand Up @@ -642,6 +644,7 @@ changelogs._

<!-- PR links -->

[#1915]: https://github.com/munich-quantum-toolkit/core/pull/1915
[#1914]: https://github.com/munich-quantum-toolkit/core/pull/1914
[#1911]: https://github.com/munich-quantum-toolkit/core/pull/1911
[#1904]: https://github.com/munich-quantum-toolkit/core/pull/1904
Expand Down
69 changes: 69 additions & 0 deletions mlir/include/mlir/Dialect/QCO/Utils/DDFunctionality.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright (c) 2023 - 2026 Chair for Design Automation, TUM
* Copyright (c) 2025 - 2026 Munich Quantum Software Company GmbH
* All rights reserved.
*
* SPDX-License-Identifier: MIT
*
* Licensed under the MIT License
*/

#pragma once

#include "dd/Package_fwd.hpp"

#include <mlir/Dialect/Func/IR/FuncOps.h>
#include <mlir/Support/LogicalResult.h>

namespace mlir::qco {

/**
* @brief Sequentially build a matrix DD for a static unitary QCO `func.func`.
*
* @details Walks the entry block of @p func, maps `qco.static` SSA values to
* wire indices (or, if none are present, qubit-typed function arguments as
* wires `0..n-1`), and applies unitary operations via decision-diagram
* multiplication.
*
* Supported programs:
* - Standard single- and two-qubit gates with compile-time constant parameters
* (sparse DD path)
* - `ctrl` with a sole standard-gate body (same sparse path)
* - Other `UnitaryOpInterface` ops with a compile-time known matrix (`inv`,
* compound `ctrl`, ...), including `gphase` and `barrier`
* - Skips: `static`, `sink`, `arith.constant`; `func.return` accepts qubit
* results only in canonical wire order
*
* Known one- and two-qubit matrices are constructed directly as DD gates. The
* dense matrix fallback accepts full-width unitaries on wires `0..n-1` and
* rewrites the QCO/MSB-first basis into the DD package's LSB-first indexing.
* Only this full-width fallback is limited to 12 qubits (dense `2^n Γ— 2^n`
* storage). Measurements, resets, symbolic parameters, and control-flow ops
* are not supported.
*
* @param func The QCO function to construct the functionality for
* @param dd The DD package to use (must hold at least the function's qubits)
* @return The matrix DD on success, or failure for unsupported programs
*/
FailureOr<dd::MatrixDD> buildFunctionality(func::FuncOp func, dd::Package& dd);

/**
* @brief Simulate a static unitary QCO `func.func` on a given input state.
*
* @details Same supported op set and limitations as @ref buildFunctionality.
* Mirrors @ref dd::simulate: sequentially applies unitaries to @p in via
* decision-diagram multiplication. Only purely quantum, measurement-free
* programs are supported. Consumes one reference to @p in regardless of
* whether simulation succeeds or fails.
*
* @param func The QCO function to simulate
* @param in The input state, represented as a vector DD; one reference is
* consumed
* @param dd The DD package to use (must hold at least the function's qubits)
* @return The output statevector DD on success, or failure for unsupported
* programs
*/
FailureOr<dd::VectorDD> simulate(func::FuncOp func, const dd::VectorDD& in,
dd::Package& dd);

} // namespace mlir::qco
25 changes: 23 additions & 2 deletions mlir/lib/Dialect/QCO/Utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ target_sources(MLIRQCOMatrix PUBLIC FILE_SET HEADERS BASE_DIRS ${MQT_MLIR_SOURCE
${MQT_MLIR_SOURCE_INCLUDE_DIR}/mlir/Dialect/QCO/Utils/Matrix.h)

file(GLOB_RECURSE UTILS_CPP "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
list(FILTER UTILS_CPP EXCLUDE REGEX "Matrix\\.cpp$")
list(FILTER UTILS_CPP EXCLUDE REGEX "(DDFunctionality|Matrix)\\.cpp$")

add_mlir_dialect_library(
MLIRQCOUtils
Expand All @@ -34,7 +34,7 @@ mqt_mlir_target_use_project_options(MLIRQCOUtils)

# collect header files
file(GLOB_RECURSE UTILS_HEADERS_SOURCE "${MQT_MLIR_SOURCE_INCLUDE_DIR}/mlir/Dialect/QCO/Utils/*.h")
list(FILTER UTILS_HEADERS_SOURCE EXCLUDE REGEX "Matrix\\.h$")
list(FILTER UTILS_HEADERS_SOURCE EXCLUDE REGEX "(DDFunctionality|Matrix)\\.h$")
file(GLOB_RECURSE UTILS_HEADERS_BUILD "${MQT_MLIR_BUILD_INCLUDE_DIR}/mlir/Dialect/QCO/Utils/*.inc")

# add public headers using file sets
Expand All @@ -52,3 +52,24 @@ target_sources(
${MQT_MLIR_BUILD_INCLUDE_DIR}
FILES
${UTILS_HEADERS_BUILD})

add_mlir_library(
MLIRQCODDFunctionality
PARTIAL_SOURCES_INTENDED
DDFunctionality.cpp
DEPENDS
MLIRQCOOpsIncGen
MLIRQCOInterfacesIncGen
LINK_LIBS
PUBLIC
MLIRQCODialect
MLIRQCOMatrix
MLIRFuncDialect
MQT::CoreDD)

mqt_mlir_target_use_project_options(MLIRQCODDFunctionality)

target_sources(
MLIRQCODDFunctionality
PUBLIC FILE_SET HEADERS BASE_DIRS ${MQT_MLIR_SOURCE_INCLUDE_DIR} FILES
${MQT_MLIR_SOURCE_INCLUDE_DIR}/mlir/Dialect/QCO/Utils/DDFunctionality.h)
Loading
Loading