Skip to content

Commit 15396fb

Browse files
authored
Merge pull request #1 from danclaudino/deprecate_annealing
Turned annealing deprecated
2 parents d1edaa7 + bbca6f6 commit 15396fb

9 files changed

Lines changed: 54 additions & 14 deletions

File tree

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ option(XACC_BUILD_TESTS "Build test programs" OFF)
2020
option(XACC_BUILD_EXAMPLES "Build example programs" OFF)
2121
option(XACC_ENSMALLEN_INCLUDE_DIR "Path to ensmallen.hpp for mlpack optimizer" "")
2222
option(XACC_ARMADILLO_INCLUDE_DIR "Path to armadillo header for mlpack optimizer" "")
23+
option(XACC_BUILD_ANNEALING "Build annealing libraries" OFF)
24+
if(XACC_BUILD_ANNEALING)
25+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DANNEALING_ENABLED")
26+
else()
27+
message(STATUS "${BoldYellow}Skipping Annealing libraries by default. You can turn it on with -DXACC_BUILD_ANNEALING=ON${ColorReset}")
28+
endif()
2329

2430
if(FROM_SETUP_PY AND NOT APPLE)
2531
message(STATUS "Running build from setup.py, linking to static libstdc++")

python/compiler/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ usFunctionEmbedResources(TARGET ${LIBRARY_NAME}
4242

4343
target_include_directories(${LIBRARY_NAME} PRIVATE . generated
4444
${CMAKE_SOURCE_DIR}/tpls/antlr/runtime/src)
45-
target_link_libraries(${LIBRARY_NAME} PUBLIC xacc xacc-quantum-gate xacc-quantum-annealing ${ANTLR_LIB})
45+
if(XACC_BUILD_ANNEALING)
46+
target_link_libraries(${LIBRARY_NAME} PUBLIC xacc xacc-quantum-gate xacc-quantum-annealing ${ANTLR_LIB})
47+
else()
48+
target_link_libraries(${LIBRARY_NAME} PUBLIC xacc xacc-quantum-gate ${ANTLR_LIB})
49+
endif()
4650

4751
if(APPLE)
4852
set_target_properties(${LIBRARY_NAME} PROPERTIES INSTALL_RPATH "@loader_path/../lib")

python/compiler/pyxasm_listener.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
#include "pyxasm_listener.hpp"
2020
#include "Circuit.hpp"
21-
#include "AnnealingProgram.hpp"
21+
#ifdef ANNEALING_ENABLED
22+
#include "AnnealingProgram.hpp"
23+
#endif
2224
#include <memory>
2325
#include <regex>
2426

@@ -49,12 +51,15 @@ void PyXASMListener::enterInstruction(pyxasmParser::InstructionContext *ctx) {
4951
instructionName = "CNOT";
5052
} else if (instructionName == "MEASURE") {
5153
instructionName = "Measure";
52-
} else if (instructionName == "dwqmi") {
54+
}
55+
#ifdef ANNEALING_ENABLED
56+
else if (instructionName == "dwqmi") {
5357
auto isCircuit = std::dynamic_pointer_cast<quantum::Circuit>(function);
5458
if (isCircuit) {
5559
function = irProvider->createComposite(function->name(), function->getVariables(), "anneal");
5660
}
5761
}
62+
#endif
5863

5964
auto nRequiredBits = irProvider->getNRequiredBits(instructionName);
6065
std::vector<std::size_t> bits;
@@ -122,9 +127,11 @@ void PyXASMListener::enterInstruction(pyxasmParser::InstructionContext *ctx) {
122127
}
123128
}
124129

130+
#ifdef ANNEALING_ENABLED
125131
if (std::dynamic_pointer_cast<quantum::AnnealingProgram>(tmpInst) && std::dynamic_pointer_cast<quantum::Circuit>(function)) {
126132
function = irProvider->createComposite(function->name(), function->getVariables(), "anneal");
127133
}
134+
#endif
128135
}
129136
function->addInstruction(tmpInst);
130137
function->expand(options);

