Skip to content

Commit

Permalink
Improvements for I/O mapping information extraction
Browse files Browse the repository at this point in the history
* Python bindings now support extraction of I/O mapping information from Qiskit objects
* Improved check whether measurements occur at the end of the circuit
* Extraction of I/O mapping information from measurements is now conducted during circuit import
* Correctly set visibility settings for googletest when building bindings

Signed-off-by: Lukas Burgholzer <lukas.burgholzer@jku.at>
  • Loading branch information
burgholzer committed Jan 25, 2021
1 parent 3605849 commit b263d13
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 37 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if(${CMAKE_VERSION} VERSION_LESS 3.12)
endif()

project(qcec
VERSION 1.7.0
VERSION 1.7.1
DESCRIPTION "QCEC - A JKQ tool for Quantum Circuit Equivalence Checking"
LANGUAGES CXX)

Expand All @@ -27,7 +27,7 @@ macro(handle_submodule MODULENAME)
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git" AND GIT_SUBMODULE)
message(STATUS "${MODULENAME} update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive -- extern/${MODULENAME}
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive --remote -- extern/${MODULENAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
Expand Down
2 changes: 1 addition & 1 deletion extern/qfr
Submodule qfr updated from be35b7 to 035b6a
6 changes: 6 additions & 0 deletions jkq/qcec/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
pybind11_add_module(py${PROJECT_NAME} bindings.cpp)
target_link_libraries(py${PROJECT_NAME} PUBLIC ${PROJECT_NAME} JKQ::pyqfr pybind11_json)
set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
if (TARGET gtest)
target_compile_options(gtest PUBLIC -fvisibility=hidden)
target_compile_options(gtest_main PUBLIC -fvisibility=hidden)
target_compile_options(gmock PUBLIC -fvisibility=hidden)
target_compile_options(gmock_main PUBLIC -fvisibility=hidden)
endif ()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def build_extension(self, ext):

setup(
name='jkq.qcec',
version='1.7.0',
version='1.7.1',
author='Lukas Burgholzer',
author_email='lukas.burgholzer@jku.at',
description='QCEC - A JKQ tool for Quantum Circuit Equivalence Checking',
Expand Down
38 changes: 5 additions & 33 deletions src/EquivalenceChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,42 +187,14 @@ namespace ec {
}

void EquivalenceChecker::applyGate(decltype(qc1.begin())& opIt, dd::Edge& to, std::map<unsigned short, unsigned short>& permutation, decltype(qc1.end())& end, Direction dir) {

auto&& op = *opIt;

// Measurements at the end of the circuit are considered NOPs. They may provide output permutation information
if (op->getType() == qc::Measure) {
auto atEnd = opIt;
bool onlyMeasurementsRemaining = true;
while (atEnd != end) {
if ((*atEnd)->getType() != qc::Measure) {
onlyMeasurementsRemaining = false;
break;
}
++atEnd;
}

if (!onlyMeasurementsRemaining) {
// Measurements at the end of the circuit are considered NOPs.
if ((*opIt)->getType() == qc::Measure) {
if (!qc::QuantumComputation::isLastOperationOnQubit(opIt, end)) {
throw QCECException("Intermediate measurements currently not supported. Defer your measurements to the end.");
}

for (size_t i=0; i<op->getNcontrols(); ++i) {
auto qubitidx = op->getControls().at(i).qubit;
auto bitidx = op->getTargets().at(i);
auto current = permutation.at(qubitidx);
if (qubitidx != bitidx && current != bitidx) {
for (auto& p: permutation) {
if (p.second == bitidx) {
p.second = current;
break;
}
}
permutation.at(qubitidx) = bitidx;
}
}
} else {
applyGate(op, to, permutation, dir);
return;
}
applyGate(*opIt, to, permutation, dir);
}

void EquivalenceChecker::check(const Configuration& config) {
Expand Down

0 comments on commit b263d13

Please sign in to comment.