ionq_accelerator.hpp 2.77 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*******************************************************************************
 * Copyright (c) 2019 UT-Battelle, LLC.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Eclipse Distribution License v1.0 which accompanies this
 * distribution. The Eclipse Public License is available at
 * http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution
 *License is available at https://eclipse.org/org/documents/edl-v10.php
 *
 * Contributors:
 *   Alexander J. McCaskey - initial API and implementation
 *******************************************************************************/
#ifndef QUANTUM_GATE_ACCELERATORS_IONQACCELERATOR_HPP_
#define QUANTUM_GATE_ACCELERATORS_IONQACCELERATOR_HPP_

#include "RemoteAccelerator.hpp"

#include <bitset>
#include <type_traits>

namespace xacc {
namespace quantum {

class IonQAccelerator : public RemoteAccelerator {
public:
  void cancel() override;
27
28
29
  void execute(std::shared_ptr<AcceleratorBuffer> buffer,
               const std::vector<std::shared_ptr<CompositeInstruction>>
                   circuits) override;
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
  void initialize(const HeterogeneousMap &params = {}) override;
  void updateConfiguration(const HeterogeneousMap &config) override {
    if (config.keyExists<int>("shots")) {
      shots = config.get<int>("shots");
    }
    if (config.stringExists("backend")) {
      backend = config.getString("backend");
    }
  }

  const std::vector<std::string> configurationKeys() override {
    return {"shots", "backend"};
  }

  HeterogeneousMap getProperties() override;

  const std::string getSignature() override { return "ionq:" + backend; }

  std::vector<std::pair<int, int>> getConnectivity() override;

  const std::string name() const override { return "ionq"; }
  const std::string description() const override { return ""; }

  const std::string processInput(
      std::shared_ptr<AcceleratorBuffer> buffer,
      std::vector<std::shared_ptr<CompositeInstruction>> functions) override;

  void processResponse(std::shared_ptr<AcceleratorBuffer> buffer,
                       const std::string &response) override;

  IonQAccelerator() : RemoteAccelerator() {}

  IonQAccelerator(std::shared_ptr<Client> client) : RemoteAccelerator(client) {}

  virtual ~IonQAccelerator() {}

private:
  void searchAPIKey(std::string &key, std::string &url);
  void findApiKeyInFile(std::string &key, std::string &url,
                        const std::string &p);

  std::string currentApiToken;

  std::string url;

  int shots = 1024;
  std::string backend = "simulator";
77
  std::vector<std::pair<int,int>> m_connectivity;
78
79
80
81
82
83
84
85
86
87
88

  bool jobIsRunning = false;
  std::string currentJobId = "";

  bool initialized = false;
};

} // namespace quantum
} // namespace xacc

#endif