Skip to content

Commit

Permalink
Update IonQ plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
wongey committed Jun 23, 2024
1 parent 739819e commit 582a4a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 7 additions & 4 deletions quantum/plugins/ionq/ionq_accelerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <regex>
#include <thread>

#include <iostream>

namespace xacc {
namespace quantum {

Expand All @@ -41,9 +43,10 @@ void IonQAccelerator::initialize(const HeterogeneousMap &params) {
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::vector<std::pair<int,int>>>();
// std::cout << j.dump(1) << std::endl;
// m_connectivity = j["characterizations"][0]["connectivity"].get<std::vector<std::pair<int,int>>>();

remoteUrl = url;
postPath = "/jobs";
Expand Down Expand Up @@ -145,8 +148,7 @@ void IonQAccelerator::processResponse(std::shared_ptr<AcceleratorBuffer> buffer,
std::cout << "\033[0m" << "\n";

auto results = handleExceptionRestClientGet(url, "/jobs/" + jobId + "/results", headers);

std::map<std::string, double> histogram = json::parse(results);
std::map<std::string, double> histogram = json::parse(results);

int n = buffer->size();
auto getBitStrForInt = [&](std::uint64_t i) {
Expand Down Expand Up @@ -218,3 +220,4 @@ void IonQAccelerator::findApiKeyInFile(std::string &apiKey, std::string &url,
}
} // namespace quantum
} // namespace xacc

5 changes: 3 additions & 2 deletions quantum/plugins/ionq/json/ionq_program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,15 @@ namespace nlohmann {
x.set_lang(j.at("lang").get<std::string>());
x.set_target(j.at("target").get<std::string>());
x.set_shots(j.at("shots").get<std::int64_t>());
x.set_body(j.at("body").get<xacc::ionq::Body>());
x.set_body(j.at("input").get<xacc::ionq::Body>());
}

inline void to_json(json & j, const xacc::ionq::IonQProgram & x) {
j = json::object();
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();
}
}

0 comments on commit 582a4a5

Please sign in to comment.