Skip to content

Commit

Permalink
[quera] Fix C++ frontend behavior (#2528)
Browse files Browse the repository at this point in the history
* Fix the behavior of `quera` backend with C++ frontend by showing appropriate error message.
  (Behavior prior to this change - default simulator was invoked)
* Tell nvq++ to generate glue for `quera`
* Simplify libraries - combine 'libcudaq-quera-qpu.so' and 'libcudaq-serverhelper-quera.so' into one.

Signed-off-by: Pradnya Khalate <[email protected]>
  • Loading branch information
khalatepradnya authored Jan 22, 2025
1 parent c96be85 commit 7d70b43
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 13 deletions.
13 changes: 1 addition & 12 deletions runtime/cudaq/platform/quera/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,10 @@
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #

target_sources(cudaq-rest-qpu PRIVATE QuEraExecutor.cpp QuEraServerHelper.cpp)

add_library(cudaq-serverhelper-quera SHARED QuEraExecutor.cpp QuEraServerHelper.cpp )
target_link_libraries(cudaq-serverhelper-quera
PUBLIC
cudaq-serverhelper-braket
cudaq-common
fmt::fmt-header-only
)
install(TARGETS cudaq-serverhelper-quera DESTINATION lib)

set(LIBRARY_NAME cudaq-quera-qpu)
message(STATUS "Building QuEra REST QPU.")

add_library(${LIBRARY_NAME} SHARED QuEraRemoteRESTQPU.cpp)
add_library(${LIBRARY_NAME} SHARED QuEraExecutor.cpp QuEraRemoteRESTQPU.cpp QuEraServerHelper.cpp)

target_include_directories(${LIBRARY_NAME} PRIVATE .
PUBLIC
Expand Down
3 changes: 2 additions & 1 deletion runtime/cudaq/platform/quera/QuEraBaseQPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class QuEraBaseQPU : public BaseRemoteRESTQPU {

void launchKernel(const std::string &kernelName,
const std::vector<void *> &rawArgs) override {
throw std::runtime_error("Not supported on this target.");
throw std::runtime_error(
"Arbitrary kernel execution is not supported on this target.");
}
};
} // namespace cudaq
2 changes: 2 additions & 0 deletions runtime/cudaq/platform/quera/quera.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ description: "CUDA-Q target for QuEra."
config:
# Tell DefaultQuantumPlatform what QPU subtype to use
platform-qpu: quera
# Tell NVQ++ to generate glue code to set the target backend name
gen-target-backend: true
# Add the quera-qpu library to the link list
link-libs: ["-lcudaq-quera-qpu"]
# Library mode is only for simulators, physical backends must turn this off
Expand Down
28 changes: 28 additions & 0 deletions targettests/quera/unsupported_arbitrary_kernel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2022 - 2025 NVIDIA Corporation & Affiliates. *
* All rights reserved. *
* *
* This source code and the accompanying materials are made available under *
* the terms of the Apache License 2.0 which accompanies this distribution. *
******************************************************************************/

// RUN: nvq++ %cpp_std --target quera %s -o %t.x
// RUN: not %t.x 2>&1 | FileCheck %s
// RUN: nvq++ %cpp_std --target quera --emulate %s -o %t.x
// RUN: not %t.x 2>&1 | FileCheck %s

#include <cudaq.h>

auto bell = []() __qpu__ {
cudaq::qvector q(2);
h(q[0]);
x<cudaq::ctrl>(q[0], q[1]);
};

int main() {
auto counts = cudaq::sample(bell);
counts.dump();
return 0;
}

// CHECK: Arbitrary kernel execution is not supported on this target

0 comments on commit 7d70b43

Please sign in to comment.