Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Quleaf authored Jul 22, 2024
2 parents 5027c2e + 79d0c06 commit c362508
Show file tree
Hide file tree
Showing 222 changed files with 8,112 additions and 1,490 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/config/gitlab_commits.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
nvidia-mgpu-repo: cuda-quantum/cuquantum-mgpu.git
nvidia-mgpu-commit: 59b8ed189989d6d2d944e41d8fbc5881b289c83c
nvidia-mgpu-commit: d46ce1f4848448b64bb1f1224b476a099831802c
8 changes: 5 additions & 3 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ jobs:
create_function_result=$(ngc-cli/ngc cloud-function function create \
--container-image nvcr.io/${{ env.NGC_QUANTUM_ORG }}/${{ env.NGC_QUANTUM_TEAM }}/cuda-quantum:nightly \
--container-environment-variable NUM_GPUS:1 \
--container-environment-variable NVQC_REST_PAYLOAD_VERSION:1 \
--container-environment-variable NVQC_REST_PAYLOAD_VERSION:1.1 \
--api-body-format CUSTOM \
--inference-port 3030 \
--health-uri / \
Expand Down Expand Up @@ -543,8 +543,10 @@ jobs:
# Test all remote-sim tests
for filename in `find targettests/Remote-Sim -name '*.cpp'`; do
# unsupport_args is a compile error test
if [[ "$filename" != *"unsupport_args"* ]]; then
# unsupport_args and compile_errors are compile error tests
# pauli_word: https://github.com/NVIDIA/cuda-quantum/issues/1957
# nested_vectors: related to vector of pauli_words (https://github.com/NVIDIA/cuda-quantum/issues/1957)
if [[ "$filename" != *"unsupport_args"* ]] && [[ "$filename" != *"compile_errors"* ]] && [[ "$filename" != *"nested_vectors"* ]] && [[ "$filename" != *"pauli_word"* ]]; then
echo "$filename"
nvqc_config=""
# Look for a --remote-mqpu-auto-launch to determine the number of QPUs
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/nvqc_regression_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ jobs:
# Test all remote-sim tests
for filename in `find targettests/Remote-Sim -name '*.cpp'`; do
# unsupport_args is a compile error test
if [[ "$filename" != *"unsupport_args"* ]] && [[ "$filename" != *"state_overlap"* ]]; then
# unsupport_args and compile_errors are compile error tests
# pauli_word: https://github.com/NVIDIA/cuda-quantum/issues/1957
# nested_vectors: related to vector of pauli_words (https://github.com/NVIDIA/cuda-quantum/issues/1957)
if [[ "$filename" != *"unsupport_args"* ]] && [[ "$filename" != *"state_overlap"* ]] && [[ "$filename" != *"compile_errors"* ]] && [[ "$filename" != *"nested_vectors"* ]] && [[ "$filename" != *"pauli_word"* ]]; then
echo "$filename"
nvqc_config=""
# Look for a --remote-mqpu-auto-launch to determine the number of QPUs
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publishing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -938,9 +938,9 @@ jobs:
shell: bash
run: |
backends_to_test=`\
for file in $(ls $CUDA_QUANTUM_PATH/targets/*.config); \
for file in $(ls $CUDA_QUANTUM_PATH/targets/*.yml); \
do
if [ -n "$(cat $file | grep "GPU_REQUIREMENTS")" ]; then \
if [ -n "$(cat $file | grep "gpu-requirements")" ]; then \
basename $file | cut -d "." -f 1; \
elif [ -n "$(basename $file | grep mqpu)" ]; then \
echo remote-mqpu; \
Expand Down
4 changes: 2 additions & 2 deletions cmake/AddCUDAQ.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ function(add_cudaq_translation_library name)
endfunction()

function(add_target_config name)
install(FILES ${name}.config DESTINATION targets)
configure_file(${name}.config ${CMAKE_BINARY_DIR}/targets/${name}.config COPYONLY)
install(FILES ${name}.yml DESTINATION targets)
configure_file(${name}.yml ${CMAKE_BINARY_DIR}/targets/${name}.yml COPYONLY)
endfunction()

function(add_target_mapping_arch providerName name)
Expand Down
2 changes: 1 addition & 1 deletion cmake/WheelBuildHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function(add_target_libs_to_wheel nvqir_backend_lib_or_config)
if ("${FILE_EXTENSION}" STREQUAL ".so")
message(STATUS "Installing NVQIR backend lib '${nvqir_backend_lib_or_config}'")
install(FILES ${nvqir_backend_lib_or_config} DESTINATION lib)
elseif("${FILE_EXTENSION}" STREQUAL ".config")
elseif("${FILE_EXTENSION}" STREQUAL ".yml")
message(STATUS "Installing NVQIR backend config '${nvqir_backend_lib_or_config}'")
install(FILES ${nvqir_backend_lib_or_config} DESTINATION targets)
else()
Expand Down
22 changes: 18 additions & 4 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
# SOURCE_LOCATION: location of the source file (relative to 'sphinx/examples/cpp' directory by default)
# Optional keyword args:
# TARGET <TARGET_NAME>: name of the target to use
# TARGET_OPTION <Option>: extra option for the target
# SOURCE_DIR <DIR>: the directory that SOURCE_LOCATION is relative to (if not the default)
# LAUNCH_COMMAND <COMMAND>: the command to launch the test (e.g., mpirun)
function(add_nvqpp_test TEST_NAME SOURCE_LOCATION)
cmake_parse_arguments(PARSED_ARGS "" "TARGET;LABELS;SOURCE_DIR;LAUNCH_COMMAND;APPLICATION_ARGS" "" ${ARGN})
cmake_parse_arguments(PARSED_ARGS "" "TARGET;LABELS;SOURCE_DIR;LAUNCH_COMMAND;APPLICATION_ARGS;TARGET_OPTION" "" ${ARGN})
set(NVQPP_COMPILE_ARGS "")
if(PARSED_ARGS_TARGET)
set(NVQPP_COMPILE_ARGS "${NVQPP_COMPILE_ARGS} --target ${PARSED_ARGS_TARGET}")
if (PARSED_ARGS_TARGET_OPTION)
set(NVQPP_COMPILE_ARGS "${NVQPP_COMPILE_ARGS} --${PARSED_ARGS_TARGET}-option ${PARSED_ARGS_TARGET_OPTION}")
endif()
endif()
if (NOT PARSED_ARGS_SOURCE_DIR)
set(PARSED_ARGS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/sphinx/examples/cpp")
Expand Down Expand Up @@ -68,9 +72,14 @@ if (CUSTATEVEC_ROOT AND CUDA_FOUND)
add_nvqpp_test(QuickStart_nvidia quick_start.cpp TARGET nvidia LABELS gpu_required SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp)

# mqpu snippets need custatevec backend and optionally MPI
add_nvqpp_test(SampleAsync using/cudaq/platform/sample_async.cpp TARGET nvidia-mqpu LABELS gpu_required SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp)
add_nvqpp_test(ObserveMQPU using/cudaq/platform/observe_mqpu.cpp TARGET nvidia-mqpu LABELS gpu_required SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp)
add_nvqpp_test(StateAsyncMQPU using/cudaq/platform/get_state_async.cpp TARGET nvidia-mqpu LABELS gpu_required SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp)
add_nvqpp_test(SampleAsync using/cudaq/platform/sample_async.cpp TARGET nvidia TARGET_OPTION mqpu LABELS gpu_required SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp)
add_nvqpp_test(ObserveMQPU using/cudaq/platform/observe_mqpu.cpp TARGET nvidia TARGET_OPTION mqpu LABELS gpu_required SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp)
add_nvqpp_test(StateAsyncMQPU using/cudaq/platform/get_state_async.cpp TARGET nvidia TARGET_OPTION mqpu LABELS gpu_required SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp)

# Legacy check for the `nvidia-mqpu` target
add_nvqpp_test(LegacySampleAsync using/cudaq/platform/sample_async.cpp TARGET nvidia-mqpu LABELS gpu_required SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp)
add_nvqpp_test(LegacyObserveMQPU using/cudaq/platform/observe_mqpu.cpp TARGET nvidia-mqpu LABELS gpu_required SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp)
add_nvqpp_test(LegacyStateAsyncMQPU using/cudaq/platform/get_state_async.cpp TARGET nvidia-mqpu LABELS gpu_required SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp)

# Add the MPI test if MPI was found and there are more than 2 GPUs
if (MPI_CXX_FOUND)
Expand All @@ -81,6 +90,11 @@ if (CUSTATEVEC_ROOT AND CUDA_FOUND)
# Only build this test if we have more than 1 GPU
if (${NGPUS} GREATER_EQUAL 2)
add_nvqpp_test(ObserveMQPU_MPI using/cudaq/platform/observe_mqpu_mpi.cpp
TARGET nvidia
TARGET_OPTION mqpu
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp
LAUNCH_COMMAND "${MPIEXEC} --allow-run-as-root -np 2")
add_nvqpp_test(LegacyObserveMQPU_MPI using/cudaq/platform/observe_mqpu_mpi.cpp
TARGET nvidia-mqpu
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp
LAUNCH_COMMAND "${MPIEXEC} --allow-run-as-root -np 2")
Expand Down
3 changes: 3 additions & 0 deletions docs/sphinx/api/languages/cpp_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ Platform
.. doxygenclass:: cudaq::quantum_platform
:members:

.. doxygenstruct:: cudaq::RemoteCapabilities
:members:

.. doxygenclass:: cudaq::SerializedCodeExecutionContext

.. doxygentypedef:: cudaq::QuantumTask
Expand Down
3 changes: 2 additions & 1 deletion docs/sphinx/api/languages/python_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ Kernel Execution
.. autofunction:: cudaq::get_state
.. autofunction:: cudaq::get_state_async
.. autofunction:: cudaq::vqe
.. autofunction:: cudaq::draw
.. autofunction:: cudaq::draw
.. autofunction:: cudaq::translate

Backend Configuration
=============================
Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx/examples/cpp/algorithms/bernstein_vazirani.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Compile and run with:
// ```
// nvq++ bernstein_vazirani.cpp -o bv.x --target nvidia-mgpu
// nvq++ bernstein_vazirani.cpp -o bv.x --target nvidia --target-option mgpu
// mpirun -np 4 ./bv.x
// ```

Expand Down
6 changes: 2 additions & 4 deletions docs/sphinx/examples/cpp/algorithms/qaoa_maxcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,8 @@ int main() {
-M_PI / 8.0, M_PI / 8.0, n_params, std::mt19937::default_seed);

// Call the optimizer
auto [opt_val, opt_params] = cudaq::vqe(
ansatz{}, Hp, optimizer, n_params, [&](std::vector<double> params) {
return std::make_tuple(params, n_qubits, n_layers);
});
auto [opt_val, opt_params] =
cudaq::vqe(ansatz{}, Hp, optimizer, n_params, n_qubits, n_layers);

// Print the optimized value and the parameters
printf("Optimal value = %.16lf\n", opt_val);
Expand Down
8 changes: 2 additions & 6 deletions docs/sphinx/examples/cpp/algorithms/vqe_h2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,14 @@ int main() {

so4_fabric ansatz;

auto argMapper = [&](std::vector<double> x) {
return std::make_tuple(x, n_qubits, n_layers);
};

// Run VQE.
cudaq::optimizers::lbfgs optimizer;
optimizer.initial_parameters = init_params;
optimizer.max_eval = 20;
optimizer.max_line_search_trials = 10;
cudaq::gradients::central_difference gradient(ansatz, argMapper);
cudaq::gradients::central_difference gradient;
auto [opt_val, opt_params] =
cudaq::vqe(ansatz, gradient, H, optimizer, n_params, argMapper);
cudaq::vqe(ansatz, gradient, H, optimizer, n_params, n_qubits, n_layers);

printf("Optimal value = %.16lf\n", opt_val);
}
Loading

0 comments on commit c362508

Please sign in to comment.