Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,28 @@ jobs:
- name: Install ROCm
if: ${{ matrix.hip == 'ON' }}
run: |
sudo apt update
sudo apt upgrade
sudo apt install "linux-headers-$(uname -r)" "linux-modules-extra-$(uname -r)"
sudo apt install python3-setuptools python3-wheel
sudo usermod -a -G render,video $USER
wget https://repo.radeon.com/amdgpu-install/6.3.3/ubuntu/noble/amdgpu-install_6.3.60303-1_all.deb
sudo apt install ./amdgpu-install_6.3.60303-1_all.deb
# Make the directory if it doesn't exist yet.
# This location is recommended by the distribution maintainers.
sudo mkdir --parents --mode=0755 /etc/apt/keyrings
# Download the key, convert the signing-key to a full
# keyring required by apt and store in the keyring directory
wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | \
gpg --dearmor | sudo tee /etc/apt/keyrings/rocm.gpg > /dev/null
sudo tee /etc/apt/sources.list.d/amdgpu.list << EOF
deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/7.2 noble main
deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/graphics/7.2/ubuntu noble main
EOF
sudo tee /etc/apt/preferences.d/rocm-pin-600 << EOF
Package: *
Pin: release o=repo.radeon.com
Pin-Priority: 600
EOF
sudo apt update
sudo apt install amdgpu-dkms rocm
sudo apt autoremove
sudo apt install rocm rocm-hip-sdk rocm-hip-runtime-dev
echo "${{ env.rocm_path }}" >> $GITHUB_PATH

# invoke cmake, disabling LTO (it duplicates symbols with CUDA + MPI)
Expand Down
34 changes: 22 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})


# GNUInstallDirs to provide sensible default install directory names
cmake_path(SET ORG_INSTALL_PATH NORMALIZE "${CMAKE_INSTALL_PREFIX}")
cmake_path(APPEND CMAKE_INSTALL_PREFIX "quest")
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

Expand Down Expand Up @@ -74,10 +72,11 @@ endif()


# Library type
# Shared library by default
option(BUILD_SHARED_LIBS "Build shared library. Turned ON by default." ON)
message(STATUS "Shared library is turned ${BUILD_SHARED_LIBS}. Set BUILD_SHARED_LIBS to modify.")

# Shared library by default when we are the top level cmake project
if(PROJECT_IS_TOP_LEVEL)
option(BUILD_SHARED_LIBS "Build shared library. Turned ON by default." ON)
message(STATUS "Shared library is turned ${BUILD_SHARED_LIBS}. Set BUILD_SHARED_LIBS to modify.")
endif ()