quantum/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
# Alexander J. McCaskey - initial API and implementation
1212
# *******************************************************************************/
1313
add_subdirectory(gate)
14-
add_subdirectory(annealing)
14+
if (XACC_BUILD_ANNEALING)
15+
add_subdirectory(annealing)
16+
endif()
1517
add_subdirectory(provider)
1618
add_subdirectory(observable)
1719
add_subdirectory(plugins)

quantum/plugins/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
add_subdirectory(ibm)
1414
add_subdirectory(rigetti)
1515
#add_subdirectory(cmr)
16-
add_subdirectory(dwave)
1716
add_subdirectory(algorithms)
1817
add_subdirectory(decorators)
1918
add_subdirectory(circuits)
@@ -37,6 +36,10 @@ else()
3736
message("-- Could NOT find Qrack library (missing: find_library(QRACK_LIBRARY NAMES qrack))")
3837
endif()
3938

39+
if(XACC_BUILD_ANNEALING)
40+
add_subdirectory(dwave)
41+
endif()
42+
4043
add_subdirectory(optimal_control)
4144
add_subdirectory(qsim)
4245
add_subdirectory(atos_qlm)

quantum/plugins/placement/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
add_subdirectory(minor_graph_embedding)
1+
if(XACC_BUILD_ANNEALING)
2+
add_subdirectory(minor_graph_embedding)
3+
endif()
24

35
# Note: TriQ depends on Z3 library.
46
# Users need to install Z3, e.g.

quantum/provider/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ usFunctionEmbedResources(TARGET
5050
FILES
5151
manifest.json)
5252

53-
target_link_libraries(${LIBRARY_NAME} PUBLIC xacc PRIVATE xacc-quantum-gate xacc-quantum-annealing)
53+
if(XACC_BUILD_ANNEALING)
54+
target_link_libraries(${LIBRARY_NAME} PUBLIC xacc PRIVATE xacc-quantum-gate xacc-quantum-annealing)
55+
else()
56+
target_link_libraries(${LIBRARY_NAME} PUBLIC xacc PRIVATE xacc-quantum-gate)
57+
endif()
5458
target_compile_features(${LIBRARY_NAME}
5559
PUBLIC
5660
cxx_std_14

quantum/provider/QuantumIRProvider.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
#include "GateIR.hpp"
1616
#include "Circuit.hpp"
1717

18-
#include "DWIR.hpp"
19-
#include "AnnealingProgram.hpp"
18+
#ifdef ANNEALING_ENABLED
19+
#include "DWIR.hpp"
20+
#include "AnnealingProgram.hpp"
21+
#endif
2022

2123
#include "CompositeInstruction.hpp"
2224
#include "xacc_service.hpp"
@@ -131,9 +133,13 @@ std::shared_ptr<Instruction> QuantumIRProvider::createInstruction(
131133
// FIXME, update to handle D-Wave...
132134
if (type == "circuit") {
133135
return std::make_shared<xacc::quantum::Circuit>(name,variables);
134-
} else if (type == "anneal") {
136+
}
137+
#ifdef ANNEALING_ENABLED
138+
else if (type == "anneal") {
135139
return std::make_shared<xacc::quantum::AnnealingProgram>(name,variables);
136-
} else {
140+
}
141+
#endif
142+
else {
137143
xacc::error("Invalid Composite type, can be circuit or anneal");
138144
return nullptr;
139145
}
@@ -142,9 +148,15 @@ std::shared_ptr<Instruction> QuantumIRProvider::createInstruction(
142148
std::shared_ptr<IR> QuantumIRProvider::createIR(const std::string type) {
143149
if (type == "circuit") {
144150
return std::make_shared<GateIR>();
145-
} else if (type == "anneal") {
151+
}
152+
153+
#ifdef ANNEALING_ENABLED
154+
else if (type == "anneal") {
146155
return std::make_shared<DWIR>();
147-
} else {
156+
}
157+
#endif
158+
159+
else {
148160
xacc::error("Invalid IR type, can be circuit or anneal");
149161
return nullptr;
150162
}

tpls/boost-cmake

0 commit comments

Comments
 (0)