Skip to content

Commit cfd023f

Browse files
mergify[bot]keefehuangpre-commit-ci[bot]denialhaag
authored
✨ Add support for multi-controlled gates to ZX package (backport #1380) (#1651)
## Description Add CRZ, MCX, MCZ, MCRZ functionality to ZX package. Add convenience addCCZ function as it avoids one additional Hardamard edge (optimizes it away). Fixes #1357 ## Checklist: - [X] The pull request only contains commits that are focused and relevant to this change. - [X] I have added appropriate tests that cover the new/changed functionality. - [X] ~~I have updated the documentation to reflect these changes.~~ - [x] I have added entries to the changelog for any noteworthy additions, changes, fixes, or removals. - [x] ~~I have added migration instructions to the upgrade guide (if needed).~~ - [x] The changes follow the project's style guidelines and introduce no new warnings. - [x] The changes are fully tested and pass the CI checks. - [X] I have reviewed my own code changes. (cherry picked from commit 2497aee) --------- Co-authored-by: Keefe Huang <30915130+keefehuang@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel Haag <121057143+denialhaag@users.noreply.github.com>
1 parent 8b82352 commit cfd023f

4 files changed

Lines changed: 761 additions & 137 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning], with the exception that minor rel
1111

1212
### Added
1313

14+
- ✨ Add support for multi-controlled gates to ZX package ([#1380]) ([**@keefehuang**])
1415
- ✨ Add Sampler and Estimator Primitives to the QDMI-Qiskit Interface ([#1507]) ([**@marcelwa**])
1516

1617
### Changed
@@ -342,6 +343,7 @@ _📚 Refer to the [GitHub Release Notes](https://github.com/munich-quantum-tool
342343
[#1383]: https://github.com/munich-quantum-toolkit/core/pull/1383
343344
[#1382]: https://github.com/munich-quantum-toolkit/core/pull/1382
344345
[#1381]: https://github.com/munich-quantum-toolkit/core/pull/1381
346+
[#1380]: https://github.com/munich-quantum-toolkit/core/pull/1380
345347
[#1378]: https://github.com/munich-quantum-toolkit/core/pull/1378
346348
[#1375]: https://github.com/munich-quantum-toolkit/core/pull/1375
347349
[#1371]: https://github.com/munich-quantum-toolkit/core/pull/1371
@@ -485,6 +487,7 @@ _📚 Refer to the [GitHub Release Notes](https://github.com/munich-quantum-tool
485487
[**@lsschmid**]: https://github.com/lsschmid
486488
[**@marcelwa**]: https://github.com/marcelwa
487489
[**@lirem101**]: https://github.com/lirem101
490+
[**@keefehuang**]: https://github.com/keefehuang
488491

489492
<!-- General links -->
490493

include/mqt-core/zx/FunctionalityConstruction.hpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,14 @@ class FunctionalityConstruction {
8585
EdgeType type = EdgeType::Simple);
8686
static void addCphase(ZXDiagram& diag, const PiExpression& phase, Qubit ctrl,
8787
Qubit target, std::vector<Vertex>& qubits);
88-
static void addSwap(ZXDiagram& diag, Qubit target, Qubit target2,
88+
static void addMcphase(ZXDiagram& diag, const PiExpression& phase,
89+
const std::vector<Qubit>& controls, Qubit target,
90+
std::vector<Vertex>& qubits);
91+
static void addSwap(ZXDiagram& diag, Qubit target1, Qubit target2,
8992
std::vector<Vertex>& qubits);
93+
static void addMcswap(ZXDiagram& diag, const std::vector<Qubit>& controls,
94+
Qubit target1, Qubit target2,
95+
std::vector<Vertex>& qubits);
9096
static void
9197
addRzz(ZXDiagram& diag, const PiExpression& phase, Qubit target,
9298
Qubit target2, std::vector<Vertex>& qubits,
@@ -99,6 +105,11 @@ class FunctionalityConstruction {
99105
addRzx(ZXDiagram& diag, const PiExpression& phase, Qubit target,
100106
Qubit target2, std::vector<Vertex>& qubits,
101107
const std::optional<double>& unconvertedPhase = std::nullopt);
108+
static void
109+
addMcrzz(ZXDiagram& diag, const PiExpression& phase,
110+
const std::vector<Qubit>& controls, Qubit target, Qubit target2,
111+
std::vector<Vertex>& qubits,
112+
const std::optional<double>& unconvertedPhase = std::nullopt);
102113
static void addDcx(ZXDiagram& diag, Qubit qubit1, Qubit qubit2,
103114
std::vector<Vertex>& qubits);
104115
static void
@@ -113,6 +124,22 @@ class FunctionalityConstruction {
113124
const std::optional<double>& unconvertedBeta = std::nullopt);
114125
static void addCcx(ZXDiagram& diag, Qubit ctrl0, Qubit ctrl1, Qubit target,
115126
std::vector<Vertex>& qubits);
127+
static void addCcz(ZXDiagram& diag, Qubit ctrl0, Qubit ctrl1, Qubit target,
128+
std::vector<Vertex>& qubits);
129+
static void addCrx(ZXDiagram& diag, const PiExpression& phase, Qubit control,
130+
Qubit target, std::vector<Vertex>& qubits);
131+
static void addMcrx(ZXDiagram& diag, const PiExpression& phase,
132+
const std::vector<Qubit>& controls, Qubit target,
133+
std::vector<Vertex>& qubits);
134+
static void addCrz(ZXDiagram& diag, const PiExpression& phase, Qubit control,
135+
Qubit target, std::vector<Vertex>& qubits);
136+
static void addMcrz(ZXDiagram& diag, const PiExpression& phase,
137+
std::vector<Qubit> controls, Qubit target,
138+
std::vector<Vertex>& qubits);
139+
static void addMcx(ZXDiagram& diag, std::vector<Qubit> controls, Qubit target,
140+
std::vector<Vertex>& qubits);
141+
static void addMcz(ZXDiagram& diag, const std::vector<Qubit>& controls,
142+
Qubit target, std::vector<Vertex>& qubits);
116143
static op_it parseOp(ZXDiagram& diag, op_it it, op_it end,
117144
std::vector<Vertex>& qubits, const qc::Permutation& p);
118145
static op_it parseCompoundOp(ZXDiagram& diag, op_it it, op_it end,

0 commit comments

Comments
 (0)