From 69b3706e194e873b7ffa46cc9f6ac03a6e5d699c Mon Sep 17 00:00:00 2001 From: burgholzer Date: Mon, 25 Nov 2024 16:31:16 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9A=A1=20skip=20ancillary=20and=20garbag?= =?UTF-8?q?e=20setup=20on=20equal=20number=20of=20qubits?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: burgholzer --- src/EquivalenceCheckingManager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/EquivalenceCheckingManager.cpp b/src/EquivalenceCheckingManager.cpp index dd4614c7..ba2b8591 100644 --- a/src/EquivalenceCheckingManager.cpp +++ b/src/EquivalenceCheckingManager.cpp @@ -189,6 +189,10 @@ void EquivalenceCheckingManager::setupAncillariesAndGarbage() { const auto qubitDifference = largerCircuit.getNqubits() - smallerCircuit.getNqubits(); + if (qubitDifference == 0) { + return; + } + std::vector>> removed{}; removed.reserve(qubitDifference); From 720d7f37a452512df5b54776674647815009445c Mon Sep 17 00:00:00 2001 From: burgholzer Date: Mon, 25 Nov 2024 16:35:52 +0100 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=A7=AA=20add=20a=20couple=20of=20fail?= =?UTF-8?q?ing=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: burgholzer --- test/python/test_verify.py | 27 ++++++++++++++++++++++++ test/test_zx.cpp | 42 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/test/python/test_verify.py b/test/python/test_verify.py index 38fb1ff2..4287c6bd 100644 --- a/test/python/test_verify.py +++ b/test/python/test_verify.py @@ -93,3 +93,30 @@ def test_cpp_exception_propagation_internal() -> None: with pytest.raises(ValueError, match="Lookahead application scheme can only be used for matrices."): qcec.verify(qc, qc, configuration=config) + + +def test_zx_ancilla_support() -> None: + """This is a regression test for the handling of ancilla registers in the ZX checker.""" + from qiskit.circuit import AncillaRegister + + anc = AncillaRegister(1) + + qc1 = QuantumCircuit(1, 0) + + qc1.add_register(anc) + qc1.h(anc[0]) + + qc2 = QuantumCircuit(1, 0) + qc2.add_register(anc) + + result = qcec.verify( + qc1, + qc2, + check_partial_equivalence=True, + parallel=False, + run_alternating_checker=False, + run_simulation_checker=False, + run_zx_checker=True, + run_construction_checker=False, + ) + assert result.equivalence == qcec.EquivalenceCriterion.not_equivalent diff --git a/test/test_zx.cpp b/test/test_zx.cpp index 60937782..cd00b8e9 100644 --- a/test/test_zx.cpp +++ b/test/test_zx.cpp @@ -449,3 +449,45 @@ TEST_F(ZXTest, TwoQubitRotations) { EXPECT_EQ(ecm->getResults().equivalence, ec::EquivalenceCriterion::Equivalent); } + +TEST_F(ZXTest, EmptyCircuitWithAncillas) { + auto qc1 = qc::QuantumComputation(0U); + qc1.addAncillaryRegister(1); + qc1.x(0); + + auto qc2 = qc::QuantumComputation(0U); + qc2.addAncillaryRegister(1); + + config.execution.runZXChecker = true; + config.execution.parallel = false; + config.execution.runSimulationChecker = false; + config.execution.runAlternatingChecker = false; + config.execution.runConstructionChecker = false; + ecm = std::make_unique(qc1, qc2, config); + + ecm->run(); + EXPECT_EQ(ecm->getResults().equivalence, + ec::EquivalenceCriterion::NotEquivalent); +} + +TEST_F(ZXTest, EmptyCircuitWithAncillasAndGarbage) { + auto qc1 = qc::QuantumComputation(1U); + qc1.addAncillaryRegister(1); + qc1.setLogicalQubitGarbage(1); + qc1.h(1); + + auto qc2 = qc::QuantumComputation(1U); + qc2.addAncillaryRegister(1); + qc2.setLogicalQubitGarbage(1); + + config.execution.runZXChecker = true; + config.execution.parallel = false; + config.execution.runSimulationChecker = false; + config.execution.runAlternatingChecker = false; + config.execution.runConstructionChecker = false; + ecm = std::make_unique(qc1, qc2, config); + + ecm->run(); + EXPECT_EQ(ecm->getResults().equivalence, + ec::EquivalenceCriterion::Equivalent); +} From 936bd9f420ca45ee2c2ee6a3a4b806f18e496de1 Mon Sep 17 00:00:00 2001 From: burgholzer Date: Tue, 26 Nov 2024 00:06:45 +0100 Subject: [PATCH 3/3] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20update=20mqt-core?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: burgholzer --- cmake/ExternalDependencies.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/ExternalDependencies.cmake b/cmake/ExternalDependencies.cmake index cb960a7a..6e7964b9 100644 --- a/cmake/ExternalDependencies.cmake +++ b/cmake/ExternalDependencies.cmake @@ -22,7 +22,7 @@ endif() # cmake-format: off set(MQT_CORE_VERSION 2.7.1 CACHE STRING "MQT Core version") -set(MQT_CORE_REV "ee7482834c75c6ba7b5ce5fbd74829cb513e3c01" +set(MQT_CORE_REV "04a1b371e1f4e52125471a610f0ed3cd1afe6b5d" CACHE STRING "MQT Core identifier (tag, branch or commit hash)") set(MQT_CORE_REPO_OWNER "cda-tum" CACHE STRING "MQT Core repository owner (change when using a fork)")