Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into external
Browse files Browse the repository at this point in the history
  • Loading branch information
sethrj committed Jul 19, 2024
2 parents 2d0e58f + 94fcd56 commit 27d8611
Show file tree
Hide file tree
Showing 32 changed files with 526 additions and 660 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
url = https://github.com/dwavesystems/minorminer
[submodule "tpls/nlopt"]
path = tpls/nlopt
url = https://github.com/ORNL-QCI/nlopt
url = https://github.com/stevengj/nlopt
[submodule "quantum/plugins/dwave/tpls/legacy-sapi-clients"]
path = quantum/plugins/dwave/tpls/legacy-sapi-clients
url = https://github.com/ornl-qci/legacy-sapi-clients
Expand Down
75 changes: 48 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,19 @@ option(XACC_BUILD_EXAMPLES "Build example programs" OFF)
option(XACC_ENSMALLEN_INCLUDE_DIR "Path to ensmallen.hpp for mlpack optimizer" "")
option(XACC_ARMADILLO_INCLUDE_DIR "Path to armadillo header for mlpack optimizer" "")
option(XACC_BUILD_ANNEALING "Build annealing libraries" OFF)
option(XACC_BUILD_SCIPY "Build Scipy optimizer plugin" OFF)
if(XACC_BUILD_ANNEALING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DANNEALING_ENABLED")
else()
message(STATUS "${BoldYellow}Skipping Annealing libraries by default. You can turn it on with -DXACC_BUILD_ANNEALING=ON${ColorReset}")
endif()

option(QIREE_MINIMAL_BUILD "Build only components for QIREE CI" OFF)

if(QIREE_MINIMAL_BUILD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQIREE_BUILD")
endif()

if(FROM_SETUP_PY AND NOT APPLE)
message(STATUS "Running build from setup.py, linking to static libstdc++")
set(CMAKE_SHARED_LINKER_FLAGS "-static-libstdc++" CACHE INTERNAL "" FORCE)
Expand Down Expand Up @@ -216,37 +223,42 @@ endif()
add_subdirectory(xacc)
add_subdirectory(quantum)

find_package(Python COMPONENTS Interpreter Development)
# qiree doesn't need python, so we can ignore this and everything else that is python related
if(NOT QIREE_MINIMAL_BUILD)

if(Python_FOUND)
if(${Python_VERSION} VERSION_GREATER_EQUAL 3.0.0)
message(STATUS "${BoldGreen}Found Python version ${Python_VERSION}. Building XACC Python API with ${Python_INCLUDE_DIRS}${ColorReset}")
add_subdirectory(python)
add_subdirectory(${CMAKE_SOURCE_DIR}/quantum/python)

# Double check we have module ipopo installed, contributes pelix
execute_process(COMMAND ${Python_EXECUTABLE} -c "import pelix" RESULT_VARIABLE PELIX_EXISTS)

if(PELIX_EXISTS EQUAL "1")
# if not, check we have pip
execute_process(COMMAND ${Python_EXECUTABLE} -c "import pip" RESULT_VARIABLE PIP_EXISTS)
find_package(Python COMPONENTS Interpreter Development)

if(PIP_EXISTS EQUAL "0")
# we have pip, son just install ipopo
message(STATUS "${BoldGreen}Installing Pelix OSGi framework.${ColorReset}")
execute_process(COMMAND ${Python_EXECUTABLE} -m pip install ipopo)
if(Python_FOUND)
if(${Python_VERSION} VERSION_GREATER_EQUAL 3.0.0)
message(STATUS "${BoldGreen}Found Python version ${Python_VERSION}. Building XACC Python API with ${Python_INCLUDE_DIRS}${ColorReset}")
add_subdirectory(python)
add_subdirectory(${CMAKE_SOURCE_DIR}/quantum/python)

# Double check we have module ipopo installed, contributes pelix
execute_process(COMMAND ${Python_EXECUTABLE} -c "import pelix" RESULT_VARIABLE PELIX_EXISTS)

if(PELIX_EXISTS EQUAL "1")
# if not, check we have pip
execute_process(COMMAND ${Python_EXECUTABLE} -c "import pip" RESULT_VARIABLE PIP_EXISTS)

if(PIP_EXISTS EQUAL "0")
# we have pip, son just install ipopo
message(STATUS "${BoldGreen}Installing Pelix OSGi framework.${ColorReset}")
execute_process(COMMAND ${Python_EXECUTABLE} -m pip install ipopo)
else()
# we dont have pip, so warn the user
message(STATUS "${BoldYellow}Pelix Framework not found, but can't install via pip. Ensure you install ipopo module before using XACC Python API.${ColorReset}")
endif()
else()
# we dont have pip, so warn the user
message(STATUS "${BoldYellow}Pelix Framework not found, but can't install via pip. Ensure you install ipopo module before using XACC Python API.${ColorReset}")
message(STATUS "${BoldGreen}Found Pelix framework.${ColorReset}")
endif()
else()
message(STATUS "${BoldGreen}Found Pelix framework.${ColorReset}")
message(STATUS "${BoldYellow}Found Python version ${Python_VERSION}. Version must be greater than 3.0.0, skipping Python API build.${ColorReset}")
endif()
else()
message(STATUS "${BoldYellow}Found Python version ${Python_VERSION}. Version must be greater than 3.0.0, skipping Python API build.${ColorReset}")
message(STATUS "${BoldYellow}Python interpreter or development headers not found. Skipping Python API build.${ColorReset}")
endif()
else()
message(STATUS "${BoldYellow}Python interpreter or development headers not found. Skipping Python API build.${ColorReset}")

endif()

# Version info
Expand All @@ -265,13 +277,22 @@ install(FILES "${CMAKE_BINARY_DIR}/xacc-config-version.cmake" DESTINATION .)
install(FILES "${CMAKE_SOURCE_DIR}/cmake/Modules/format.cmake" DESTINATION share/xacc/)
install(FILES "${CMAKE_SOURCE_DIR}/tpls/mpark-variant/variant.hpp" DESTINATION include/xacc/)
install(FILES "${CMAKE_SOURCE_DIR}/tpls/taocpp/operators.hpp" DESTINATION include/xacc/)
install(FILES "${NLOHMANN_INCLUDE_DIR}/nlohmann/json.hpp" DESTINATION include/xacc/)
if(NOT XACC_DEPS_EXTERNAL OR NOT nlohmann_json_FOUND)
install(FILES "${NLOHMANN_INCLUDE_DIR}/nlohmann/json.hpp" DESTINATION include/xacc/)
endif()

install(DIRECTORY "${SPDLOG_INCLUDE_DIR}" DESTINATION include/spdlog/)
if(NOT XACC_DEPS_EXTERNAL OR NOT spdlog_FOUND)
install(DIRECTORY "${SPDLOG_INCLUDE_DIR}" DESTINATION include/spdlog/)
endif()
install(DIRECTORY "${CMAKE_SOURCE_DIR}/tpls/exprtk" DESTINATION include)
install(DIRECTORY "${EIGEN_INCLUDE_DIR}" DESTINATION include)
if(NOT XACC_DEPS_EXTERNAL OR NOT Eigen3_FOUND)
install(DIRECTORY "${EIGEN_INCLUDE_DIR}" DESTINATION include)
endif()
install(DIRECTORY "${CMAKE_SOURCE_DIR}/tpls/rapidjson" DESTINATION include)
install(DIRECTORY "${CMAKE_SOURCE_DIR}/tpls/pybind11" DESTINATION include)

if(NOT QIREE_MINIMAL_BUILD)
install(DIRECTORY "${CMAKE_SOURCE_DIR}/tpls/pybind11" DESTINATION include)
endif()

if(XACC_CPACK_DEB_PLATFORM)
message(STATUS "CPack DEB Build Enabled.")
Expand Down
2 changes: 2 additions & 0 deletions python/compiler/tests/PyXASMCompilerTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class custom_range : public xacc::quantum::Circuit {
std::cout << "KERNEL\n" << IR->getComposites()[0]->toString() << "\n";
}

#ifndef QIREE_BUILD
TEST(PyXASMCompilerTester, checkUCCSD) {
auto compiler = xacc::getCompiler("pyxasm");
auto IR = compiler -> compile(R"(def ansatz_vqe(buffer, args):
Expand All @@ -93,6 +94,7 @@ auto compiler = xacc::getCompiler("pyxasm");
std::cout << IR->getComposites()[0]->toString() << "\n";

}
#endif

int main(int argc, char **argv) {
xacc::Initialize(argc, argv);
Expand Down
2 changes: 2 additions & 0 deletions quantum/gate/utils/tests/IRUtilsTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ TEST(IRUtilsTester, checkSimple) {
EXPECT_TRUE(result.validate(testCircs));
}

#ifndef QIREE_BUILD
TEST(IRUtilsTester, checkObservable) {
{
auto H_N_2 = xacc::quantum::getObservable(
Expand Down Expand Up @@ -115,6 +116,7 @@ TEST(IRUtilsTester, checkObservable) {
EXPECT_TRUE(result.validate(fsToExe));
}
}
#endif

int main(int argc, char **argv) {
xacc::Initialize(argc, argv);
Expand Down
4 changes: 3 additions & 1 deletion quantum/observable/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
add_subdirectory(pauli)
add_subdirectory(fermion)
add_subdirectory(transforms)
if(NOT QIREE_MINIMAL_BUILD)
add_subdirectory(transforms)
endif(NOT QIREE_MINIMAL_BUILD)
23 changes: 8 additions & 15 deletions quantum/observable/pauli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,15 @@ usFunctionGetResourceSource(TARGET ${LIBRARY_NAME} OUT SRC)
usFunctionGenerateBundleInit(TARGET ${LIBRARY_NAME} OUT SRC)

add_library(${LIBRARY_NAME} SHARED ${SRC})
set(EIGEN_INCLUDE_DIR "${EIGEN_INCLUDE_DIR}")
message("EIGEN_INCLUDE_DIR:${EIGEN_INCLUDE_DIR}")
target_include_directories(${LIBRARY_NAME}
PUBLIC
"${EIGEN_INCLUDE_DIR}"
"${EIGEN_INCLUDE_DIR} "
"${EIGEN_INCLUDE_DIR}/POOOOOP"
"${EIGEN_INCLUDE_DIR}"/POOOOOP
${CMAKE_SOURCE_DIR}/tpls/armadillo
${CMAKE_SOURCE_DIR}/tpls/antlr/runtime/src
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/generated
${CMAKE_SOURCE_DIR}/tpls/taocpp
${CMAKE_BINARY_DIR}
)
target_link_libraries(${LIBRARY_NAME} PUBLIC Eigen3::Eigen)
PUBLIC
. ${CMAKE_SOURCE_DIR}/tpls/armadillo
${CMAKE_SOURCE_DIR}/tpls/antlr/runtime/src
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/generated
${CMAKE_SOURCE_DIR}/tpls/taocpp
${EIGEN_INCLUDE_DIR}
${CMAKE_BINARY_DIR})

add_dependencies(${LIBRARY_NAME} antlr4_shared)

Expand Down
13 changes: 1 addition & 12 deletions quantum/observable/pauli/PauliOperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,11 @@
#include "PauliOperator.hpp"
#include "CompositeInstruction.hpp"
#include "IRProvider.hpp"
#include <cassert>
#include <cmath>
#include <memory>
#include <regex>
#include <set>
#include <iostream>
#include "Instruction.hpp"
#include "Observable.hpp"
#include "xacc.hpp"
#include "xacc_service.hpp"

#include <Eigen/Core>

#include "PauliOperatorLexer.h"
#include "PauliListenerImpl.hpp"

#include <armadillo>

namespace xacc {
Expand Down Expand Up @@ -1107,7 +1096,7 @@ std::vector<std::shared_ptr<CompositeInstruction>> PauliOperator::getMeasurement

// the idea is that, for something like VQE, we only need to know
// the qubits that need to be measure in the X or Y basis
// so we map the index of the qubit, to the corresponding
// so we map the index of the qubit, to the corresponding
// rotation operators, then later add measure to all qubits
std::vector<std::shared_ptr<CompositeInstruction>> basisRotations;

Expand Down
2 changes: 2 additions & 0 deletions quantum/observable/pauli/tests/PauliOperatorTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ TEST(PauliOperatorTester, checkGroupingCommuteCheck) {
}
}

#ifndef QIREE_BUILD
TEST(PauliOperatorTester, checkGroupingQaoaPostProcessLSB) {
PauliOperator op;
op.fromString("(1.5,0) + (-0.5,0) Z0 Z1 + (-0.5,0) Z0 Z2 + (-0.5,0) Z1 Z2");
Expand Down Expand Up @@ -591,6 +592,7 @@ TEST(PauliOperatorTester, checkGroupingQaoaPostProcessMSB) {
buffer, xacc::Observable::PostProcessingTask::EXP_VAL_CALC, {});
EXPECT_NEAR(exp_val, 2.0, 0.1);
}
#endif

TEST(PauliOperatorTester, checkGetBasisRotations) {
PauliOperator op;
Expand Down
39 changes: 19 additions & 20 deletions quantum/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,38 @@
# Alexander J. McCaskey - initial API and implementation
# *******************************************************************************/
add_subdirectory(ibm)
add_subdirectory(rigetti)
#add_subdirectory(cmr)
add_subdirectory(algorithms)
add_subdirectory(decorators)
add_subdirectory(circuits)
add_subdirectory(optimizers)
add_subdirectory(circuit_optimizers)
add_subdirectory(iontrap)
add_subdirectory(ionq)
add_subdirectory(placement)
#add_subdirectory(scaffold)
add_subdirectory(xasm)
add_subdirectory(qpp)
add_subdirectory(staq)
add_subdirectory(honeywell)

if(NOT QIREE_MINIMAL_BUILD)
add_subdirectory(placement)
add_subdirectory(iontrap)
add_subdirectory(circuits)
add_subdirectory(optimizers)
add_subdirectory(circuit_optimizers)
add_subdirectory(rigetti)
add_subdirectory(decorators)
add_subdirectory(observable_transforms)
#add_subdirectory(jaqal)
add_subdirectory(optimal_control)
add_subdirectory(qsim)
add_subdirectory(atos_qlm)
add_subdirectory(noise_model)

find_library(QRACK_LIBRARY NAMES qrack)
if (QRACK_LIBRARY)
message("-- Found Qrack library (find_library(QRACK_LIBRARY NAMES qrack))")
add_subdirectory(qrack)
else()
message("-- Could NOT find Qrack library (missing: find_library(QRACK_LIBRARY NAMES qrack))")
if (QRACK_LIBRARY)
message("-- Found Qrack library (find_library(QRACK_LIBRARY NAMES qrack))")
add_subdirectory(qrack)
else()
message("-- Could NOT find Qrack library (missing: find_library(QRACK_LIBRARY NAMES qrack))")
endif()
endif()

if(XACC_BUILD_ANNEALING)
add_subdirectory(dwave)
endif()

add_subdirectory(optimal_control)
add_subdirectory(qsim)
add_subdirectory(atos_qlm)
add_subdirectory(noise_model)

install (FILES utils/OperatorPool.hpp DESTINATION include/quantum/gate)
28 changes: 16 additions & 12 deletions quantum/plugins/algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@
# Contributors:
# Alexander J. McCaskey - initial API and implementation
# *******************************************************************************/
add_subdirectory(adapt)
add_subdirectory(vqe)
add_subdirectory(rdm)
add_subdirectory(ml)
add_subdirectory(rotoselect)
add_subdirectory(qpt)
add_subdirectory(qaoa)
add_subdirectory(qpe)
add_subdirectory(gradient_strategies)
add_subdirectory(qite)
add_subdirectory(qcmx)
add_subdirectory(qeom)

if(NOT QIREE_MINIMAL_BUILD)
add_subdirectory(vqe)
add_subdirectory(rdm)
add_subdirectory(gradient_strategies)
add_subdirectory(qaoa)
add_subdirectory(rotoselect)
add_subdirectory(adapt)
add_subdirectory(qpe)
add_subdirectory(qpt)
add_subdirectory(ml)
add_subdirectory(qite)
add_subdirectory(qcmx)
add_subdirectory(qeom)
endif(NOT QIREE_MINIMAL_BUILD)


file(GLOB PYDECORATORS ${CMAKE_CURRENT_SOURCE_DIR}/vqe/python/*.py
${CMAKE_CURRENT_SOURCE_DIR}/ml/ddcl/python/*.py)
Expand Down
3 changes: 2 additions & 1 deletion quantum/plugins/algorithms/ml/ddcl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ add_library(${LIBRARY_NAME} SHARED ${SRC})

target_include_directories(
${LIBRARY_NAME}
PUBLIC SYSTEM "${EIGEN_INCLUDE_DIR}")
PUBLIC .
${EIGEN_INCLUDE_DIR})

target_link_libraries(${LIBRARY_NAME} PUBLIC xacc)

Expand Down
9 changes: 8 additions & 1 deletion quantum/plugins/circuits/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ target_include_directories(
PUBLIC . range exp hwe qft uccsd ucc1 ucc3 aswap qfast kak
${CMAKE_SOURCE_DIR}/quantum/plugins/utils)

if(QIREE_MINIMAL_BUILD)
list(REMOVE_ITEM SRC kak/kak.cpp qfast/qfast.cpp aswap/aswap.cpp)
list(REMOVE_ITEM INCLUDE_DIRS kak qfast aswap)
endif()

target_link_libraries(${LIBRARY_NAME} PUBLIC xacc PRIVATE xacc-quantum-gate xacc-pauli xacc-fermion)

set(_bundle_name xacc_generators)
Expand Down Expand Up @@ -73,7 +78,9 @@ if(XACC_BUILD_TESTS)
add_subdirectory(ucc3/tests)
add_subdirectory(aswap/tests)
add_subdirectory(qfast/tests)
add_subdirectory(kak/tests)
if(NOT QIREE_MINIMAL_BUILD)
add_subdirectory(kak/tests)
endif()
endif()

install(TARGETS ${LIBRARY_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/plugins)
Expand Down
3 changes: 2 additions & 1 deletion quantum/plugins/circuits/uccsd/tests/UCCSDTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ TEST(UCCSDTester,checkUCCSD) {

}

#ifndef QIREE_BUILD
TEST(UCCSDTester,checkSingletAdaptedUCCSD) {

auto tmp = xacc::getService<Instruction>("uccsd");//std::make_shared<QFT>();
Expand All @@ -48,7 +49,7 @@ TEST(UCCSDTester,checkQubitPool) {
std::cout << uccsd->toString() << "\n";

}

#endif

int main(int argc, char** argv) {
xacc::Initialize();
Expand Down
Loading

0 comments on commit 27d8611

Please sign in to comment.