Skip to content
Closed
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
6 changes: 3 additions & 3 deletions docs/sphinx/applications/python/logical_aim_sqale.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not mean to have this. Not sure how it got there.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like you missed to save the notebook after running it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't matter either way - this is something that would be nice to add some scripts for to "sanitize" how notebooks are checked in at some point.

"metadata": {},
"outputs": [],
"source": [
"try:\n",
" import cudaq_solvers as solvers\n",
" import cudaq\n",
" import cudaq_solvers as solvers\n",
" import matplotlib.pyplot as plt\n",
"except ImportError:\n",
" print(\"Installing required packages...\")\n",
" %pip install --quiet 'cudaq-solvers' 'matplotlib'\n",
" print(\"Installed `cudaq`, `cudaq-solvers`, and `matplotlib` packages.\")\n",
" print(\"You may need to restart the kernel to import newly installed packages.\")\n",
" import cudaq_solvers as solvers\n",
" import cudaq\n",
" import cudaq_solvers as solvers\n",
" import matplotlib.pyplot as plt\n",
"\n",
"from collections.abc import Mapping, Sequence\n",
Expand Down
17 changes: 12 additions & 5 deletions runtime/cudaq/platform/quantum_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ void quantum_platform::validateQpuId(std::size_t qpuId) const {

// [remove at]: runtime refactor release
// Deprecated: Use with_execution_context instead.
void quantum_platform::set_exec_ctx(ExecutionContext *ctx) {
void quantum_platform::set_exec_ctx(ExecutionContext *ctx, std::size_t qid) {
configureExecutionContext(*ctx);
detail::setExecutionContext(ctx);
beginExecution();
}

// [remove at]: runtime refactor release
// Deprecated: Use with_execution_context instead.
void quantum_platform::reset_exec_ctx() {
void quantum_platform::reset_exec_ctx(std::size_t qid) {
auto *ctx = getExecutionContext();
if (ctx == nullptr)
return;
Expand All @@ -119,6 +119,13 @@ void quantum_platform::reset_exec_ctx() {
});
}

// This is a workaround to provide backward ABI compatibility with cudaq_solvers
// 0.5.0 It is not clear where this would be called from. Uncomment the assert
// to find out
void quantum_platform::set_current_qpu(const std::size_t device_id) {
// assert(false);
}

// Specify the execution context for this platform.
// This delegates to the targeted QPU
void quantum_platform::configureExecutionContext(ExecutionContext &ctx) const {
Expand Down Expand Up @@ -153,17 +160,17 @@ std::optional<QubitConnectivity> quantum_platform::connectivity() {
return platformQPUs.front()->getConnectivity();
}

bool quantum_platform::is_simulator(std::size_t qpu_id) const {
bool quantum_platform::is_simulator(const std::size_t qpu_id) const {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious: were these arguments declared const previously?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

validateQpuId(qpu_id);
return platformQPUs[qpu_id]->isSimulator();
}

bool quantum_platform::is_remote(std::size_t qpu_id) const {
bool quantum_platform::is_remote(const std::size_t qpu_id) {
validateQpuId(qpu_id);
return platformQPUs[qpu_id]->isRemote();
}

bool quantum_platform::is_emulated(std::size_t qpu_id) const {
bool quantum_platform::is_emulated(const std::size_t qpu_id) const {
validateQpuId(qpu_id);
return platformQPUs[qpu_id]->isEmulated();
}
Expand Down
15 changes: 10 additions & 5 deletions runtime/cudaq/platform/quantum_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class quantum_platform {
// [remove at]: runtime refactor release
[[deprecated("set_exec_ctx is deprecated - please use with_execution_context "
"instead.")]] void
set_exec_ctx(ExecutionContext *ctx);
set_exec_ctx(ExecutionContext *ctx, std::size_t qid = 0);

/// Return the current execution context
// [remove at]: runtime refactor release
Expand All @@ -91,7 +91,9 @@ class quantum_platform {
// [remove at]: runtime refactor release
[[deprecated("reset_exec_ctx is deprecated - please use "
"with_execution_context instead.")]] void
reset_exec_ctx();
reset_exec_ctx(std::size_t qid = 0);

void set_current_qpu(const std::size_t device_id);

/// @brief Execute the given function within the given execution context.
template <typename Callable, typename... Args>
Expand Down Expand Up @@ -132,7 +134,8 @@ class quantum_platform {
std::size_t num_qpus() const { return platformQPUs.size(); }

/// Return whether this platform is a simulator.
bool is_simulator(std::size_t qpu_id = 0) const;
// TODO: replace const std::size_t with std::size_t
bool is_simulator(const std::size_t qpu_id = 0) const;

/// @brief Return whether the QPU supports explicit measurements.
bool supports_explicit_measurements(std::size_t qpu_id = 0) const;
Expand All @@ -142,10 +145,12 @@ class quantum_platform {
std::string name() const { return platformName; }

/// @brief Return true if the QPU is remote.
bool is_remote(std::size_t qpu_id = 0) const;
// TODO: make is a const member function
bool is_remote(const std::size_t qpu_id = 0);

/// @brief Return true if QPU is locally emulating a remote QPU
bool is_emulated(std::size_t qpu_id = 0) const;
// TODO: replace const std::size_t with std::size_t
bool is_emulated(const std::size_t qpu_id = 0) const;

/// @brief Set the noise model for @p qpu_id on this platform.
void set_noise(const noise_model *model, std::size_t qpu_id = 0);
Expand Down
2 changes: 2 additions & 0 deletions runtime/cudaq/qis/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ state &state::initialize(const state_data &data) {
state::state(SimulationState *ptrToOwn)
: internal(makeSharedSimulationState(ptrToOwn)) {}

state::~state() = default;

SimulationState::precision state::get_precision() const {
return internal->getPrecision();
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/cudaq/qis/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class state {
/// @brief Copy assignment
state &operator=(state &&other);
/// @brief Default destructor
~state() = default;
~state();

/// @brief Convenience function for extracting from a known vector.
std::complex<double> operator[](std::size_t idx) const;
Expand Down
Loading