From dee4af73349ff7ce01abe8cab406dd1d8e8e2c20 Mon Sep 17 00:00:00 2001 From: hhorii Date: Wed, 25 Nov 2020 12:36:32 +0900 Subject: [PATCH 01/15] reduce overhads to check available methods in qasm simulator (#1053) --- qiskit/providers/aer/backends/backend_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qiskit/providers/aer/backends/backend_utils.py b/qiskit/providers/aer/backends/backend_utils.py index 053722aeae..6d080cc465 100644 --- a/qiskit/providers/aer/backends/backend_utils.py +++ b/qiskit/providers/aer/backends/backend_utils.py @@ -61,6 +61,7 @@ def available_methods(controller, methods): for method in methods: qobj = assemble(dummy_circ, optimization_level=0, + shots=1, method=method) result = cpp_execute(controller, qobj) if result.get('success', False): From 76d8c81b240dbea8c781d9a7129885f0b19628f4 Mon Sep 17 00:00:00 2001 From: "Christopher J. Wood" Date: Thu, 26 Nov 2020 13:44:33 -0500 Subject: [PATCH 02/15] Fix bug with nested omp being applied incorrectly (#1055) --- .../fix-omp-nested-9d120cd1a08725ab.yaml | 5 ++++ src/controllers/controller.hpp | 26 ++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix-omp-nested-9d120cd1a08725ab.yaml diff --git a/releasenotes/notes/fix-omp-nested-9d120cd1a08725ab.yaml b/releasenotes/notes/fix-omp-nested-9d120cd1a08725ab.yaml new file mode 100644 index 0000000000..bab20a0be8 --- /dev/null +++ b/releasenotes/notes/fix-omp-nested-9d120cd1a08725ab.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixes a bug with nested OpenMP flag was being set to true when it + shouldn't be. diff --git a/src/controllers/controller.hpp b/src/controllers/controller.hpp index b2c7fccda2..0e9b54e276 100755 --- a/src/controllers/controller.hpp +++ b/src/controllers/controller.hpp @@ -217,6 +217,7 @@ class Controller { int parallel_experiments_; int parallel_shots_; int parallel_state_update_; + bool parallel_nested_ = false; }; //========================================================================= @@ -251,6 +252,7 @@ void Controller::set_config(const json_t &config) { max_parallel_threads_ = 1; max_parallel_shots_ = 1; max_parallel_experiments_ = 1; + parallel_nested_ = false; #endif // Load configurations for parallelization @@ -297,6 +299,7 @@ void Controller::clear_parallelization() { parallel_experiments_ = 1; parallel_shots_ = 1; parallel_state_update_ = 1; + parallel_nested_ = false; explicit_parallelization_ = false; max_memory_mb_ = get_system_memory_mb() / 2; @@ -517,8 +520,16 @@ Result Controller::execute(std::vector &circuits, result.metadata["max_memory_mb"] = max_memory_mb_; #ifdef _OPENMP - if (parallel_shots_ > 1 || parallel_state_update_ > 1) + // Check if circuit parallelism is nested with one of the others + if (parallel_experiments_ > 1 && parallel_experiments_ < max_parallel_threads_) { + // Nested parallel experiments + parallel_nested_ = true; omp_set_nested(1); + result.metadata["omp_nested"] = parallel_nested_; + } else { + parallel_nested_ = false; + omp_set_nested(0); + } #endif // then- and else-blocks have intentionally duplication. // Nested omp has significant overheads even though a guard condition exists. @@ -620,6 +631,19 @@ void Controller::execute_circuit(Circuit &circ, // Vector to store parallel thread output data std::vector par_results(parallel_shots_); std::vector error_msgs(parallel_shots_); + + #ifdef _OPENMP + if (!parallel_nested_) { + if (parallel_shots_ > 1 && parallel_state_update_ > 1) { + // Nested parallel shots + state update + omp_set_nested(1); + result.metadata["omp_nested"] = true; + } else { + omp_set_nested(0); + } + } + #endif + #pragma omp parallel for if (parallel_shots_ > 1) num_threads(parallel_shots_) for (int i = 0; i < parallel_shots_; i++) { try { From e285bbca1ffe41e4c71ba29bbe3d54b77ab7dcc9 Mon Sep 17 00:00:00 2001 From: "Christopher J. Wood" Date: Wed, 2 Dec 2020 05:14:30 -0500 Subject: [PATCH 03/15] Remove deprecated usage of omp_set_nested (#1061) On mac and linux use `omp_set_max_active_levels` instead of `omp_set_nested` --- src/controllers/controller.hpp | 16 ++++++++++++++++ src/misc/clang_omp_symbols.hpp | 6 ++++++ src/misc/gcc_omp_symbols.hpp | 6 ++++++ 3 files changed, 28 insertions(+) diff --git a/src/controllers/controller.hpp b/src/controllers/controller.hpp index 0e9b54e276..ec93065adc 100755 --- a/src/controllers/controller.hpp +++ b/src/controllers/controller.hpp @@ -524,11 +524,19 @@ Result Controller::execute(std::vector &circuits, if (parallel_experiments_ > 1 && parallel_experiments_ < max_parallel_threads_) { // Nested parallel experiments parallel_nested_ = true; + #ifdef _WIN32 omp_set_nested(1); + #else + omp_set_max_active_levels(3); + #endif result.metadata["omp_nested"] = parallel_nested_; } else { parallel_nested_ = false; + #ifdef _WIN32 omp_set_nested(0); + #else + omp_set_max_active_levels(1); + #endif } #endif // then- and else-blocks have intentionally duplication. @@ -636,10 +644,18 @@ void Controller::execute_circuit(Circuit &circ, if (!parallel_nested_) { if (parallel_shots_ > 1 && parallel_state_update_ > 1) { // Nested parallel shots + state update + #ifdef _WIN32 omp_set_nested(1); + #else + omp_set_max_active_levels(2); + #endif result.metadata["omp_nested"] = true; } else { + #ifdef _WIN32 omp_set_nested(0); + #else + omp_set_max_active_levels(1); + #endif } } #endif diff --git a/src/misc/clang_omp_symbols.hpp b/src/misc/clang_omp_symbols.hpp index 5d405d2b2b..0e3bae3671 100644 --- a/src/misc/clang_omp_symbols.hpp +++ b/src/misc/clang_omp_symbols.hpp @@ -218,6 +218,11 @@ extern "C" { void __KAI_KMPC_CONVENTION omp_set_nested(int foo){ _hook_omp_set_nested(foo); } + using omp_set_max_active_levels_t = void(*)(int); + omp_set_max_active_levels_t _hook_omp_set_max_active_levels; + void __KAI_KMPC_CONVENTION omp_set_max_active_levels(int foo){ + _hook_omp_set_max_active_levels(foo); + } using omp_get_num_procs_t = int(*)(void); omp_get_num_procs_t _hook_omp_get_num_procs; int __KAI_KMPC_CONVENTION omp_get_num_procs(void) { @@ -325,6 +330,7 @@ void populate_hooks(void * handle){ _hook_omp_get_num_threads = reinterpret_cast(dlsym(handle, "omp_get_num_threads")); _hook_omp_get_thread_num = reinterpret_cast(dlsym(handle, "omp_get_thread_num")); _hook_omp_set_nested = reinterpret_cast(dlsym(handle, "omp_set_nested")); + _hook_omp_set_max_active_levels = reinterpret_cast(dlsym(handle, "omp_set_max_active_levels")); _hook_omp_get_num_procs = reinterpret_cast(dlsym(handle, "omp_get_num_procs")); } diff --git a/src/misc/gcc_omp_symbols.hpp b/src/misc/gcc_omp_symbols.hpp index 3268d1dbee..3ff2b0f162 100644 --- a/src/misc/gcc_omp_symbols.hpp +++ b/src/misc/gcc_omp_symbols.hpp @@ -71,6 +71,11 @@ extern "C" { void __KAI_KMPC_CONVENTION omp_set_nested(int foo){ _hook_omp_set_nested(foo); } + using omp_set_max_active_levels_t = void(*)(int); + omp_set_max_active_levels_t _hook_omp_set_max_active_levels; + void __KAI_KMPC_CONVENTION omp_set_max_active_levels(int foo){ + _hook_omp_set_max_active_levels(foo); + } using omp_get_num_threads_t = int(*)(void); omp_get_num_threads_t _hook_omp_get_num_threads; int __KAI_KMPC_CONVENTION omp_get_num_threads(void) { @@ -101,6 +106,7 @@ namespace Hacks { _hook_omp_get_num_threads = reinterpret_cast(dlsym(handle, "omp_get_num_threads")); _hook_omp_get_max_threads = reinterpret_cast(dlsym(handle, "omp_get_max_threads")); _hook_omp_set_nested = reinterpret_cast(dlsym(handle, "omp_set_nested")); + _hook_omp_set_max_active_levels = reinterpret_cast(dlsym(handle, "omp_set_max_active_levels")); _hook_omp_get_thread_num = reinterpret_cast(dlsym(handle, "omp_get_thread_num")); _hook_omp_get_num_procs = reinterpret_cast(dlsym(handle, "omp_get_num_procs")); } From 9323a2db20cbb370c901ffe38402556c7a75a72b Mon Sep 17 00:00:00 2001 From: Victor Villar Date: Wed, 9 Dec 2020 10:07:47 +0100 Subject: [PATCH 04/15] bump version to 0.7.2 --- docs/conf.py | 2 +- qiskit/providers/aer/VERSION.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 3fb1f4358f..49d0d093f6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -46,7 +46,7 @@ # The short X.Y version version = '' # The full version, including alpha/beta/rc tags -release = '0.7.1' +release = '0.7.2' # -- General configuration --------------------------------------------------- diff --git a/qiskit/providers/aer/VERSION.txt b/qiskit/providers/aer/VERSION.txt index 39e898a4f9..7486fdbc50 100644 --- a/qiskit/providers/aer/VERSION.txt +++ b/qiskit/providers/aer/VERSION.txt @@ -1 +1 @@ -0.7.1 +0.7.2 From 376b61d0162b7d648f638653e8367e3019210517 Mon Sep 17 00:00:00 2001 From: Victor Villar <59838221+vvilpas@users.noreply.github.com> Date: Wed, 4 Nov 2020 15:51:04 +0100 Subject: [PATCH 05/15] Cmake: make conan optional (#999) Co-authored-by: Drew Risinger --- CMakeLists.txt | 61 ++++++++++-------- CONTRIBUTING.md | 35 ++++++++-- cmake/conan_utils.cmake | 34 ++++++++++ cmake/dependency_utils.cmake | 64 +++++++++++++++++++ .../aer/backends/wrappers/CMakeLists.txt | 6 +- ...cmake-optional-conan-bc99a895fc4345e1.yaml | 9 +++ setup.py | 25 +++++--- src/simulators/statevector/qv_avx2.cpp | 2 +- test/CMakeLists.txt | 2 +- 9 files changed, 190 insertions(+), 48 deletions(-) create mode 100644 cmake/dependency_utils.cmake create mode 100644 releasenotes/notes/cmake-optional-conan-bc99a895fc4345e1.yaml diff --git a/CMakeLists.txt b/CMakeLists.txt index 60b9bed3bf..505b20c7b5 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,11 +45,20 @@ option(STATIC_LINKING "Specify if we want statically link the executable (for redistribution mainly)" FALSE) option(BUILD_TESTS "Specify whether we want to build tests or not" FALSE) +# Allow disabling conan for downstream package managers. Requires all libraries to be present in path +# Default is value of environment variable if defined or ON +if(DEFINED ENV{DISABLE_CONAN}) + set(_DISABLE_CONAN_DEFAULT ENV{DISABLE_CONAN}) +else() + set(_DISABLE_CONAN_DEFAULT OFF) +endif() +option(DISABLE_CONAN "Disable Conan package manager to find dependencies. If disabled, you must have all dependencies present on your system." ${_DISABLE_CONAN_DEFAULT}) + include(CTest) include(compiler_utils) include(Linter) include(findBLASInSpecificPath) -include(conan_utils) +include(dependency_utils) # Get version information get_version(${VERSION_NUM}) @@ -137,29 +146,33 @@ endif() # # Looking for external libraries # - -setup_conan() +set(BACKEND_REDIST_DEPS "") # List of redistributable dependencies +setup_dependencies() # If we do not set them with a space CMake fails afterwards if nothing is set for this vars! set(AER_LINKER_FLAGS " ") set(AER_COMPILER_FLAGS " ") -message(STATUS "Looking for OpenMP support...") -if(APPLE) - set(OPENMP_FOUND TRUE) - if(NOT SKBUILD) - set(AER_LIBRARIES ${AER_LIBRARIES} CONAN_PKG::llvm-openmp) - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CONAN_CXX_FLAGS_LLVM-OPENMP}") - set(AER_SIMULATOR_CPP_EXTERNAL_LIBS ${AER_SIMULATOR_CPP_EXTERNAL_LIBS} ${CONAN_INCLUDE_DIRS_LLVM-OPENMP}) - endif() -else() +if(NOT OPENMP_FOUND) # Could already be setup for macos with conan + message(STATUS "Looking for OpenMP support...") find_package(OpenMP QUIET) if(OPENMP_FOUND) set(AER_COMPILER_FLAGS "${AER_COMPILER_FLAGS} ${OpenMP_CXX_FLAGS}") set(AER_LINKER_FLAGS "${AER_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS} ${OpenMP_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") + if(APPLE) + set(AER_SIMULATOR_CPP_EXTERNAL_LIBS ${AER_SIMULATOR_CPP_EXTERNAL_LIBS} ${OpenMP_CXX_INCLUDE_DIRS}) + # On Apple and clang, we do need to link against the library unless we are building + # the Terra Addon, see issue: https://github.com/Qiskit/qiskit-aer/issues/1 + if(NOT SKBUILD) + set(AER_LIBRARIES "${AER_LIBRARIES}" "${OpenMP_${OpenMP_CXX_LIB_NAMES}_LIBRARY}") + message(STATUS "Adding Clang: ${OpenMP_${OpenMP_CXX_LIB_NAMES}_LIBRARY}") + else() + get_filename_component(OPENMP_LIB_TO_COPY ${OpenMP_${OpenMP_CXX_LIB_NAMES}_LIBRARY} REALPATH) #Needed to follow symlinks + set(BACKEND_REDIST_DEPS ${BACKEND_REDIST_DEPS} ${OPENMP_LIB_TO_COPY}) + endif() + endif() message(STATUS "OpenMP found!") message(STATUS "OpenMP_CXX_FLAGS = ${OpenMP_CXX_FLAGS}") message(STATUS "OpenMP_EXE_LINKER_FLAGS = ${OpenMP_EXE_LINKER_FLAGS}") @@ -197,7 +210,7 @@ else() set(WIN_ARCH "win32") endif() execute_process(COMMAND ${CMAKE_COMMAND} -E tar "xvfj" "${AER_SIMULATOR_CPP_SRC_DIR}/third-party/${WIN_ARCH}/lib/openblas.7z" WORKING_DIRECTORY "${AER_SIMULATOR_CPP_SRC_DIR}/third-party/${WIN_ARCH}/lib/") - set(OPENBLAS_DLLs "${AER_SIMULATOR_CPP_SRC_DIR}/third-party/${WIN_ARCH}/lib/libopenblas.dll") + set(BACKEND_REDIST_DEPS ${BACKEND_REDIST_DEPS} "${AER_SIMULATOR_CPP_SRC_DIR}/third-party/${WIN_ARCH}/lib/libopenblas.dll") set(BLAS_LIBRARIES "${AER_SIMULATOR_CPP_SRC_DIR}/third-party/${WIN_ARCH}/lib/libopenblas.dll.a") # Seems CMake is unable to find it on its own set(BLAS_FOUND True) else() @@ -249,21 +262,19 @@ if(AER_THRUST_SUPPORTED) set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -ccbin \"${CMAKE_CXX_COMPILER}\" ${AER_CUDA_ARCH_FLAGS_EXPAND} -DAER_THRUST_CUDA -I${AER_SIMULATOR_CPP_SRC_DIR} -isystem ${AER_SIMULATOR_CPP_SRC_DIR}/third-party/headers -use_fast_math --expt-extended-lambda") set(AER_COMPILER_DEFINITIONS ${AER_COMPILER_DEFINITIONS} THRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA) - set(THRUST_DEPENDANT_LIBS "") + set(THRUST_DEPENDENT_LIBS "") elseif(AER_THRUST_BACKEND STREQUAL "TBB") message(STATUS "TBB Support found!") - set(AER_SIMULATOR_CPP_EXTERNAL_LIBS ${AER_SIMULATOR_CPP_EXTERNAL_LIBS} ${CONAN_INCLUDE_DIRS_THRUST}) - set(THRUST_DEPENDANT_LIBS CONAN_PKG::tbb) + set(THRUST_DEPENDENT_LIBS AER_DEPENDENCY_PKG::tbb) set(AER_COMPILER_DEFINITIONS ${AER_COMPILER_DEFINITIONS} AER_THRUST_CPU=TRUE) elseif(AER_THRUST_BACKEND STREQUAL "OMP") message(STATUS "Thrust library: Setting OMP backend") if(NOT OPENMP_FOUND) message(FATAL_ERROR "There's no OMP support. We cannot set Thrust backend to OMP!!") endif() - set(AER_SIMULATOR_CPP_EXTERNAL_LIBS ${AER_SIMULATOR_CPP_EXTERNAL_LIBS} ${CONAN_INCLUDE_DIRS_THRUST}) set(AER_COMPILER_DEFINITIONS ${AER_COMPILER_DEFINITIONS} AER_THRUST_CPU=TRUE) # We don't need to add OMP because it's already an AER dependency - set(THRUST_DEPENDANT_LIBS "") + set(THRUST_DEPENDENT_LIBS "") else() message(STATUS "No Thrust supported backend") set(AER_THRUST_SUPPORTED FALSE) @@ -281,16 +292,16 @@ endif() set(AER_LIBRARIES ${AER_LIBRARIES} ${BLAS_LIBRARIES} - CONAN_PKG::nlohmann_json + AER_DEPENDENCY_PKG::nlohmann_json + AER_DEPENDENCY_PKG::spdlog Threads::Threads - CONAN_PKG::spdlog ${DL_LIB} - ${THRUST_DEPENDANT_LIBS}) + ${THRUST_DEPENDENT_LIBS}) set(AER_COMPILER_DEFINITIONS ${AER_COMPILER_DEFINITIONS} ${CONAN_DEFINES}) # Cython build is only enabled if building through scikit-build. if(SKBUILD) # Terra Addon build - set(AER_LIBRARIES ${AER_LIBRARIES} CONAN_PKG::muparserx) + set(AER_LIBRARIES ${AER_LIBRARIES} AER_DEPENDENCY_PKG::muparserx) add_subdirectory(qiskit/providers/aer/pulse/qutip_extra_lite/cy) add_subdirectory(qiskit/providers/aer/backends/wrappers) add_subdirectory(src/open_pulse) @@ -343,9 +354,9 @@ else() # Standalone build PRIVATE ${AER_COMPILER_DEFINITIONS}) if(WIN32 AND NOT BLAS_LIB_PATH) add_custom_command(TARGET qasm_simulator POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${OPENBLAS_DLLs} + ${BACKEND_REDIST_DEPS} $) - install(FILES ${OPENBLAS_DLLs} DESTINATION bin) + install(FILES ${BACKEND_REDIST_DEPS} DESTINATION bin) endif() install(TARGETS qasm_simulator DESTINATION bin) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5f8a0ace60..68fc2d0cdf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -249,7 +249,7 @@ window $ git clone https://github.com/Qiskit/qiskit-aer ``` -- Next, install the platform-specific dependencies for your operating system [Linux](#linux-dependencies) | [macOS](#mac-dependencies) | [Windows](#win-dependencies). +- Next, install the platform-specific dependencies for your operating system [Linux](#linux-dependencies) | [macOS](#mac-dependencies) | [Windows](#win-dependencies). - The common dependencies can then be installed via *pip*, using the `requirements-dev.txt` file, e.g.: @@ -258,11 +258,14 @@ window $ pip install -r requirements-dev.txt ``` -This will also install [**Conan**](https://conan.io/), a C/C++ package manager written in Python. This tool will handle -most of the dependencies needed by the C++ source code. Internet connection may be needed for the first build or -when dependencies are added/updated, in order to download the required packages if they are not in your **Conan** local +This will also install [**Conan**](https://conan.io/), a C/C++ package manager written in Python. This tool will handle +most of the dependencies needed by the C++ source code. Internet connection may be needed for the first build or +when dependencies are added/updated, in order to download the required packages if they are not in your **Conan** local repository. +> Note: Conan use can be disabled with the flag or environment variable ``DISABLE_CONAN=ON`` . +This is useful for building from source offline, or to reuse the installed package dependencies. + If we are only building the standalone version and do not want to install all Python requirements you can just install **Conan**: @@ -607,7 +610,7 @@ For example, qiskit-aer$ python ./setup.py bdist_wheel -- -DAER_THRUST_BACKEND=CUDA -If we want to specify the CUDA® architecture instead of letting the build system +If we want to specify the CUDA® architecture instead of letting the build system auto detect it, we can use the AER_CUDA_ARCH flag (can also be set as an ENV variable with the same name, although the flag takes precedence). For example: @@ -661,7 +664,7 @@ These are the flags: Tells CMake the directory to look for the BLAS library instead of the usual paths. If no BLAS library is found under that directory, CMake will raise an error and stop. - + It can also be set as an ENV variable with the same name, although the flag takes precedence. Values: An absolute path. @@ -700,11 +703,29 @@ These are the flags: This flag allows us we to specify the CUDA architecture instead of letting the build system auto detect it. It can also be set as an ENV variable with the same name, although the flag takes precedence. - + Values: Auto | Common | All | List of valid CUDA architecture(s). Default: Auto Example: ``python ./setup.py bdist_wheel -- -DAER_THRUST_BACKEND=CUDA -DAER_CUDA_ARCH="5.2; 5.3"`` +* DISABLE_CONAN + + This flag allows disabling the Conan package manager. This will force CMake to look for + the libraries in use on your system path, relying on FindPackage CMake mechanism and + the appropriate configuration of libraries in order to use it. + If a specific version is not found, the build system will look for any version available, + although this may produce build errors or incorrect behaviour. + + __WARNING__: This is not the official procedure to build AER. Thus, the user is responsible + of providing all needed libraries and corresponding files to make them findable to CMake. + + This is also available as the environment variable ``DISABLE_CONAN``, which overrides + the CMake flag of the same name. + + Values: ON | OFF + Default: OFF + Example: ``python ./setup.py bdist_wheel -- -DDISABLE_CONAN=ON`` + ## Tests Code contribution are expected to include tests that provide coverage for the diff --git a/cmake/conan_utils.cmake b/cmake/conan_utils.cmake index 9f9720a60b..2fbc30f53b 100644 --- a/cmake/conan_utils.cmake +++ b/cmake/conan_utils.cmake @@ -1,13 +1,20 @@ include(conan) +macro(_rename_conan_lib package) + add_library(AER_DEPENDENCY_PKG::${package} INTERFACE IMPORTED) + target_link_libraries(AER_DEPENDENCY_PKG::${package} PUBLIC INTERFACE CONAN_PKG::${package}) +endmacro() + macro(setup_conan) # Right now every dependency shall be static set(CONAN_OPTIONS ${CONAN_OPTIONS} "*:shared=False") set(REQUIREMENTS nlohmann_json/3.1.1 spdlog/1.5.0) + list(APPEND AER_CONAN_LIBS nlohmann_json spdlog) if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(REQUIREMENTS ${REQUIREMENTS} llvm-openmp/8.0.1) + list(APPEND AER_CONAN_LIBS llvm-openmp) if(SKBUILD) set(CONAN_OPTIONS ${CONAN_OPTIONS} "llvm-openmp:shared=True") endif() @@ -15,6 +22,7 @@ macro(setup_conan) if(SKBUILD) set(REQUIREMENTS ${REQUIREMENTS} muparserx/4.0.8) + list(APPEND AER_CONAN_LIBS muparserx) if(NOT MSVC) set(CONAN_OPTIONS ${CONAN_OPTIONS} "muparserx:fPIC=True") endif() @@ -22,12 +30,17 @@ macro(setup_conan) if(AER_THRUST_BACKEND AND NOT AER_THRUST_BACKEND STREQUAL "CUDA") set(REQUIREMENTS ${REQUIREMENTS} thrust/1.9.5) + list(APPEND AER_CONAN_LIBS thrust) string(TOLOWER ${AER_THRUST_BACKEND} THRUST_BACKEND) set(CONAN_OPTIONS ${CONAN_OPTIONS} "thrust:device_system=${THRUST_BACKEND}") + if(THRUST_BACKEND MATCHES "tbb") + list(APPEND AER_CONAN_LIBS tbb) + endif() endif() if(BUILD_TESTS) set(REQUIREMENTS ${REQUIREMENTS} catch2/2.12.1) + list(APPEND AER_CONAN_LIBS catch2) endif() # Add Appleclang-12 until officially supported by Conan @@ -40,4 +53,25 @@ macro(setup_conan) CMAKE_TARGETS KEEP_RPATHS BUILD missing) + + # Headers includes + if(AER_THRUST_BACKEND AND NOT AER_THRUST_BACKEND STREQUAL "CUDA") + set(AER_SIMULATOR_CPP_EXTERNAL_LIBS ${AER_SIMULATOR_CPP_EXTERNAL_LIBS} ${CONAN_INCLUDE_DIRS_THRUST}) + endif() + + # Reassign targets from CONAN_PKG to AER_DEPENDENCY_PKG + foreach(CONAN_LIB ${AER_CONAN_LIBS}) + _rename_conan_lib(${CONAN_LIB}) + endforeach() + + if(APPLE) + set(OPENMP_FOUND TRUE) + if(NOT SKBUILD) + set(AER_LIBRARIES ${AER_LIBRARIES} AER_DEPENDENCY_PKG::llvm-openmp) + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CONAN_CXX_FLAGS_LLVM-OPENMP}") + set(AER_SIMULATOR_CPP_EXTERNAL_LIBS ${AER_SIMULATOR_CPP_EXTERNAL_LIBS} ${CONAN_INCLUDE_DIRS_LLVM-OPENMP}) + set(BACKEND_REDIST_DEPS ${BACKEND_REDIST_DEPS} "${CONAN_LIB_DIRS_LLVM-OPENMP}/libomp.dylib") + endif() + endif() endmacro() diff --git a/cmake/dependency_utils.cmake b/cmake/dependency_utils.cmake new file mode 100644 index 0000000000..0952da0a2e --- /dev/null +++ b/cmake/dependency_utils.cmake @@ -0,0 +1,64 @@ +# This code is part of Qiskit. +# +# (C) Copyright IBM 2020 +# +# This code is licensed under the Apache License, Version 2.0. You may +# obtain a copy of this license in the LICENSE.txt file in the root directory +# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. +# +# Any modifications or derivative works of this code must retain this +# copyright notice, and modified files need to carry a notice indicating +# that they have been altered from the originals. + + +macro(setup_dependencies) + # Defines AER_DEPENDENCY_PKG alias which refers to either conan-provided or system libraries. + if(DISABLE_CONAN) + _use_system_libraries() + else() + include(conan_utils) + setup_conan() + endif() +endmacro() + +macro(_use_system_libraries) + # Use system libraries + _import_aer_system_dependency(nlohmann_json 3.1.1) + _import_aer_system_dependency(spdlog 1.5.0) + + if(SKBUILD) + _import_aer_system_dependency(muparserx 4.0.8) + endif() + + if(AER_THRUST_BACKEND AND NOT AER_THRUST_BACKEND STREQUAL "CUDA") + string(TOLOWER ${AER_THRUST_BACKEND} THRUST_BACKEND) + _import_aer_system_dependency(Thrust 1.9.5) + endif() + + if(BUILD_TESTS) + _import_aer_system_dependency(Catch2 2.12.1) + endif() + + if(APPLE) + # Fix linking. See https://stackoverflow.com/questions/54068035 + link_directories(/usr/local/lib) #brew + link_directories(/opt/local/lib) #ports + endif() +endmacro() + +macro(_import_aer_system_dependency package version) + # Arguments: + # package: name of package to search for using find_package() + # version: version of package to search for + + find_package(${package} ${version} EXACT QUIET) + if(NOT ${package}_FOUND) + message(STATUS "${package} ${version} NOT found! Looking for any other version available.") + find_package(${package} REQUIRED) + message(STATUS "${package} version found: ${${package}_VERSION}. WARNING: This version may not work!!!") + endif() + string(TOLOWER ${package} PACKAGE_LOWER) # Conan use lowercase for every lib + add_library(AER_DEPENDENCY_PKG::${PACKAGE_LOWER} INTERFACE IMPORTED) + target_link_libraries(AER_DEPENDENCY_PKG::${PACKAGE_LOWER} PUBLIC INTERFACE ${package}) + message(STATUS "Using system-provided ${PACKAGE_LOWER} library") +endmacro() diff --git a/qiskit/providers/aer/backends/wrappers/CMakeLists.txt b/qiskit/providers/aer/backends/wrappers/CMakeLists.txt index 9f03653bd7..e3cff03581 100644 --- a/qiskit/providers/aer/backends/wrappers/CMakeLists.txt +++ b/qiskit/providers/aer/backends/wrappers/CMakeLists.txt @@ -44,8 +44,4 @@ target_compile_definitions(controller_wrappers PRIVATE ${AER_COMPILER_DEFINITION install(TARGETS controller_wrappers LIBRARY DESTINATION qiskit/providers/aer/backends) # Install redistributable dependencies -if(APPLE) - install(FILES "${CONAN_LIB_DIRS_LLVM-OPENMP}/libomp.dylib" DESTINATION qiskit/providers/aer/backends) -elseif(WIN32 AND NOT BLAS_LIB_PATH) - install(FILES ${OPENBLAS_DLLs} DESTINATION qiskit/providers/aer/backends) -endif() +install(FILES ${BACKEND_REDIST_DEPS} DESTINATION qiskit/providers/aer/backends) diff --git a/releasenotes/notes/cmake-optional-conan-bc99a895fc4345e1.yaml b/releasenotes/notes/cmake-optional-conan-bc99a895fc4345e1.yaml new file mode 100644 index 0000000000..ba3343d86f --- /dev/null +++ b/releasenotes/notes/cmake-optional-conan-bc99a895fc4345e1.yaml @@ -0,0 +1,9 @@ +--- +features: + - | + Add the CMake flag ``DISABLE_CONAN`` (default=``OFF``)s. When installing from source, + setting this to ``ON`` allows bypassing the Conan package manager to find libraries + that are already installed on your system. This is also available as an environment + variable ``DISABLE_CONAN``, which takes precedence over the CMake flag. + This is not the official procedure to build AER. Thus, the user is responsible + of providing all needed libraries and corresponding files to make them findable to CMake. diff --git a/setup.py b/setup.py index e0d5ad6cc6..b8a2f5fee1 100644 --- a/setup.py +++ b/setup.py @@ -3,13 +3,17 @@ """ Main setup file for qiskit-aer """ - +import distutils.util +import importlib +import inspect import os +import setuptools import subprocess import sys -import inspect + PACKAGE_NAME = os.getenv('QISKIT_AER_PACKAGE_NAME', 'qiskit-aer') +_DISABLE_CONAN = distutils.util.strtobool(os.getenv("DISABLE_CONAN", "OFF").lower()) try: from Cython.Build import cythonize @@ -18,11 +22,12 @@ subprocess.call([sys.executable, '-m', 'pip', 'install', 'Cython>=0.27.1']) from Cython.Build import cythonize -try: - from conans import client -except ImportError: - subprocess.call([sys.executable, '-m', 'pip', 'install', 'conan']) - from conans import client +if not _DISABLE_CONAN: + try: + from conans import client + except ImportError: + subprocess.call([sys.executable, '-m', 'pip', 'install', 'conan']) + from conans import client try: from skbuild import setup @@ -34,7 +39,8 @@ except ImportError: subprocess.call([sys.executable, '-m', 'pip', 'install', 'pybind11>=2.4']) -import setuptools +from skbuild import setup + # These are requirements that are both runtime/install dependencies and # also build time/setup requirements and will be added to both lists @@ -52,8 +58,9 @@ setup_requirements = common_requirements + [ 'scikit-build', 'cmake!=3.17,!=3.17.0', - 'conan>=1.22.2' ] +if not _DISABLE_CONAN: + setup_requirements.append('conan>=1.22.2') requirements = common_requirements + ['qiskit-terra>=0.12.0'] diff --git a/src/simulators/statevector/qv_avx2.cpp b/src/simulators/statevector/qv_avx2.cpp index adf9f2e60f..8434e037c0 100644 --- a/src/simulators/statevector/qv_avx2.cpp +++ b/src/simulators/statevector/qv_avx2.cpp @@ -22,7 +22,7 @@ /** * DISCLAIMER: We want to compile this code in isolation of the rest of the *codebase, because it contains AVX specific instructions, so is very CPU arch - *dependant. We will detect CPU features at runtime and derive the execution + *dependent. We will detect CPU features at runtime and derive the execution *path over here if AVX is supported, if it's not supported the QubitVector *normal class will be used instead (so no SIMD whatsoever). Because of this, we *don't want to depend on any other library, otherwise the linker could take AVX diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fe9b1589b1..4bf917e347 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -8,7 +8,7 @@ macro(add_test_executable target_name) PRIVATE ${AER_SIMULATOR_CPP_SRC_DIR} PRIVATE ${AER_SIMULATOR_CPP_EXTERNAL_LIBS}) target_link_libraries(${target_name} - PRIVATE CONAN_PKG::catch2 + PRIVATE AER_DEPENDENCY_PKG::catch2 PRIVATE ${AER_LIBRARIES}) add_test(${target_name} ${target_name}) endmacro() From 7153c695c67c2491c3dff6e7b8aee36ef3f65c40 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Tue, 10 Nov 2020 11:14:01 -0500 Subject: [PATCH 06/15] Remove cache step from azure-pipelines windows jobs (#1029) A recent change in the disk layout of the azure pipelines windows images has moved where the pip cache is stored on disk. This breaks the cache step in the job which tries to upload from the old path to a share cache between jobs. This commit removes the cache step to unblock CI since without this all CI jobs are blocked while try to upload the local pip cache. While this will increase the run time for the job and network traffic (which means the jobs are more prone to network errors), it is still better than a non-working CI. --- azure-pipelines.yml | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a3e0787417..1f1f7b4299 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -147,15 +147,6 @@ stages: submodules: true - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" displayName: Add conda to PATH - - task: Cache@2 - inputs: - key: 'pip | "$(Agent.OS)" | "$(python.version)" |"$(Build.BuildNumber)"' - restoreKeys: | - pip | "$(Agent.OS)" | "$(python.version)" - pip | "$(Agent.OS)" - pip - path: $(PIP_CACHE_DIR) - displayName: Cache pip - bash: | set -x set -e @@ -193,15 +184,6 @@ stages: submodules: true - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" displayName: Add conda to PATH - - task: Cache@2 - inputs: - key: 'pip | "$(Agent.OS)" | "$(python.version)" |"$(Build.BuildNumber)"' - restoreKeys: | - pip | "$(Agent.OS)" | "$(python.version)" - pip | "$(Agent.OS)" - pip - path: $(PIP_CACHE_DIR) - displayName: Cache pip - bash: | set -x set -e @@ -254,15 +236,6 @@ stages: submodules: true - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" displayName: Add conda to PATH - - task: Cache@2 - inputs: - key: 'pip | "$(Agent.OS)" | "$(python.version)" |"$(Build.BuildNumber)"' - restoreKeys: | - pip | "$(Agent.OS)" | "$(python.version)" - pip | "$(Agent.OS)" - pip - path: $(PIP_CACHE_DIR) - displayName: Cache pip - bash: | set -x set -e From c1b84990a9ea8d443b791330d2cec2740cd1de8c Mon Sep 17 00:00:00 2001 From: Victor Villar <59838221+vvilpas@users.noreply.github.com> Date: Wed, 11 Nov 2020 12:55:32 +0100 Subject: [PATCH 07/15] Fix conan dependency problem with urllib3 (#1031) urllib3 1.26.0 has been released, causing a dependency error when installing conan. Here I add urllib3 add as a dependency and cosntrainit it <1.26 to avoid this problem. --- .github/workflows/main.yml | 2 +- pyproject.toml | 2 +- requirements-dev.txt | 3 +++ setup.py | 4 ++++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5111b9e875..c24711f277 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -81,7 +81,7 @@ jobs: with: python-version: 3.7 - name: Install deps - run: pip install conan + run: pip install "urllib3<1.26" conan - name: Install openblas run: | set -e diff --git a/pyproject.toml b/pyproject.toml index 04b39f580f..0e00e6d818 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,2 @@ [build-system] -requires = ["setuptools", "wheel", "conan>=1.22.2", "scikit-build", "cmake!=3.17.1,!=3.17.0", "ninja", "pybind11>2.4", "Cython>0.27.1"] +requires = ["setuptools", "wheel", "urllib3<1.26", "conan>=1.22.2", "scikit-build", "cmake!=3.17.1,!=3.17.0", "ninja", "pybind11>2.4", "Cython>0.27.1"] diff --git a/requirements-dev.txt b/requirements-dev.txt index 0b1eb58f5a..201ca40425 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -14,3 +14,6 @@ sphinx-automodapi jupyter-sphinx;python_version<'3.8' reno>=3.1.0 ddt>=1.2.0,!=1.4.0 + +# Problem with Conan and urllib3==1.26 +urllib3<1.26 diff --git a/setup.py b/setup.py index b8a2f5fee1..cf88f2b5e9 100644 --- a/setup.py +++ b/setup.py @@ -26,6 +26,9 @@ try: from conans import client except ImportError: + # Problem with Conan and urllib3 1.26 + subprocess.call([sys.executable, '-m', 'pip', 'install', 'urllib3<1.26']) + subprocess.call([sys.executable, '-m', 'pip', 'install', 'conan']) from conans import client @@ -60,6 +63,7 @@ 'cmake!=3.17,!=3.17.0', ] if not _DISABLE_CONAN: + setup_requirements.append('urllib3<1.26') setup_requirements.append('conan>=1.22.2') requirements = common_requirements + ['qiskit-terra>=0.12.0'] From 62694c2c83927c6b06061390aa53c917a7b5e342 Mon Sep 17 00:00:00 2001 From: Victor Villar Date: Mon, 16 Nov 2020 14:18:06 +0100 Subject: [PATCH 08/15] Fix tests due to bad input to assemble function (#1039) In Qiskit/qiskit-terra#5298 a bug was fixed to ensure that a singe entry list passed to `transpile()` would always return a list instead of just a circuit object. However, in the aer tests there were a couple of places that were building a list assuming transpile would return a bare circuit object. When the terra fix merged changing the return type the tests started to fail because the input to the `assemble()` function was now a list of a list of circuits instead of the intend list of circuits. This commit fixes this issue so it works with the corrected terra behavior. --- test/terra/backends/qasm_simulator/qasm_fusion.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/terra/backends/qasm_simulator/qasm_fusion.py b/test/terra/backends/qasm_simulator/qasm_fusion.py index a10f4947ce..b5d54ea4b5 100644 --- a/test/terra/backends/qasm_simulator/qasm_fusion.py +++ b/test/terra/backends/qasm_simulator/qasm_fusion.py @@ -188,7 +188,7 @@ def test_kraus_noise_fusion(self): backend=self.SIMULATOR, basis_gates=noise_model.basis_gates, optimization_level=0) - qobj = assemble([circuit], + qobj = assemble(circuit, self.SIMULATOR, shots=shots, seed_simulator=1) @@ -217,7 +217,7 @@ def test_non_kraus_noise_fusion(self): backend=self.SIMULATOR, basis_gates=noise_model.basis_gates, optimization_level=0) - qobj = assemble([circuit], + qobj = assemble(circuit, self.SIMULATOR, shots=shots, seed_simulator=1) From 2cf659f62207b2791a56855557987f164074ec82 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Tue, 17 Nov 2020 11:04:37 -0500 Subject: [PATCH 09/15] Update setup-build action version (#1045) This commit updates the version of the setup-msbuild action we use in the windows ci jobs. This action is used to setup the compilers in the windows environment, but the version we were using was relying on a previously deprecated and now removed feature in github actions and has now stopped working. By updating the version we should unblock CI. --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c24711f277..a78693e237 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -90,7 +90,7 @@ jobs: shell: bash if: runner.os == 'Linux' - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.0.1 + uses: microsoft/setup-msbuild@v1.0.2 if: runner.os == 'Windows' - name: Compile Standalone Windows run: | @@ -219,7 +219,7 @@ jobs: ${{ runner.os }}-${{ matrix.python-version}}- if: runner.os == 'Windows' - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.0.1 + uses: microsoft/setup-msbuild@v1.0.2 if: runner.os == 'Windows' - name: Install Deps run: python -m pip install -U -r requirements-dev.txt wheel git+https://github.com/Qiskit/qiskit-terra From 5cc17751e263dd77bec533764f4c255791e6c02f Mon Sep 17 00:00:00 2001 From: Maureen McElaney Date: Wed, 18 Nov 2020 16:41:57 -0500 Subject: [PATCH 10/15] Qiskit projects point to main CoC (#1049) --- CODE_OF_CONDUCT.md | 116 +++------------------------------------------ 1 file changed, 6 insertions(+), 110 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 159eca449b..f82b61c5f6 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,113 +1,9 @@ -# Code of Conduct - -## Our Pledge - -The Qiskit Community is dedicated to our values of treating every individual -with respect and dignity. In the interest of fostering an open and welcoming -environment, all participants, including attendees, speakers, sponsors, -volunteers, online contributors, and IBM employees are expected to show -courtesy for each other and our community by creating a harassment-free -experience for everyone, regardless of age, personal appearance, disability, -ethnicity, gender identity and expression, body size, level of experience, -nationality, race, religion, caste, or sexual identity and orientation. -Expected behavior applies to both online and offline engagement within the -Qiskit Community. - -## Scope - -The purpose of this Code of Conduct is to define and enforce the values and -conduct of contributors and participants in the Qiskit open source community. -The Code of Conduct applies both within project spaces and in public spaces -when an individual is engaging with the Qiskit open source community. Examples -include attending a Qiskit event, contributing to online projects, commentary -on Slack, or representing a project or community, including using an official -project e-mail address, posting via an official social media account, or -acting as an appointed representative at an online or offline event. -Representation of a project may be further defined and clarified by project -maintainers. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment -include: + -- Using welcoming and inclusive language -- Being respectful of differing viewpoints, experiences, and cultures -- Gracefully accepting constructive criticism -- Focusing on what is best for the community -- Showing empathy towards other community members -- Being mindful of your surroundings and your fellow participants and listening - to others -- Valuing the contributions of all participants -- Engaging in collaboration before conflict -- Pointing out unintentionally racist, sexist, casteist, or biased comments and - jokes made by community members when they happen - -Examples of unacceptable behavior by participants, even when presented as -"ironic" or "joking," include: - -- The use of sexualized language or imagery and unwelcome physical contact, - sexual attention, or advances -- Trolling, insulting/derogatory comments, and personal or political attacks -- Public or private harassment, including offensive or degrading language -- Publishing others' private information, such as a physical or electronic - address, without explicit permission. This includes any sort of "outing" of - any aspect of someone's identity without their consent. -- "Doxxing," Publishing screenshots or quotes, especially from identity slack - channels, private chat, or public events, without all quoted users' explicit - consent. -- Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Responsibilities & Enforcement - -The entire Qiskit community is responsible for upholding the terms of the Code -of Conduct in Qiskit Community events and spaces and reporting violations if -they see them. The internal Qiskit team at IBM is ultimately responsible for -clarifying the standards of acceptable behavior and enforcement, and is expected -to take appropriate and fair corrective action in response to any instances of -unacceptable behavior. - -If a participant or contributor engages in negative or harmful behavior, IBM -will take any action they deem appropriate, including but not limited to -issuing warnings, expulsion from an event with no refund, deleting comments, -permanent banning from future events or online community, or calling local law -enforcement. IBM has the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, or to temporarily or permanently ban any -contributor or participant for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. - -If you see a Code of Conduct violation: +# Code of Conduct +All members of this project agree to adhere to the Qiskit Code of Conduct listed at [https://github.com/Qiskit/qiskit/blob/master/CODE_OF_CONDUCT.md](https://github.com/Qiskit/qiskit/blob/master/CODE_OF_CONDUCT.md) -1. If you feel comfortable, let the person know that what they did is not - appropriate and ask them to stop and/or edit or delete their message(s) or - comment(s). -2. If the person does not immediately stop the behavior or correct the issue, - or if you're uncomfortable speaking up, flag a moderator and, if appropriate, - fill out the anonymous - [Code of Conduct violation form](https://airtable.com/shrl5mEF4Eun1aIDm). -3. The Qiskit Community will open an investigation upon receiving your form - entry. When reporting, please include any relevant details, links, - screenshots, context, or other information that may be used to better - understand and resolve the situation. -4. If the code of conduct violation occurs at an event and requires immediate - response or contains a concern about an individual attending an upcoming - event, contact the event's on-call Code of Conduct point of contact listed - in the event specific code of conduct document. If you don't feel comfortable - speaking to the point of contact in person, fill out a Code of Conduct - violation form entry and include the details of the event so that the Code of - Conduct enforcement board can contact the event's on-call Code of Conduct - point of contact. -5. If an IBM employee witnesses a Code of Conduct violation at any time, such as - at events, in a Slack channel, or open source forums, it is their - responsibility to file a Code of Conduct violation report. +---- -This Code of Conduct does not supersede existing IBM corporate policies, such as -the IBM Business Conduct Guidelines and IBM Business Partner Code of Conduct. -IBM employees must follow IBM's Business Conduct Guidelines. IBM's business -partners must follow the IBM Business Partner Code of Conduct. IBM employees -concerned with a fellow IBMer's behavior should follow IBM's own internal HR -reporting protocols, which include engaging the offending IBMer's manager and -involving IBM Concerns and Appeals. IBM employees concerned with an IBM -business partner's behavior should notify tellibm@us.ibm.com. +License: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), +Copyright Contributors to Qiskit. From 1efa655bcd47f22bc7b3d7c6681566c2427ec88b Mon Sep 17 00:00:00 2001 From: Victor Villar Date: Tue, 24 Nov 2020 08:27:35 +0100 Subject: [PATCH 11/15] Run C++ unit tests on CI (#1051) --- .github/workflows/main.yml | 19 +++++++++++++++++-- test/CMakeLists.txt | 5 +++++ test/src/test_linalg.cpp | 2 ++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a78693e237..05e639e06a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -95,17 +95,32 @@ jobs: - name: Compile Standalone Windows run: | set -e - mkdir out; cd out; cmake .. + mkdir out; cd out; cmake .. -DBUILD_TESTS=1 cmake --build . --config Release shell: bash if: runner.os == 'Windows' - name: Compile Standalone run: | set -e - mkdir out; cd out; cmake .. + mkdir out; cd out; cmake .. -DBUILD_TESTS=1 make shell: bash if: runner.os != 'Windows' + - name: Run Unit Tests + run: | + cd out/bin + for test in test* + do echo $test + if ! ./$test + then + ERR=1 + fi + done + if [ ! -z "$ERR" ] + then + exit 1 + fi + shell: bash sdist: name: compile-sdist-python${{ matrix.python-version }}-${{ matrix.platform.os }} runs-on: ${{ matrix.platform.os }} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4bf917e347..ea92f6946c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -11,6 +11,11 @@ macro(add_test_executable target_name) PRIVATE AER_DEPENDENCY_PKG::catch2 PRIVATE ${AER_LIBRARIES}) add_test(${target_name} ${target_name}) + if(WIN32 AND NOT BLAS_LIB_PATH) + add_custom_command(TARGET test_linalg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${BACKEND_REDIST_DEPS} + $) + endif() endmacro() add_test_executable(test_linalg "src/test_linalg.cpp") diff --git a/test/src/test_linalg.cpp b/test/src/test_linalg.cpp index f1fdfffecc..e3843f1544 100644 --- a/test/src/test_linalg.cpp +++ b/test/src/test_linalg.cpp @@ -12,6 +12,8 @@ * that they have been altered from the originals. */ +#define _USE_MATH_DEFINES +#include #include #include #include From 512118dc12fe26248867863b4759e0fd7fb27667 Mon Sep 17 00:00:00 2001 From: Victor Villar Date: Wed, 25 Nov 2020 09:26:55 +0100 Subject: [PATCH 12/15] Fix mismatch between BLAS_LIB_PATH and AER_BLAS_LIB_PATH (#1054) Co-authored-by: Christopher J. Wood --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 505b20c7b5..6c52bf7a92 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -193,8 +193,8 @@ if(STATIC_LINKING) set(BLA_STATIC TRUE) endif() -if(BLAS_LIB_PATH) - find_BLAS_in_specific_path(${BLAS_LIB_PATH}) +if(AER_BLAS_LIB_PATH) + find_BLAS_in_specific_path(${AER_BLAS_LIB_PATH}) else() if(APPLE) message(STATUS "Looking for Apple BLAS & Lapack library...") @@ -352,7 +352,7 @@ else() # Standalone build PRIVATE ${AER_SIMULATOR_CPP_EXTERNAL_LIBS}) target_compile_definitions(qasm_simulator PRIVATE ${AER_COMPILER_DEFINITIONS}) - if(WIN32 AND NOT BLAS_LIB_PATH) + if(WIN32 AND NOT AER_BLAS_LIB_PATH) add_custom_command(TARGET qasm_simulator POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${BACKEND_REDIST_DEPS} $) From b3844a98285f4760cd1dedb44fb75259766743d7 Mon Sep 17 00:00:00 2001 From: "Christopher J. Wood" Date: Wed, 2 Dec 2020 17:30:59 -0500 Subject: [PATCH 13/15] Break main GHA into multiple workflows (#1064) --- .github/workflows/build.yml | 86 +++++ .github/workflows/{wheels.yml => deploy.yml} | 2 +- .github/workflows/docs.yml | 88 +++++ .github/workflows/main.yml | 318 ------------------- .github/workflows/tests_linux.yml | 126 ++++++++ .github/workflows/tests_mac.yml | 125 ++++++++ .github/workflows/tests_windows.yml | 83 +++++ 7 files changed, 509 insertions(+), 319 deletions(-) create mode 100644 .github/workflows/build.yml rename .github/workflows/{wheels.yml => deploy.yml} (99%) create mode 100644 .github/workflows/docs.yml delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/tests_linux.yml create mode 100644 .github/workflows/tests_mac.yml create mode 100644 .github/workflows/tests_windows.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..c4e18a5eca --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,86 @@ +name: Build +on: + push: + branches: [master, 'stable/*'] + pull_request: + branches: [master, 'stable/*'] +jobs: + standalone: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ["macOS-latest", "ubuntu-latest", "windows-latest"] + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Install deps + run: pip install "urllib3<1.26" conan + - name: Install openblas + run: | + set -e + sudo apt-get update + sudo apt-get install -y libopenblas-dev + shell: bash + if: runner.os == 'Linux' + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.0.2 + if: runner.os == 'Windows' + - name: Compile Standalone Windows + run: | + set -e + mkdir out; cd out; cmake .. -DBUILD_TESTS=1 + cmake --build . --config Release + shell: bash + if: runner.os == 'Windows' + - name: Compile Standalone + run: | + set -e + mkdir out; cd out; cmake .. -DBUILD_TESTS=1 + make + shell: bash + if: runner.os != 'Windows' + - name: Run Unit Tests + run: | + cd out/bin + for test in test* + do echo $test + if ! ./$test + then + ERR=1 + fi + done + if [ ! -z "$ERR" ] + then + exit 1 + fi + shell: bash + wheel: + runs-on: ${{ matrix.os }} + needs: ["standalone"] + strategy: + matrix: + os: ["macOS-latest", "ubuntu-latest"] + steps: + - uses: actions/checkout@v2 + - name: Set up Python Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install deps + run: python -m pip install -U cibuildwheel==1.7.0 + - name: Build Wheels + env: + CIBW_BEFORE_ALL_LINUX: "yum install -y openblas-devel" + CIBW_BEFORE_BUILD: "pip install -U virtualenv pybind11" + CIBW_SKIP: "cp27-* cp34-* cp35-* cp39-* pp*" + CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2010" + CIBW_MANYLINUX_I686_IMAGE: "manylinux2010" + CIBW_TEST_COMMAND: "python3 {project}/tools/verify_wheels.py" + CIBW_TEST_REQUIRES: "git+https://github.com/Qiskit/qiskit-terra.git" + run: cibuildwheel --output-dir wheelhouse + - uses: actions/upload-artifact@v2 + with: + path: ./wheelhouse/*.whl diff --git a/.github/workflows/wheels.yml b/.github/workflows/deploy.yml similarity index 99% rename from .github/workflows/wheels.yml rename to .github/workflows/deploy.yml index 932f0f8249..8784790f5c 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: Build +name: Deploy on: push: tags: diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000000..0b09f548c7 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,88 @@ +name: Docs and Tutorial +on: + push: + branches: [master, 'stable/*'] + pull_request: + branches: [master, 'stable/*'] +jobs: + docs: + runs-on: ubuntu-latest + timeout-minutes: 60 + strategy: + matrix: + python-version: [3.7] + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-${{ matrix.python-version}}-pip-docs-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.python-version}}-pip-docs- + ${{ runner.os }}-${{ matrix.python-version}}-pip- + ${{ runner.os }}-${{ matrix.python-version}}- + - name: Install Deps + run: | + set -e + pip install -U pip virtualenv wheel + pip install -U tox + sudo apt-get update + sudo apt-get install -y build-essential libopenblas-dev + shell: bash + - name: Run Docs Build + run: tox -edocs + - uses: actions/upload-artifact@v2 + with: + name: html_docs + path: docs/_build/html + tutorials: + runs-on: ubuntu-latest + needs: [docs] + strategy: + matrix: + python-version: [3.7] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~\AppData\Local\pip\Cache + key: ${{ runner.os }}-${{ matrix.python-version}}-pip-tutorials-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.python-version}}-pip-tutorials- + ${{ runner.os }}-${{ matrix.python-version}}-pip- + ${{ runner.os }}-${{ matrix.python-version}}}- + - name: Setup tutorials job + run: | + set -e + git clone https://github.com/Qiskit/qiskit-tutorials --depth=1 + python -m pip install --upgrade pip wheel + pip install -U -r requirements-dev.txt -c constraints.txt + pip install -c constraints.txt git+https://github.com/Qiskit/qiskit-terra + pip install -c constraints.txt . + pip install -U "qiskit-ibmq-provider" "z3-solver" "qiskit-ignis" "qiskit-aqua" "pyscf<1.7.4" "matplotlib<3.3.0" jupyter pylatexenc sphinx nbsphinx sphinx_rtd_theme cvxpy -c constraints.txt + python setup.py build_ext --inplace + sudo apt install -y graphviz pandoc libopenblas-dev + pip check + shell: bash + - name: Run Tutorials + run: | + set -e + cd qiskit-tutorials + rm -rf tutorials/chemistry tutorials/circuits tutorials/circuits_advanced tutorials/finance tutorials/optimization tutorials/noise + sphinx-build -b html . _build/html + - uses: actions/upload-artifact@v2 + with: + name: tutorials_html + path: qiskit-tutorials/_build/html diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 05e639e06a..0000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,318 +0,0 @@ -name: Compile tests -on: - push: - branches: [master, 'stable/*'] - pull_request: - branches: [master, 'stable/*'] -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Pip cache - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-lint-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} - restore-keys: | - ${{ runner.os }}-pip-lint- - ${{ runner.os }}-pip- - ${{ runner.os }}- - - name: Install deps - run: | - set -e - pip install -U pip wheel - pip install -U -c constraints.txt git+https://github.com/Qiskit/qiskit-terra - pip install -U -c constraints.txt -r requirements-dev.txt - shell: bash - - name: Run Lint - run: | - set -e - pycodestyle --ignore=E402,W504 --max-line-length=100 qiskit/providers/aer - pylint -j 2 -rn qiskit/providers/aer - docs: - runs-on: ubuntu-latest - timeout-minutes: 60 - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Set up Python 3.7 - uses: actions/setup-python@v2 - with: - python-version: 3.7 - - name: Pip cache - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-docs-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} - restore-keys: | - ${{ runner.os }}-pip-docs- - ${{ runner.os }}-pip- - ${{ runner.os }}- - - name: Install Deps - run: | - set -e - pip install -U pip virtualenv wheel - pip install -U tox - sudo apt-get update - sudo apt-get install -y build-essential libopenblas-dev - shell: bash - - name: Run Docs Build - run: tox -edocs - - uses: actions/upload-artifact@v2 - with: - name: html_docs - path: docs/_build/html - standalone: - name: compile-standalone-${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: ["macOS-latest", "ubuntu-latest", "windows-latest"] - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.7 - uses: actions/setup-python@v2 - with: - python-version: 3.7 - - name: Install deps - run: pip install "urllib3<1.26" conan - - name: Install openblas - run: | - set -e - sudo apt-get update - sudo apt-get install -y libopenblas-dev - shell: bash - if: runner.os == 'Linux' - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.0.2 - if: runner.os == 'Windows' - - name: Compile Standalone Windows - run: | - set -e - mkdir out; cd out; cmake .. -DBUILD_TESTS=1 - cmake --build . --config Release - shell: bash - if: runner.os == 'Windows' - - name: Compile Standalone - run: | - set -e - mkdir out; cd out; cmake .. -DBUILD_TESTS=1 - make - shell: bash - if: runner.os != 'Windows' - - name: Run Unit Tests - run: | - cd out/bin - for test in test* - do echo $test - if ! ./$test - then - ERR=1 - fi - done - if [ ! -z "$ERR" ] - then - exit 1 - fi - shell: bash - sdist: - name: compile-sdist-python${{ matrix.python-version }}-${{ matrix.platform.os }} - runs-on: ${{ matrix.platform.os }} - needs: ["lint"] - strategy: - matrix: - python-version: [3.6, 3.7, 3.8] - platform: [ - { os: "macOS-latest", python-architecture: "x64"}, - { os: "ubuntu-latest", python-architecture: "x64" }, - ] - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Pip cache - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-${{ matrix.python-version}}-pip-sdist-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} - restore-keys: | - ${{ runner.os }}-${{ matrix.python-version}}-pip-sdist- - ${{ runner.os }}-${{ matrix.python-version}}-pip- - ${{ runner.os }}-${{ matrix.python-version}}- - - name: Install Deps - run: python -m pip install -U setuptools wheel virtualenv - - name: Install openblas - run: | - set -e - sudo apt-get update - sudo apt-get install -y libopenblas-dev - shell: bash - if: runner.os == 'Linux' - - name: Build Sdist - run: python setup.py sdist - - name: Install from sdist and test - run: | - set -e - mkdir out; cd out; virtualenv aer-test - aer-test/bin/pip install ../dist/*tar.gz - aer-test/bin/pip install -c ../constraints.txt git+https://github.com/Qiskit/qiskit-terra - aer-test/bin/python ../tools/verify_wheels.py - aer-test/bin/pip check - shell: bash - wheel: - name: compile-wheel-${{ matrix.os }} - runs-on: ${{ matrix.os }} - needs: ["lint"] - strategy: - matrix: - os: ["macOS-latest", "ubuntu-latest"] - steps: - - uses: actions/checkout@v2 - - name: Set up Python Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Install deps - run: python -m pip install -U cibuildwheel==1.5.5 - - name: Build Wheels - env: - CIBW_BEFORE_ALL_LINUX: "yum install -y openblas-devel" - CIBW_BEFORE_BUILD: "pip install -U Cython virtualenv pybind11" - CIBW_SKIP: "cp27-* cp34-* cp35-* pp*" - CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2010" - CIBW_MANYLINUX_I686_IMAGE: "manylinux2010" - CIBW_TEST_COMMAND: "python3 {project}/tools/verify_wheels.py" - CIBW_TEST_REQUIRES: "git+https://github.com/Qiskit/qiskit-terra.git" - run: cibuildwheel --output-dir wheelhouse - - uses: actions/upload-artifact@v2 - with: - path: ./wheelhouse/*.whl - tests: - name: tests-python${{ matrix.python-version }}-${{ matrix.os }} - runs-on: ${{ matrix.os }} - needs: [standalone, sdist, lint, docs] - timeout-minutes: 25 - strategy: - matrix: - python-version: [3.6, 3.7, 3.8] - os: ["macOS-latest", "ubuntu-latest", "windows-latest"] - env: - AER_THRUST_BACKEND: OMP - QISKIT_TEST_CAPTURE_STREAMS: 1 - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Pip cache - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-${{ matrix.python-version}}-pip-test-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} - restore-keys: | - ${{ runner.os }}-${{ matrix.python-version}}-pip-test- - ${{ runner.os }}-${{ matrix.python-version}}-pip- - ${{ runner.os }}-${{ matrix.python-version}}- - if: runner.os != 'Windows' - - name: Pip cache - uses: actions/cache@v2 - with: - path: ~\AppData\Local\pip\Cache - key: ${{ runner.os }}-${{ matrix.python-version}}-pip-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} - restore-keys: | - ${{ runner.os }}-${{ matrix.python-version}}-pip-test- - ${{ runner.os }}-${{ matrix.python-version}}-pip- - ${{ runner.os }}-${{ matrix.python-version}}- - if: runner.os == 'Windows' - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.0.2 - if: runner.os == 'Windows' - - name: Install Deps - run: python -m pip install -U -r requirements-dev.txt wheel git+https://github.com/Qiskit/qiskit-terra - - name: Install openblas - run: | - set -e - sudo apt-get update - sudo apt-get install -y libopenblas-dev - shell: bash - if: runner.os == 'Linux' - - name: Install Aer - run: python -m pip install -U . - if: runner.os != 'Windows' - - name: Install Aer Windows - run: | - set -e - python setup.py bdist_wheel -- -G 'Visual Studio 16 2019' - pip install --find-links=dist qiskit-aer - shell: bash - if: runner.os == 'Windows' - - name: Run Tests - env: - QISKIT_SUPPRESS_PACKAGING_WARNINGS: Y - run: | - set -e - pip check - stestr run --slowest - shell: bash - if: runner.os != 'macOS' || matrix.python-version != '3.8' - - name: Run Tests macOS 3.8 - env: - QISKIT_SUPPRESS_PACKAGING_WARNINGS: Y - QISKIT_IN_PARALLEL: TRUE - run: | - set -e - pip check - stestr run --slowest - shell: bash - if: runner.os == 'macOS' && matrix.python-version == '3.8' - tutorials: - name: Tutorials - runs-on: ubuntu-latest - needs: [standalone, sdist, lint, docs] - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.7 - uses: actions/setup-python@v2 - with: - python-version: 3.7 - - name: Pip cache - uses: actions/cache@v2 - with: - path: ~\AppData\Local\pip\Cache - key: ${{ runner.os }}-pip-tutorials-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} - restore-keys: | - ${{ runner.os }}-pip-tutorials- - ${{ runner.os }}-pip- - ${{ runner.os }}- - - name: Setup tutorials job - run: | - set -e - git clone https://github.com/Qiskit/qiskit-tutorials --depth=1 - python -m pip install --upgrade pip wheel - pip install -U -r requirements-dev.txt -c constraints.txt - pip install -c constraints.txt git+https://github.com/Qiskit/qiskit-terra - pip install -c constraints.txt . - pip install -U "qiskit-ibmq-provider" "z3-solver" "qiskit-ignis" "qiskit-aqua" "pyscf<1.7.4" "matplotlib<3.3.0" jupyter pylatexenc sphinx nbsphinx sphinx_rtd_theme cvxpy -c constraints.txt - python setup.py build_ext --inplace - sudo apt install -y graphviz pandoc libopenblas-dev - pip check - shell: bash - - name: Run Tutorials - run: | - set -e - cd qiskit-tutorials - rm -rf tutorials/chemistry tutorials/circuits tutorials/circuits_advanced tutorials/finance tutorials/optimization tutorials/noise - sphinx-build -b html . _build/html - - uses: actions/upload-artifact@v2 - with: - name: tutorials_html - path: qiskit-tutorials/_build/html diff --git a/.github/workflows/tests_linux.yml b/.github/workflows/tests_linux.yml new file mode 100644 index 0000000000..ccb2523f74 --- /dev/null +++ b/.github/workflows/tests_linux.yml @@ -0,0 +1,126 @@ +name: Tests Linux +on: + push: + branches: [master, 'stable/*'] + pull_request: + branches: [master, 'stable/*'] +jobs: + lint: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-${{ matrix.python-version}}-pip-lint-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.python-version}}-pip-lint- + ${{ runner.os }}-${{ matrix.python-version}}-pip- + ${{ runner.os }}-${{ matrix.python-version}}- + - name: Install deps + run: | + set -e + pip install -U pip wheel + pip install -U -c constraints.txt git+https://github.com/Qiskit/qiskit-terra + pip install -U -c constraints.txt -r requirements-dev.txt + shell: bash + - name: Run Lint + run: | + set -e + pycodestyle --ignore=E402,W504 --max-line-length=100 qiskit/providers/aer + pylint -j 2 -rn qiskit/providers/aer + sdist: + runs-on: ${{ matrix.platform.os }} + needs: ["lint"] + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + platform: [ + { os: "ubuntu-latest", python-architecture: "x64" }, + ] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-${{ matrix.python-version}}-pip-sdist-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.python-version}}-pip-sdist- + ${{ runner.os }}-${{ matrix.python-version}}-pip- + ${{ runner.os }}-${{ matrix.python-version}}- + - name: Install Deps + run: python -m pip install -U setuptools wheel virtualenv + - name: Install openblas + run: | + set -e + sudo apt-get update + sudo apt-get install -y libopenblas-dev + shell: bash + - name: Build Sdist + run: python setup.py sdist + - name: Install from sdist and test + run: | + set -e + mkdir out; cd out; virtualenv aer-test + aer-test/bin/pip install ../dist/*tar.gz + aer-test/bin/pip install -c ../constraints.txt git+https://github.com/Qiskit/qiskit-terra + aer-test/bin/python ../tools/verify_wheels.py + aer-test/bin/pip check + shell: bash + tests: + runs-on: ${{ matrix.os }} + needs: [sdist, lint] + timeout-minutes: 25 + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + os: ["ubuntu-latest"] + env: + AER_THRUST_BACKEND: OMP + QISKIT_TEST_CAPTURE_STREAMS: 1 + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-${{ matrix.python-version}}-pip-test-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.python-version}}-pip-test- + ${{ runner.os }}-${{ matrix.python-version}}-pip- + ${{ runner.os }}-${{ matrix.python-version}}- + - name: Install Deps + run: python -m pip install -U -r requirements-dev.txt wheel git+https://github.com/Qiskit/qiskit-terra + - name: Install openblas + run: | + set -e + sudo apt-get update + sudo apt-get install -y libopenblas-dev + shell: bash + - name: Install Aer + run: python -m pip install -U . + - name: Run Tests + env: + QISKIT_SUPPRESS_PACKAGING_WARNINGS: Y + run: | + set -e + pip check + stestr run --slowest + shell: bash diff --git a/.github/workflows/tests_mac.yml b/.github/workflows/tests_mac.yml new file mode 100644 index 0000000000..44045d0b74 --- /dev/null +++ b/.github/workflows/tests_mac.yml @@ -0,0 +1,125 @@ +name: Tests MacOS +on: + push: + branches: [master, 'stable/*'] + pull_request: + branches: [master, 'stable/*'] +jobs: + lint: + runs-on: macOS-latest + strategy: + matrix: + python-version: [3.8] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-${{ matrix.python-version}}-pip-lint-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.python-version}}-pip-lint- + ${{ runner.os }}-${{ matrix.python-version}}-pip- + ${{ runner.os }}-${{ matrix.python-version}}- + - name: Install deps + run: | + set -e + pip install -U pip wheel + pip install -U -c constraints.txt git+https://github.com/Qiskit/qiskit-terra + pip install -U -c constraints.txt -r requirements-dev.txt + shell: bash + - name: Run Lint + run: | + set -e + pycodestyle --ignore=E402,W504 --max-line-length=100 qiskit/providers/aer + pylint -j 2 -rn qiskit/providers/aer + sdist: + runs-on: ${{ matrix.platform.os }} + needs: ["lint"] + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + platform: [ + { os: "macOS-latest", python-architecture: "x64"}, + ] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-${{ matrix.python-version}}-pip-sdist-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.python-version}}-pip-sdist- + ${{ runner.os }}-${{ matrix.python-version}}-pip- + ${{ runner.os }}-${{ matrix.python-version}}- + - name: Install Deps + run: python -m pip install -U setuptools wheel virtualenv + - name: Build Sdist + run: python setup.py sdist + - name: Install from sdist and test + run: | + set -e + mkdir out; cd out; virtualenv aer-test + aer-test/bin/pip install ../dist/*tar.gz + aer-test/bin/pip install -c ../constraints.txt git+https://github.com/Qiskit/qiskit-terra + aer-test/bin/python ../tools/verify_wheels.py + aer-test/bin/pip check + shell: bash + tests: + runs-on: ${{ matrix.os }} + needs: [sdist, lint] + timeout-minutes: 25 + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + os: ["macOS-latest"] + env: + AER_THRUST_BACKEND: OMP + QISKIT_TEST_CAPTURE_STREAMS: 1 + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-${{ matrix.python-version}}-pip-test-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.python-version}}-pip-test- + ${{ runner.os }}-${{ matrix.python-version}}-pip- + ${{ runner.os }}-${{ matrix.python-version}}- + - name: Install Deps + run: python -m pip install -U -r requirements-dev.txt wheel git+https://github.com/Qiskit/qiskit-terra + - name: Install Aer + run: python -m pip install -U . + - name: Run Tests + env: + QISKIT_SUPPRESS_PACKAGING_WARNINGS: Y + run: | + set -e + pip check + stestr run --slowest + shell: bash + if: runner.os != 'macOS' || matrix.python-version != '3.8' + - name: Run Tests macOS 3.8 + env: + QISKIT_SUPPRESS_PACKAGING_WARNINGS: Y + QISKIT_IN_PARALLEL: TRUE + run: | + set -e + pip check + stestr run --slowest + shell: bash + if: runner.os == 'macOS' && matrix.python-version == '3.8' diff --git a/.github/workflows/tests_windows.yml b/.github/workflows/tests_windows.yml new file mode 100644 index 0000000000..4e1a8e01d4 --- /dev/null +++ b/.github/workflows/tests_windows.yml @@ -0,0 +1,83 @@ +name: Tests Windows +on: + push: + branches: [master, 'stable/*'] + pull_request: + branches: [master, 'stable/*'] +jobs: + lint: + runs-on: windows-latest + strategy: + matrix: + python-version: [3.8] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~\AppData\Local\pip\Cache + key: ${{ runner.os }}-${{ matrix.python-version}}-pip-lint-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.python-version}}-pip-lint- + ${{ runner.os }}-${{ matrix.python-version}}-pip- + ${{ runner.os }}-${{ matrix.python-version}}- + - name: Install deps + run: | + set -e + pip install -U -c constraints.txt git+https://github.com/Qiskit/qiskit-terra + pip install -U -c constraints.txt -r requirements-dev.txt + shell: bash + - name: Run Lint + run: | + set -e + pycodestyle --ignore=E402,W504 --max-line-length=100 qiskit/providers/aer + pylint -j 2 -rn qiskit/providers/aer + shell: bash + tests: + runs-on: ${{ matrix.os }} + needs: ["lint"] + timeout-minutes: 25 + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + os: ["windows-latest"] + env: + AER_THRUST_BACKEND: OMP + QISKIT_TEST_CAPTURE_STREAMS: 1 + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~\AppData\Local\pip\Cache + key: ${{ runner.os }}-${{ matrix.python-version}}-pip-test-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.python-version}}-pip-test- + ${{ runner.os }}-${{ matrix.python-version}}-pip- + ${{ runner.os }}-${{ matrix.python-version}}- + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.0.2 + - name: Install Deps + run: python -m pip install -U -r requirements-dev.txt wheel git+https://github.com/Qiskit/qiskit-terra + - name: Install Aer Windows + run: | + set -e + python setup.py bdist_wheel -- -G 'Visual Studio 16 2019' + pip install --find-links=dist qiskit-aer + shell: bash + - name: Run Tests + env: + QISKIT_SUPPRESS_PACKAGING_WARNINGS: Y + run: | + set -e + pip check + stestr run --slowest + shell: bash From 2ad5d58568807a232fa6c43777bc4b98c61297f4 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Thu, 3 Dec 2020 09:07:45 -0500 Subject: [PATCH 14/15] Bump manylinux2010 docker image for wheel jobs (#1066) The default version of the manylinux2010 docker images used by cibuildwheel are trying to use a nonexistent yum repository now that centos 6 is eol. The latest version of the docker image has been updated. This commit manually sets the docker image to the latest version to unblock CI. This PR can be reverted when cibuildwheel releases a new version that bumps their default manylinux2010 version (see joerick/cibuildwheel#472 for more details on that). --- .github/workflows/build.yml | 6 +++--- .github/workflows/deploy.yml | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c4e18a5eca..555bbb9a6d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,11 +73,11 @@ jobs: run: python -m pip install -U cibuildwheel==1.7.0 - name: Build Wheels env: - CIBW_BEFORE_ALL_LINUX: "yum install -y openblas-devel" + CIBW_BEFORE_ALL_LINUX: "yum install -y https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/epel-release-6-8.noarch.rpm && yum install -y openblas-devel" CIBW_BEFORE_BUILD: "pip install -U virtualenv pybind11" CIBW_SKIP: "cp27-* cp34-* cp35-* cp39-* pp*" - CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2010" - CIBW_MANYLINUX_I686_IMAGE: "manylinux2010" + CIBW_MANYLINUX_X86_64_IMAGE: "quay.io/pypa/manylinux2010_x86_64:2020-12-03-912b0de" + CIBW_MANYLINUX_I686_IMAGE: "quay.io/pypa/manylinux2010_i686:2020-12-03-912b0de" CIBW_TEST_COMMAND: "python3 {project}/tools/verify_wheels.py" CIBW_TEST_REQUIRES: "git+https://github.com/Qiskit/qiskit-terra.git" run: cibuildwheel --output-dir wheelhouse diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 8784790f5c..2ad5c1f7a0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -21,11 +21,11 @@ jobs: python -m pip install cibuildwheel==1.5.5 - name: Build wheels env: - CIBW_BEFORE_ALL_LINUX: "yum install -y openblas-devel" + CIBW_BEFORE_ALL_LINUX: "yum install -y https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/epel-release-6-8.noarch.rpm && yum install -y openblas-devel" CIBW_BEFORE_BUILD: "pip install -U Cython pip virtualenv pybind11" CIBW_SKIP: "cp27-* cp34-* cp35-* pp*" - CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2010" - CIBW_MANYLINUX_I686_IMAGE: "manylinux2010" + CIBW_MANYLINUX_X86_64_IMAGE: "quay.io/pypa/manylinux2010_x86_64:2020-12-03-912b0de" + CIBW_MANYLINUX_I686_IMAGE: "quay.io/pypa/manylinux2010_i686:2020-12-03-912b0de" CIBW_TEST_COMMAND: "python3 {project}/tools/verify_wheels.py" CIBW_TEST_REQUIRES: "git+https://github.com/Qiskit/qiskit-terra.git" run: | @@ -77,11 +77,11 @@ jobs: python -m pip install cibuildwheel==1.5.5 - name: Build wheels env: - CIBW_BEFORE_ALL: "yum install -y yum-utils wget && wget https://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda-repo-rhel6-10-1-local-10.1.243-418.87.00-1.0-1.x86_64.rpm && rpm -i cuda-repo-rhel6-10-1-local-10.1.243-418.87.00-1.0-1.x86_64.rpm && yum clean all && yum -y install cuda-10-1" + CIBW_BEFORE_ALL: "yum install -y yum-utils wget && wget https://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda-repo-rhel6-10-1-local-10.1.243-418.87.00-1.0-1.x86_64.rpm && rpm -i cuda-repo-rhel6-10-1-local-10.1.243-418.87.00-1.0-1.x86_64.rpm && yum clean all && yum -y install cuda-10-1 && yum install -y https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/epel-release-6-8.noarch.rpm" CIBW_BEFORE_BUILD: "pip install -U Cython pip virtualenv pybind11 && yum install -y openblas-devel" CIBW_SKIP: "cp27-* cp34-* cp35-* *-manylinux_i686 pp*" - CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2010" - CIBW_MANYLINUX_I686_IMAGE: "manylinux2010" + CIBW_MANYLINUX_X86_64_IMAGE: "quay.io/pypa/manylinux2010_x86_64:2020-12-03-912b0de" + CIBW_MANYLINUX_I686_IMAGE: "quay.io/pypa/manylinux2010_i686:2020-12-03-912b0de" CIBW_ENVIRONMENT: QISKIT_AER_PACKAGE_NAME=qiskit-aer-gpu AER_THRUST_BACKEND=CUDA CUDACXX=/usr/local/cuda/bin/nvcc CIBW_TEST_COMMAND: "python3 {project}/tools/verify_wheels.py" CIBW_TEST_REQUIRES: "git+https://github.com/Qiskit/qiskit-terra.git" From 29059e2ff63bb5f8d2d4cc219ded54547fb0cef5 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Tue, 8 Dec 2020 17:52:55 -0500 Subject: [PATCH 15/15] Restrict cvxpy testing to python 3.7 and 3.8 (#1074) * Restrict cvxpy testing to python 3.7 and 3.8 The cvxpy packaging (more specifically scs) is causing issues in CI for us because since it is incorrectly trying to install numpy from a pre-release package which does not support python 3.6. The nature of this issue is difficult to pin because it's not using pip to install numpy. Since cvxpy is only used in a single place, noise transformations, instead of trying to workaround these scs packaging issues this commit just restricts the test requirements on cvxpy to only match pytho 3.7 or 3.8. If cvxpy is not installed the noise transformation tests will now skip instead of fail. * Update tutorials skip list The tutorials repo has added some new types of tutorials for different parts of aqua. These should be skipped since they don't really exercise the aer api. This commit updates the tutorials job definition to stop running these new tutorials. * Fix delay instruction bug in pulse simulator Delay instructions are no longer present in the pulse library of a qobj, resulting in a key error in the pulse digest when looking up properties of instructions in the internal pulse-simulator representation of the pulse library. The bug was fixed by modifying the code that loops through instructions in an experiment to simply do nothing when a delay instruction is found. * fixing array comparison in config pulse simulator test * Add back noise skips that were accidently removed Co-authored-by: DanPuzzuoli --- .github/workflows/docs.yml | 2 +- .../providers/aer/pulse/controllers/digest_pulse_qobj.py | 4 +++- requirements-dev.txt | 2 +- test/terra/backends/test_config_pulse_simulator.py | 2 +- test/terra/noise/test_noise_transformation.py | 7 +++++++ 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 0b09f548c7..893ab04efa 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -80,7 +80,7 @@ jobs: run: | set -e cd qiskit-tutorials - rm -rf tutorials/chemistry tutorials/circuits tutorials/circuits_advanced tutorials/finance tutorials/optimization tutorials/noise + rm -rf tutorials/chemistry tutorials/circuits tutorials/circuits_advanced tutorials/finance tutorials/optimization tutorials/algorithms tutorials/operators tutorials/noise sphinx-build -b html . _build/html - uses: actions/upload-artifact@v2 with: diff --git a/qiskit/providers/aer/pulse/controllers/digest_pulse_qobj.py b/qiskit/providers/aer/pulse/controllers/digest_pulse_qobj.py index e504e75d66..b0a3d8a557 100644 --- a/qiskit/providers/aer/pulse/controllers/digest_pulse_qobj.py +++ b/qiskit/providers/aer/pulse/controllers/digest_pulse_qobj.py @@ -340,7 +340,9 @@ def experiment_to_structs(experiment, ham_chans, pulse_inds, pulse_to_int, dt, q structs['channels'][chan_name][1].extend([inst['t0'] * dt, inst['phase'], cond]) - + # Delay instruction + elif inst['name'] == 'delay': + pass # nothing to be done in this case # A standard pulse else: start = inst['t0'] * dt diff --git a/requirements-dev.txt b/requirements-dev.txt index 201ca40425..28811fb80a 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,7 +4,7 @@ conan>=1.22.2 scikit-build cython asv -cvxpy>=1.0.0 +cvxpy>=1.0.0;python_version>'3.6' and python_version<='3.8' pylint pycodestyle Sphinx>=1.8.3 diff --git a/test/terra/backends/test_config_pulse_simulator.py b/test/terra/backends/test_config_pulse_simulator.py index c88185b4df..171ff48c5a 100644 --- a/test/terra/backends/test_config_pulse_simulator.py +++ b/test/terra/backends/test_config_pulse_simulator.py @@ -66,7 +66,7 @@ def test_from_backend(self): for idx, entry in enumerate(sim_dict[key]): for entry_key in entry: if entry_key == 'samples': - self.assertTrue(all(entry[entry_key] == backend_dict[key][idx][entry_key])) + self.assertTrue(np.array_equal(entry[entry_key], backend_dict[key][idx][entry_key])) else: self.assertTrue(entry[entry_key] == backend_dict[key][idx][entry_key]) else: diff --git a/test/terra/noise/test_noise_transformation.py b/test/terra/noise/test_noise_transformation.py index a35eb7a40f..edda242942 100644 --- a/test/terra/noise/test_noise_transformation.py +++ b/test/terra/noise/test_noise_transformation.py @@ -13,6 +13,7 @@ NoiseTransformer class tests """ +import unittest from ..common import QiskitAerTestCase import numpy @@ -26,7 +27,13 @@ from qiskit.providers.aer.noise.errors.standard_errors import pauli_error from qiskit.providers.aer.noise.errors.quantum_error import QuantumError +try: + import cvxpy + HAS_CVXPY = True +except ImportError: + HAS_CVXPY = False +@unittest.skipUnless(HAS_CVXPY, 'cvxpy is required to run these tests') class TestNoiseTransformer(QiskitAerTestCase): def setUp(self): super().setUp()