XACC
ionq_accelerator.hpp
1 /*******************************************************************************
2  * Copyright (c) 2019 UT-Battelle, LLC.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * and Eclipse Distribution License v1.0 which accompanies this
6  * distribution. The Eclipse Public License is available at
7  * http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution
8  *License is available at https://eclipse.org/org/documents/edl-v10.php
9  *
10  * Contributors:
11  * Alexander J. McCaskey - initial API and implementation
12  *******************************************************************************/
13 #ifndef QUANTUM_GATE_ACCELERATORS_IONQACCELERATOR_HPP_
14 #define QUANTUM_GATE_ACCELERATORS_IONQACCELERATOR_HPP_
15 
16 #include "RemoteAccelerator.hpp"
17 
18 #include <bitset>
19 #include <type_traits>
20 
21 namespace xacc {
22 namespace quantum {
23 
25 public:
26  void cancel() override;
27 
28  void initialize(const HeterogeneousMap &params = {}) override;
29  void updateConfiguration(const HeterogeneousMap &config) override {
30  if (config.keyExists<int>("shots")) {
31  shots = config.get<int>("shots");
32  }
33  if (config.stringExists("backend")) {
34  backend = config.getString("backend");
35  }
36  }
37 
38  const std::vector<std::string> configurationKeys() override {
39  return {"shots", "backend"};
40  }
41 
42  HeterogeneousMap getProperties() override;
43 
44  const std::string getSignature() override { return "ionq:" + backend; }
45 
46  std::vector<std::pair<int, int>> getConnectivity() override;
47 
48  const std::string name() const override { return "ionq"; }
49  const std::string description() const override { return ""; }
50 
51  const std::string processInput(
52  std::shared_ptr<AcceleratorBuffer> buffer,
53  std::vector<std::shared_ptr<CompositeInstruction>> functions) override;
54 
55  void processResponse(std::shared_ptr<AcceleratorBuffer> buffer,
56  const std::string &response) override;
57 
59 
60  IonQAccelerator(std::shared_ptr<Client> client) : RemoteAccelerator(client) {}
61 
62  virtual ~IonQAccelerator() {}
63 
64 private:
65  void searchAPIKey(std::string &key, std::string &url);
66  void findApiKeyInFile(std::string &key, std::string &url,
67  const std::string &p);
68 
69  std::string currentApiToken;
70 
71  std::string url;
72 
73  int shots = 1024;
74  std::string backend = "simulator";
75 
76  bool jobIsRunning = false;
77  std::string currentJobId = "";
78 
79  bool initialized = false;
80 };
81 
82 } // namespace quantum
83 } // namespace xacc
84 
85 #endif
Definition: Accelerator.hpp:25
Definition: heterogeneous.hpp:45
Definition: ionq_accelerator.hpp:24
const std::string description() const override
Definition: ionq_accelerator.hpp:49
Definition: RemoteAccelerator.hpp:38
const std::string name() const override
Definition: ionq_accelerator.hpp:48