Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] Fix targettests for braket backend. #2474

Merged
merged 6 commits into from
Dec 13, 2024
Merged
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
2 changes: 1 addition & 1 deletion targettests/execution/angled_gate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* the terms of the Apache License 2.0 which accompanies this distribution. *
******************************************************************************/

// RUN: if $braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: if %braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi

#include <cudaq.h>

Expand Down
2 changes: 1 addition & 1 deletion targettests/execution/bug_qubit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// RUN: nvq++ %cpp_std --target iqm --iqm-machine Adonis --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target oqc --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target quantinuum --emulate %s -o %t && %t | FileCheck %s
// RUN: if $braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: if %braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: nvq++ -std=c++17 --enable-mlir %s -o %t
// RUN: cudaq-quake %cpp_std %s | cudaq-opt --promote-qubit-allocation | FileCheck --check-prefixes=MLIR %s

Expand Down
2 changes: 1 addition & 1 deletion targettests/execution/callable_kernel_arg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// RUN: nvq++ %cpp_std --target iqm --iqm-machine Adonis --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target oqc --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target quantinuum --emulate %s -o %t && %t | FileCheck %s
// RUN: if $braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: if %braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: nvq++ -std=c++17 --enable-mlir %s -o %t
// clang-format on

Expand Down
2 changes: 1 addition & 1 deletion targettests/execution/cudaq_observe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// RUN: nvq++ --target iqm --iqm-machine Apollo --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ --target oqc --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ --target quantinuum --emulate %s -o %t && %t | FileCheck %s
// RUN: if $braket_avail; then nvq++ --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: if %braket_avail; then nvq++ --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// clang-format on

#include <cudaq.h>
Expand Down
2 changes: 1 addition & 1 deletion targettests/execution/custom_operation_adj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// RUN: nvq++ %cpp_std --target iqm --iqm-machine Apollo --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target oqc --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target quantinuum --emulate %s -o %t && %t | FileCheck %s
// RUN: if $braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: if %braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// clang-format on

#include <cudaq.h>
Expand Down
2 changes: 1 addition & 1 deletion targettests/execution/custom_operation_basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// RUN: nvq++ %cpp_std --target iqm --iqm-machine Apollo --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target oqc --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target quantinuum --emulate %s -o %t && %t | FileCheck %s
// RUN: if $braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: if %braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// clang-format on

#include <cudaq.h>
Expand Down
2 changes: 1 addition & 1 deletion targettests/execution/graph_coloring-1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// clang-format off
// RUN: nvq++ %s -o %t --target infleqtion --emulate && %t | FileCheck %s
// RUN: nvq++ %s -o %t --target quantinuum --emulate && %t | FileCheck %s
// RUN: if $braket_avail; then nvq++ %s -o %t --target braket --emulate && %t | FileCheck %s; fi
// RUN: if %braket_avail; then nvq++ %s -o %t --target braket --emulate && %t | FileCheck %s; fi
// clang-format on

#include <cudaq.h>
Expand Down
2 changes: 1 addition & 1 deletion targettests/execution/graph_coloring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// clang-format off
// RUN: nvq++ %s -o %t --target infleqtion --emulate && %t | FileCheck %s
// RUN: nvq++ %s -o %t --target quantinuum --emulate && %t | FileCheck %s
// RUN: if $braket_avail; then nvq++ %s -o %t --target braket --emulate && %t | FileCheck %s; fi
// RUN: if %braket_avail; then nvq++ %s -o %t --target braket --emulate && %t | FileCheck %s; fi
// clang-format on

#include <cudaq.h>
Expand Down
2 changes: 1 addition & 1 deletion targettests/execution/if_jit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// RUN: nvq++ %cpp_std --target iqm --iqm-machine Adonis --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target oqc --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target quantinuum --emulate %s -o %t && %t | FileCheck %s
// RUN: if $braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: if %braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: nvq++ -std=c++17 --enable-mlir %s -o %t
// clang-format on

Expand Down
2 changes: 1 addition & 1 deletion targettests/execution/int8_t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// RUN: nvq++ %cpp_std --target iqm --iqm-machine Adonis --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target oqc --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target quantinuum --emulate %s -o %t && %t | FileCheck %s
// RUN: if $braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: if %braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: nvq++ -std=c++17 --enable-mlir %s -o %t
// clang-format on

Expand Down
2 changes: 1 addition & 1 deletion targettests/execution/int8_t_free_func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// RUN: nvq++ %cpp_std --target iqm --iqm-machine Adonis --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target oqc --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target quantinuum --emulate %s -o %t && %t | FileCheck %s
// RUN: if $braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: if %braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: nvq++ -std=c++17 --enable-mlir %s -o %t
// clang-format on

Expand Down
2 changes: 1 addition & 1 deletion targettests/execution/load_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// RUN: nvq++ %cpp_std --target iqm --iqm-machine Apollo --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target oqc --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target quantinuum --emulate %s -o %t && %t | FileCheck %s
// RUN: if $braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: if %braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: nvq++ -std=c++17 --enable-mlir %s -o %t
// clang-format on

