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; +} 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, diff --git a/quantum/plugins/ionq/ionq_accelerator.cpp b/quantum/plugins/ionq/ionq_accelerator.cpp index bb5e9fb90..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 calibrations = restClient->get(url, "/calibrations", headers); - auto j = nlohmann::json::parse(calibrations); - m_connectivity = j["calibrations"][0]["connectivity"].get>>(); + auto characterizations = restClient->get(url, "/jobs", headers); + auto j = nlohmann::json::parse(characterizations); + // std::cout << j.dump(1) << std::endl; + // m_connectivity = j["characterizations"][0]["connectivity"].get>>(); remoteUrl = url; postPath = "/jobs"; @@ -144,8 +147,8 @@ 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) { @@ -217,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(); } } + 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": [ {