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 31, 2024
2 parents e4250dd + 4c3ec83 commit e2b662f
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 133 deletions.
48 changes: 27 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,32 @@ set(CMAKE_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
message(STATUS "C++ version ${CXX_STANDARD} configured.")

if(NOT WIN32)
string(ASCII 27 Esc)
set(ColorReset "${Esc}[m")
set(ColorBold "${Esc}[1m")
set(Red "${Esc}[31m")
set(Green "${Esc}[32m")
set(Yellow "${Esc}[33m")
set(Blue "${Esc}[34m")
set(Magenta "${Esc}[35m")
set(Cyan "${Esc}[36m")
set(White "${Esc}[37m")
set(BoldRed "${Esc}[1;31m")
set(BoldGreen "${Esc}[1;32m")
set(BoldYellow "${Esc}[1;33m")
set(BoldBlue "${Esc}[1;34m")
set(BoldMagenta "${Esc}[1;35m")
set(BoldCyan "${Esc}[1;36m")
set(BoldWhite "${Esc}[1;37m")
endif()

option(XACC_BUILD_TESTS "Build test programs" OFF)
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)
option(XACC_BUILD_ANNEALING "Build annealing libraries" OFF)
if(XACC_BUILD_ANNEALING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DANNEALING_ENABLED")
else()
Expand All @@ -35,6 +55,12 @@ if(QIREE_MINIMAL_BUILD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQIREE_BUILD")
endif()

option(XACC_REMOTE_ACCELERATORS "Build remove (cloud) accelerators" ON)
if(NOT XACC_REMOTE_ACCELERATORS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DREMOTE_DISABLED")
message(STATUS "${BoldYellow}Skipping remote accelerators. Only local simulators are now enabled.{ColorReset}")
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 @@ -93,26 +119,6 @@ include(format)
include(cxxFlags)
include(ExternalProject)

if(NOT WIN32)
string(ASCII 27 Esc)
set(ColorReset "${Esc}[m")
set(ColorBold "${Esc}[1m")
set(Red "${Esc}[31m")
set(Green "${Esc}[32m")
set(Yellow "${Esc}[33m")
set(Blue "${Esc}[34m")
set(Magenta "${Esc}[35m")
set(Cyan "${Esc}[36m")
set(White "${Esc}[37m")
set(BoldRed "${Esc}[1;31m")
set(BoldGreen "${Esc}[1;32m")
set(BoldYellow "${Esc}[1;33m")
set(BoldBlue "${Esc}[1;34m")
set(BoldMagenta "${Esc}[1;35m")
set(BoldCyan "${Esc}[1;36m")
set(BoldWhite "${Esc}[1;37m")
endif()

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.xacc" CACHE PATH "default install path" FORCE)
endif()
Expand Down
36 changes: 21 additions & 15 deletions quantum/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,33 @@
# *******************************************************************************/
add_subdirectory(ibm)
add_subdirectory(algorithms)
add_subdirectory(ionq)
add_subdirectory(xasm)
add_subdirectory(qpp)
add_subdirectory(staq)
add_subdirectory(honeywell)

if(XACC_REMOTE_ACCELERATORS)
add_subdirectory(ionq)
add_subdirectory(honeywell)
endif()

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(optimal_control)
add_subdirectory(qsim)
add_subdirectory(atos_qlm)
add_subdirectory(noise_model)
add_subdirectory(placement)
add_subdirectory(iontrap)
add_subdirectory(circuits)
add_subdirectory(optimizers)
add_subdirectory(circuit_optimizers)
add_subdirectory(decorators)
add_subdirectory(observable_transforms)
add_subdirectory(optimal_control)
add_subdirectory(qsim)
add_subdirectory(noise_model)
add_subdirectory(rigetti)

if(XACC_REMOTE_ACCELERATORS)
add_subdirectory(atos_qlm)
endif()

find_library(QRACK_LIBRARY NAMES qrack)
find_library(QRACK_LIBRARY NAMES qrack)
if (QRACK_LIBRARY)
message("-- Found Qrack library (find_library(QRACK_LIBRARY NAMES qrack))")
add_subdirectory(qrack)
Expand Down
2 changes: 1 addition & 1 deletion quantum/plugins/algorithms/qaoa/tests/QAOATester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ TEST(QAOATester, checkStandardParamterizedScheme) {
auto acc = xacc::getAccelerator("qpp");
auto buffer = xacc::qalloc(2);

auto optimizer = xacc::getOptimizer("nlopt");
auto optimizer = xacc::getOptimizer("nlopt", std::make_pair("nlopt-optimizer", "nelder-mead"));
auto qaoa = xacc::getService<Algorithm>("QAOA");
// Create deuteron Hamiltonian
auto H_N_2 = xacc::quantum::getObservable(
Expand Down
30 changes: 15 additions & 15 deletions quantum/plugins/ibm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,28 @@ file(GLOB SRC
compiler/generated/*.cpp
accelerator/OpenPulseVisitor.cpp)


usfunctiongetresourcesource(TARGET ${LIBRARY_NAME} OUT SRC)
usfunctiongeneratebundleinit(TARGET ${LIBRARY_NAME} OUT SRC)

add_library(${LIBRARY_NAME} SHARED ${SRC})

target_include_directories(${LIBRARY_NAME}
PUBLIC accelerator
compiler
common
compiler/generated
accelerator/json
${CMAKE_SOURCE_DIR}/tpls/antlr/runtime/src
${CMAKE_SOURCE_DIR}/tpls/rapidjson/include)
#${CMAKE_SOURCE_DIR}/tpls/exprtk

target_link_libraries(${LIBRARY_NAME}
PUBLIC xacc
xacc-quantum-gate
${ANTLR_LIB}
target_include_directories(${LIBRARY_NAME}
PUBLIC accelerator
compiler
common
compiler/generated
accelerator/json
${CMAKE_SOURCE_DIR}/tpls/antlr/runtime/src
${CMAKE_SOURCE_DIR}/tpls/rapidjson/include)
target_link_libraries(${LIBRARY_NAME}
PUBLIC xacc
xacc-quantum-gate
${ANTLR_LIB}
CppMicroServices PRIVATE cpr::cpr)

if(XACC_REMOTE_ACCELERATORS)
target_link_libraries(${LIBRARY_NAME} PRIVATE cpr)
endif()

set(_bundle_name xacc_ibm)
set_target_properties(${LIBRARY_NAME}
Expand Down
8 changes: 6 additions & 2 deletions quantum/plugins/ibm/IBMActivator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ class US_ABI_LOCAL IBMActivator : public BundleActivator {
/**
*/
void Start(BundleContext context) {

//#
//ifndef REMOTE_DISABLED
auto acc = std::make_shared<xacc::quantum::IBMAccelerator>();
context.RegisterService<xacc::Accelerator>(acc);
//#
//endif

#ifdef LAPACK_FOUND
auto acc2 = std::make_shared<xacc::quantum::LocalIBMAccelerator>();
Expand All @@ -52,8 +58,6 @@ class US_ABI_LOCAL IBMActivator : public BundleActivator {
auto c2 = std::make_shared<xacc::quantum::QObjectCompiler>();
context.RegisterService<xacc::Compiler>(c2);

context.RegisterService<xacc::Accelerator>(acc);

auto qasm_qobj_gen = std::make_shared<xacc::quantum::QasmQObjGenerator>();
auto pulse_qobj_gen = std::make_shared<xacc::quantum::PulseQObjGenerator>();

Expand Down
14 changes: 13 additions & 1 deletion quantum/plugins/ibm/accelerator/IBMAccelerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
#include "OpenPulseVisitor.hpp"
#include "CountGatesOfTypeVisitor.hpp"

#ifndef REMOTE_DISABLED
#include <cpr/cpr.h>
#endif

#include "xacc.hpp"
#include "xacc_service.hpp"
Expand Down Expand Up @@ -1085,7 +1087,7 @@ const std::string RestClient::post(const std::string &remoteUrl,
const std::string &path,
const std::string &postStr,
std::map<std::string, std::string> headers) {

#ifndef REMOTE_DISABLED
if (headers.empty()) {
headers.insert(std::make_pair("Content-type", "application/json"));
headers.insert(std::make_pair("Connection", "keep-alive"));
Expand All @@ -1109,10 +1111,14 @@ const std::string RestClient::post(const std::string &remoteUrl,
r.error.message + ": " + r.text);

return r.text;
#else
return "";
#endif
}

void RestClient::put(const std::string &remoteUrl, const std::string &putStr,
std::map<std::string, std::string> headers) {
#ifndef REMOTE_DISABLED
if (headers.empty()) {
headers.insert(std::make_pair("Content-type", "application/json"));
headers.insert(std::make_pair("Connection", "keep-alive"));
Expand All @@ -1133,12 +1139,14 @@ void RestClient::put(const std::string &remoteUrl, const std::string &putStr,
throw std::runtime_error("HTTP POST Error - status code " +
std::to_string(r.status_code) + ": " +
r.error.message + ": " + r.text);
#endif
return;
}
const std::string
RestClient::get(const std::string &remoteUrl, const std::string &path,
std::map<std::string, std::string> headers,
std::map<std::string, std::string> extraParams) {
#ifndef REMOTE_DISABLED
if (headers.empty()) {
headers.insert(std::make_pair("Content-type", "application/json"));
headers.insert(std::make_pair("Connection", "keep-alive"));
Expand Down Expand Up @@ -1166,6 +1174,9 @@ RestClient::get(const std::string &remoteUrl, const std::string &path,
r.error.message + ": " + r.text);

return r.text;
#else
return "";
#endif
}

std::string IBMAccelerator::post(const std::string &_url,
Expand Down Expand Up @@ -1424,6 +1435,7 @@ void IBMPulseTransform::apply(std::shared_ptr<CompositeInstruction> program,
program->clear();
program->addInstructions(loweredKernel->getInstructions());
}

} // namespace quantum
} // namespace xacc

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ add_library(${LIBRARY_NAME} SHARED ${SRC})

# L-BFGS++ will require Eigen, XACC provides it
target_include_directories(${LIBRARY_NAME} PUBLIC .
${XACC_ROOT}/include/eigen ${XACC_ROOT}/include/armadillo)
${XACC_ROOT}/include/eigen)

# _bundle_name must be == manifest.json bundle.symbolic_name !!!
set(_bundle_name xacc_qubit_tapering)
Expand Down
Loading

0 comments on commit e2b662f

Please sign in to comment.