From 5f8a34f602e1cdd5dfa92f411360a1b58eb546ff Mon Sep 17 00:00:00 2001 From: wongey <25296194+wongey@users.noreply.github.com> Date: Thu, 9 Nov 2023 22:14:39 -0500 Subject: [PATCH 1/5] Update Honeywell url --- quantum/plugins/honeywell/honeywell.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/plugins/honeywell/honeywell.hpp b/quantum/plugins/honeywell/honeywell.hpp index d9462160e..2a13d7e6c 100644 --- a/quantum/plugins/honeywell/honeywell.hpp +++ b/quantum/plugins/honeywell/honeywell.hpp @@ -116,7 +116,7 @@ class HoneywellAccelerator : public Accelerator { int shots = 1024; std::string backend = ""; bool initialized = false; - static inline const std::string url = "https://qapi.honeywell.com/v1/"; + static inline const std::string url = "https://qapi.quantinuum.com/v1/"; // List of backend names: std::vector available_backends; std::string post(const std::string &_url, const std::string &path, From 824abed2b3839bb2fc66df7d02298778c1252a4d Mon Sep 17 00:00:00 2001 From: wongey <25296194+wongey@users.noreply.github.com> Date: Thu, 9 Nov 2023 22:22:42 -0500 Subject: [PATCH 2/5] Update IonQ backend info --- quantum/plugins/ionq/ionq_accelerator.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/quantum/plugins/ionq/ionq_accelerator.cpp b/quantum/plugins/ionq/ionq_accelerator.cpp index bb5e9fb90..20726a79f 100644 --- a/quantum/plugins/ionq/ionq_accelerator.cpp +++ b/quantum/plugins/ionq/ionq_accelerator.cpp @@ -41,9 +41,9 @@ void IonQAccelerator::initialize(const HeterogeneousMap ¶ms) { headers.insert({"Authorization", "apiKey " + apiKey}); headers.insert({"Content-Type", "application/json"}); - auto calibrations = restClient->get(url, "/calibrations", headers); - auto j = nlohmann::json::parse(calibrations); - m_connectivity = j["calibrations"][0]["connectivity"].get>>(); + auto characterizations = restClient->get(url, "/characterizations/backends/qpu.harmony", headers); + auto j = nlohmann::json::parse(characterizations); + m_connectivity = j["characterizations"][0]["connectivity"].get>>(); remoteUrl = url; postPath = "/jobs"; @@ -144,8 +144,9 @@ void IonQAccelerator::processResponse(std::shared_ptr buffer, // End the color log std::cout << "\033[0m" << "\n"; - std::map histogram = - j["data"]["histogram"].get>(); + auto results = handleExceptionRestClientGet(url, "/jobs/" + jobId + "/results", headers); + + std::map histogram = json::parse(results); int n = buffer->size(); auto getBitStrForInt = [&](std::uint64_t i) { From 739819e344bd54ea492dbc9d291e7c2841a53477 Mon Sep 17 00:00:00 2001 From: wongey <25296194+wongey@users.noreply.github.com> Date: Thu, 9 Nov 2023 22:23:43 -0500 Subject: [PATCH 3/5] Add IonQ bell example --- quantum/examples/base_api/CMakeLists.txt | 5 +++- quantum/examples/base_api/bell_ionq.cpp | 29 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 quantum/examples/base_api/bell_ionq.cpp diff --git a/quantum/examples/base_api/CMakeLists.txt b/quantum/examples/base_api/CMakeLists.txt index 49238c4f0..e20b82829 100644 --- a/quantum/examples/base_api/CMakeLists.txt +++ b/quantum/examples/base_api/CMakeLists.txt @@ -36,4 +36,7 @@ add_executable(optimal_control_goat optimal_control_goat.cpp) target_link_libraries(optimal_control_goat PRIVATE xacc) add_executable(bell_azure bell_azure.cpp) -target_link_libraries(bell_azure PRIVATE xacc) \ No newline at end of file +target_link_libraries(bell_azure PRIVATE xacc) + +add_executable(bell_ionq bell_ionq.cpp) +target_link_libraries(bell_ionq PRIVATE xacc) diff --git a/quantum/examples/base_api/bell_ionq.cpp b/quantum/examples/base_api/bell_ionq.cpp new file mode 100644 index 000000000..b7407c601 --- /dev/null +++ b/quantum/examples/base_api/bell_ionq.cpp @@ -0,0 +1,29 @@ + +#include "xacc.hpp" + +int main(int argc, char **argv) { + xacc::Initialize(argc, argv); + + // Get reference to the Accelerator + auto accelerator = xacc::getAccelerator("ionq", {{"shots", 1024}}); + + // Allocate some qubits + auto buffer = xacc::qalloc(2); + + xacc::qasm(R"( +.compiler xasm +.circuit ansatz +.qbit q +H(q[0]); +CX(q[0],q[1]); +Measure(q[0]); +Measure(q[1]); +)"); + auto ansatz = xacc::getCompiled("ansatz"); + + accelerator->execute(buffer, ansatz); + + xacc::Finalize(); + + return 0; +} From 582a4a5413767e1571434b09d7fc3fb46127b84a Mon Sep 17 00:00:00 2001 From: wongey <25296194+wongey@users.noreply.github.com> Date: Sun, 23 Jun 2024 15:58:14 -0400 Subject: [PATCH 4/5] Update IonQ plugin --- quantum/plugins/ionq/ionq_accelerator.cpp | 11 +++++++---- quantum/plugins/ionq/json/ionq_program.hpp | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/quantum/plugins/ionq/ionq_accelerator.cpp b/quantum/plugins/ionq/ionq_accelerator.cpp index 20726a79f..b2a932658 100644 --- a/quantum/plugins/ionq/ionq_accelerator.cpp +++ b/quantum/plugins/ionq/ionq_accelerator.cpp @@ -22,6 +22,8 @@ #include #include +#include + namespace xacc { namespace quantum { @@ -41,9 +43,10 @@ void IonQAccelerator::initialize(const HeterogeneousMap ¶ms) { headers.insert({"Authorization", "apiKey " + apiKey}); headers.insert({"Content-Type", "application/json"}); - auto characterizations = restClient->get(url, "/characterizations/backends/qpu.harmony", headers); + auto characterizations = restClient->get(url, "/jobs", headers); auto j = nlohmann::json::parse(characterizations); - m_connectivity = j["characterizations"][0]["connectivity"].get>>(); + // std::cout << j.dump(1) << std::endl; + // m_connectivity = j["characterizations"][0]["connectivity"].get>>(); remoteUrl = url; postPath = "/jobs"; @@ -145,8 +148,7 @@ void IonQAccelerator::processResponse(std::shared_ptr buffer, std::cout << "\033[0m" << "\n"; auto results = handleExceptionRestClientGet(url, "/jobs/" + jobId + "/results", headers); - - std::map histogram = json::parse(results); + std::map histogram = json::parse(results); int n = buffer->size(); auto getBitStrForInt = [&](std::uint64_t i) { @@ -218,3 +220,4 @@ void IonQAccelerator::findApiKeyInFile(std::string &apiKey, std::string &url, } } // namespace quantum } // namespace xacc + diff --git a/quantum/plugins/ionq/json/ionq_program.hpp b/quantum/plugins/ionq/json/ionq_program.hpp index 7cea6609a..c91014589 100644 --- a/quantum/plugins/ionq/json/ionq_program.hpp +++ b/quantum/plugins/ionq/json/ionq_program.hpp @@ -144,7 +144,7 @@ namespace nlohmann { x.set_lang(j.at("lang").get()); x.set_target(j.at("target").get()); x.set_shots(j.at("shots").get()); - x.set_body(j.at("body").get()); + x.set_body(j.at("input").get()); } inline void to_json(json & j, const xacc::ionq::IonQProgram & x) { @@ -152,6 +152,7 @@ namespace nlohmann { j["lang"] = x.get_lang(); j["target"] = x.get_target(); j["shots"] = x.get_shots(); - j["body"] = x.get_body(); + j["input"] = x.get_body(); } } + From b240b764e7e31838749de8addce011575a06d01a Mon Sep 17 00:00:00 2001 From: wongey <25296194+wongey@users.noreply.github.com> Date: Mon, 24 Jun 2024 19:52:24 -0400 Subject: [PATCH 5/5] Update IonQ Tester --- quantum/plugins/ionq/tests/IonQProgramTester.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/plugins/ionq/tests/IonQProgramTester.cpp b/quantum/plugins/ionq/tests/IonQProgramTester.cpp index ef9079e94..10f2e7f95 100644 --- a/quantum/plugins/ionq/tests/IonQProgramTester.cpp +++ b/quantum/plugins/ionq/tests/IonQProgramTester.cpp @@ -20,7 +20,7 @@ TEST(IonQProgramTester, checkFromJson) { "lang": "json", "target": "qpu", "shots": 1000, - "body": { + "input": { "qubits": 2, "circuit": [ {