Expand Down
2 changes: 1 addition & 1 deletion targettests/execution/state_preparation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// RUN: nvq++ %cpp_std --target iqm --iqm-machine Adonis --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target iqm --iqm-machine Apollo --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target oqc --emulate %s -o %t && %t | FileCheck %s
// RUN: if $braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: if %braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi

#include <bitset>
#include <cudaq.h>
Expand Down
37 changes: 6 additions & 31 deletions targettests/execution/state_preparation_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// RUN: nvq++ %cpp_std %s -o %t && %t | FileCheck %s

// Quantum emulators
// RUN: nvq++ %cpp_std -target braket -emulate %s -o %t && %t | FileCheck %s
// RUN: if %braket_avail; then nvq++ %cpp_std -target braket -emulate %s -o %t && %t | FileCheck %s ; fi
// RUN: nvq++ %cpp_std -target quantinuum -emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std -target ionq -emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std -target oqc -emulate %s -o %t && %t | FileCheck %s
Expand All @@ -35,17 +35,10 @@ __qpu__ void test_complex_constant_array() {
cudaq::qvector v(std::vector<cudaq::complex>({M_SQRT1_2, M_SQRT1_2, 0., 0.}));
}

#ifdef CUDAQ_SIMULATION_SCALAR_FP32
__qpu__ void test_complex_constant_array_floating_point() {
cudaq::qvector v(
std::vector<std::complex<float>>({M_SQRT1_2, M_SQRT1_2, 0., 0.}));
std::vector<std::complex<cudaq::real>>({M_SQRT1_2, M_SQRT1_2, 0., 0.}));
}
#else
__qpu__ void test_complex_constant_array_floating_point() {
cudaq::qvector v(
std::vector<std::complex<double>>({M_SQRT1_2, M_SQRT1_2, 0., 0.}));
}
#endif

__qpu__ void test_complex_constant_array2() {
cudaq::qvector v1(
Expand All @@ -63,45 +56,27 @@ __qpu__ void test_complex_array_param(std::vector<cudaq::complex> inState) {
cudaq::qvector q1 = inState;
}

#ifdef CUDAQ_SIMULATION_SCALAR_FP32
__qpu__ void test_complex_array_param_floating_point(
std::vector<std::complex<float>> inState) {
cudaq::qvector q1 = inState;
}
#else
__qpu__ void test_complex_array_param_floating_point(
std::vector<std::complex<double>> inState) {
std::vector<std::complex<cudaq::real>> inState) {
cudaq::qvector q1 = inState;
}
#endif

__qpu__ void test_real_constant_array() {
cudaq::qvector v({M_SQRT1_2, M_SQRT1_2, 0., 0.});
}

#ifdef CUDAQ_SIMULATION_SCALAR_FP32
__qpu__ void test_real_constant_array_floating_point() {
cudaq::qvector v(std::vector<float>({M_SQRT1_2, M_SQRT1_2, 0., 0.}));
}
#else
__qpu__ void test_real_constant_array_floating_point() {
cudaq::qvector v(std::vector<double>({M_SQRT1_2, M_SQRT1_2, 0., 0.}));
cudaq::qvector v(std::vector<cudaq::real>({M_SQRT1_2, M_SQRT1_2, 0., 0.}));
}
#endif

__qpu__ void test_real_array_param(std::vector<cudaq::real> inState) {
cudaq::qvector q1 = inState;
}

#ifdef CUDAQ_SIMULATION_SCALAR_FP32
__qpu__ void test_real_array_param_floating_point(std::vector<float> inState) {
cudaq::qvector q1 = inState;
}
#else
__qpu__ void test_real_array_param_floating_point(std::vector<double> inState) {
__qpu__ void
test_real_array_param_floating_point(std::vector<cudaq::real> inState) {
cudaq::qvector q1 = inState;
}
#endif

void printCounts(cudaq::sample_result &result) {
std::vector<std::string> values{};
Expand Down
2 changes: 1 addition & 1 deletion targettests/execution/state_preparation_vector_sizes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// RUN: nvq++ %cpp_std --target iqm --iqm-machine Adonis --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target iqm --iqm-machine Apollo --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target oqc --emulate %s -o %t && %t | FileCheck %s
// RUN: if $braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: if %braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi

#include <cudaq.h>
#include <iostream>
Expand Down
2 changes: 1 addition & 1 deletion targettests/execution/swap_gate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// RUN: nvq++ %cpp_std --target iqm --iqm-machine Adonis --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target oqc --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target quantinuum --emulate %s -o %t && %t | FileCheck %s
// RUN: if $braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: if %braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: nvq++ -std=c++17 --enable-mlir %s -o %t && %t | FileCheck %s

#include "cudaq.h"
Expand Down
2 changes: 1 addition & 1 deletion targettests/execution/variable_size_qreg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// RUN: nvq++ %cpp_std --target iqm --iqm-machine Adonis --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target oqc --emulate %s -o %t && %t | FileCheck %s
// RUN: nvq++ %cpp_std --target quantinuum --emulate %s -o %t && %t | FileCheck %s
// RUN: if $braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: if %braket_avail; then nvq++ %cpp_std --target braket --emulate %s -o %t && %t | FileCheck %s; fi
// RUN: nvq++ -std=c++17 --enable-mlir %s -o %t
// clang-format on

Expand Down
Loading