# Library naming
set(LIB_NAME QuEST
Expand Down Expand Up @@ -185,6 +184,7 @@ option(
)
message(STATUS "Disabling of deprecated API warnings is turned ${DISABLE_DEPRECATION_WARNINGS}. Set DISABLE_DEPRECATION_WARNINGS to modify.")

option(INSTALL_BINARIES "Whether to include example and user binaries in the install." OFF)


# ============================
Expand Down Expand Up @@ -565,10 +565,12 @@ add_executable(min_example
)
target_link_libraries(min_example PRIVATE QuEST::QuEST)

install(TARGETS min_example
RUNTIME
DESTINATION ${CMAKE_INSTALL_BINDIR}
)
if (INSTALL_BINARIES)
install(TARGETS min_example
RUNTIME
DESTINATION ${CMAKE_INSTALL_BINDIR}
)
endif ()


# all examples optionally built
Expand All @@ -577,7 +579,7 @@ if (BUILD_EXAMPLES)
endif()


## RATH
## RPATH
set(BUILD_RPATH_USE_ORIGIN ON)
if(APPLE)
set(_RPATH_ORIGIN "@loader_path")
Expand Down Expand Up @@ -623,7 +625,11 @@ if (USER_SOURCE AND OUTPUT_EXE)

add_executable(${OUTPUT_EXE} ${USER_SOURCE})
target_link_libraries(${OUTPUT_EXE} PUBLIC QuEST)
install(TARGETS ${OUTPUT_EXE} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

if (INSTALL_BINARIES)
install(TARGETS ${OUTPUT_EXE} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

setup_quest_rpath(${OUTPUT_EXE})
endif()

Expand Down Expand Up @@ -732,3 +738,7 @@ install(
NAMESPACE QuEST::
DESTINATION "${QuEST_INSTALL_CONFIGDIR}"
)

if(PROJECT_IS_TOP_LEVEL)
include(CPack)
endif ()
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ initRandomPureState(qureg);

applyHadamard(qureg, 0);
applyControlledRotateX(qureg, 0, 1, angle);
applyFullQuantumFourierTransform(qureg);
applyFullQuantumFourierTransform(qureg, inverse);

reportQureg(qureg);

Expand Down
5 changes: 3 additions & 2 deletions docs/cmake.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ make
| `VERBOSE_LIB_NAME` | (`OFF`), `ON` | When turned on `LIB_NAME` will be modified according to the other configuration options chosen. For example compiling QuEST with multithreading, distribution, and double precision with `VERBOSE_LIB_NAME` turned on creates `libQuEST-fp2+mt+mpi.so`. |
| `FLOAT_PRECISION` | (`2`), `1`, `4` | Determines which floating-point precision QuEST will use: double, single, or quad. *Note: Quad precision is not supported when also compiling for GPU.* |
| `BUILD_EXAMPLES` | (`OFF`), `ON` | Determines whether the example programs will be built alongside QuEST. Note that `min_example` is always built. |
| `ENABLE_MULTITHREADING` | (`ON`), OFF | Determines whether QuEST will be built with support for parallelisation with OpenMP. |
| `ENABLE_DISTRIBUTION` | (`OFF`), ON | Determines whether QuEST will be built with support for parallelisation with MPI. |
| `INSTALL_BINARIES` | (`OFF`), `ON` | Determines whether compiled binaries such as the examples will be installed as well as the QuEST library. |
| `ENABLE_MULTITHREADING` | (`ON`), `OFF` | Determines whether QuEST will be built with support for parallelisation with OpenMP. |
| `ENABLE_DISTRIBUTION` | (`OFF`), `ON` | Determines whether QuEST will be built with support for parallelisation with MPI. |
| `ENABLE_CUDA` | (`OFF`), `ON` | Determines whether QuEST will be built with support for NVIDIA GPU acceleration. If turned on, `CMAKE_CUDA_ARCHITECTURES` should probably also be set. |
| `ENABLE_CUQUANTUM` | (`OFF`), `ON` | Determines whether QuEST will make use of the NVIDIA CuQuantum library. Cannot be turned on if `ENABLE_CUDA` is off. |
| `ENABLE_HIP` | (`OFF`), `ON` | Determines whether QuEST will be built with support for AMD GPU acceleration. If turned on, `CMAKE_HIP_ARCHITECTURES` should probably also be set. |
Expand Down
5 changes: 3 additions & 2 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,8 @@ applyCompMatr1(qureg, 0, m);
QuEST includes a few convenience functions for effecting [QFT](https://quest-kit.github.io/QuEST/group__op__qft.html) and [Trotter](https://quest-kit.github.io/QuEST/group__op__paulistrsum.html) circuits.

```cpp
applyQuantumFourierTransform(qureg, targets, 3);
bool inverse = false;
applyQuantumFourierTransform(qureg, targets, 3, inverse);

qreal time = .3;
int order = 4;
Expand Down Expand Up @@ -865,4 +866,4 @@ This is important because it ensures:
> [!CAUTION]
> After calling `finalizeQuESTEnv()`, MPI will close and if being accessed directly by the user, will enter an undefined state. Subsequent calls to MPI routines may return gibberish, and distributed machines will lose their ability to communicate. It is recommended to call `finalizeQuESTEnv()` immediately before exiting.

You are now a QuEST expert 🎉 though there are _many_ more functions in the [API](https://quest-kit.github.io/QuEST/group__api.html) not covered here. Go forth and simulate!
You are now a QuEST expert 🎉 though there are _many_ more functions in the [API](https://quest-kit.github.io/QuEST/group__api.html) not covered here. Go forth and simulate!
12 changes: 7 additions & 5 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ function(add_example direc in_fn)
add_executable(${target} ${in_fn})
target_link_libraries(${target} PUBLIC QuEST)

install(
TARGETS ${target}
RUNTIME
DESTINATION ${out_dir}
)
if (INSTALL_BINARIES)
install(
TARGETS ${target}
RUNTIME
DESTINATION ${out_dir}
)
endif ()

set_target_properties(${target}
PROPERTIES
Expand Down
5 changes: 3 additions & 2 deletions examples/extended/dynamics.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,12 @@ int main() {
int order = 4;
int reps = 5;
int steps = 20;
bool randomise = true;

for (int i=0; i<steps; i++) {

// evolve qureg under (approx) exp(-i dt H)
applyTrotterizedUnitaryTimeEvolution(qureg, hamil, dt, order, reps);
applyTrotterizedUnitaryTimeEvolution(qureg, hamil, dt, order, reps, randomise);

// calculate and report <O>
qreal time = dt * (i+1);
Expand Down Expand Up @@ -187,7 +188,7 @@ int main() {

// verify results by uninterrupted higher-order simulation to target time
initPlusState(qureg);
applyTrotterizedUnitaryTimeEvolution(qureg, hamil, dt*steps, order+2, reps*steps);
applyTrotterizedUnitaryTimeEvolution(qureg, hamil, dt*steps, order+2, reps*steps, randomise);
reportScalar("final <O>", calcExpecPauliStrSum(qureg, observ));

// clean up
Expand Down
5 changes: 3 additions & 2 deletions examples/extended/dynamics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,12 @@ int main() {
int order = 4;
int reps = 5;
int steps = 20;
bool randomise = true;

for (int i=0; i<steps; i++) {

// evolve qureg under (approx) exp(-i dt H)
applyTrotterizedUnitaryTimeEvolution(qureg, hamil, dt, order, reps);
applyTrotterizedUnitaryTimeEvolution(qureg, hamil, dt, order, reps, randomise);

// calculate and report <O>
qreal time = dt * (i+1);
Expand All @@ -181,7 +182,7 @@ int main() {

// verify results by uninterrupted higher-order simulation to target time
initPlusState(qureg);
applyTrotterizedUnitaryTimeEvolution(qureg, hamil, dt*steps, order+2, reps*steps);
applyTrotterizedUnitaryTimeEvolution(qureg, hamil, dt*steps, order+2, reps*steps, randomise);
reportScalar("final <O>", calcExpecPauliStrSum(qureg, observ));

// clean up
Expand Down
5 changes: 3 additions & 2 deletions quest/include/deprecated.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "quest.h"

#include "stdlib.h"
#include <stdbool.h>



Expand Down Expand Up @@ -1321,11 +1322,11 @@ static inline void _multiControlledMultiRotatePauli(Qureg qureg, int* ctrls, int

#define applyFullQFT(...) \
_WARN_FUNC_RENAMED("applyFullQFT()", "applyFullQuantumFourierTransform()") \
applyFullQuantumFourierTransform(__VA_ARGS__)
applyFullQuantumFourierTransform(__VA_ARGS__, false)

#define applyQFT(...) \
_WARN_FUNC_RENAMED("applyQFT()", "applyQuantumFourierTransform()") \
applyQuantumFourierTransform(__VA_ARGS__)
applyQuantumFourierTransform(__VA_ARGS__, false)



Expand Down
22 changes: 19 additions & 3 deletions quest/include/multiplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -746,23 +746,20 @@ extern "C" {


/// @notyetdoced
/// @notyetvalidated
/// @see
/// - leftapplyCompMatr1()
/// - applyQubitProjector()
void leftapplyQubitProjector(Qureg qureg, int qubit, int outcome);


/// @notyetdoced
/// @notyetvalidated
/// @see
/// - leftapplyCompMatr1()
/// - applyMultiQubitProjector()
void leftapplyMultiQubitProjector(Qureg qureg, int* qubits, int* outcomes, int numQubits);


/// @notyetdoced
/// @notyetvalidated
/// @see
/// - rightapplyCompMatr1()
/// - applyQubitProjector()
Expand All @@ -782,6 +779,25 @@ void rightapplyMultiQubitProjector(Qureg qureg, int* qubits, int* outcomes, int
}
#endif

#ifdef __cplusplus


/// @notyetdoced
/// @cppvectoroverload
/// @see leftapplyMultiQubitProjector()
void leftapplyMultiQubitProjector(Qureg qureg, std::vector<int> qubits, std::vector<int> outcomes);


/// @notyetdoced
/// @cppvectoroverload
/// @see rightapplyMultiQubitProjector()
void rightapplyMultiQubitProjector(Qureg qureg, std::vector<int> qubits, std::vector<int> outcomes);


#endif

/** @} */



/**
Expand Down
Loading
Loading