Class qdk

Inheritance Relationships

Base Type

  • public RemoteAccelerator

Class Documentation

class qdk : public virtual RemoteAccelerator

Provides an execute implementation that maps XACC IR to a suitable JSON message for execution on QB hardware.

Execution is in two phases:

  1. Circuit submission via HTTP POST to QB hardware device

  2. Using the returned ID, form a HTTP GET request and poll repeatedly until results are returned

Unnamed Group

const std::string getSignature() override

Getters.

const std::string name() const override
const std::string description() const override
const std::string get_qbjson() const

Public Functions

inline qdk(const std::string name, const bool debug_flag = false)

Default constructor that just inits the parent class.

inline virtual ~qdk()

Destructor.

bool isRemote() override

Indicate that this is indeed a remote XACC accelerator.

HeterogeneousMap getProperties() override

Retrieve the properties of the backend.

const std::vector<std::string> configurationKeys() override

Get the available configuration settings.

void updateConfiguration(const HeterogeneousMap &config) override

Change the configuration of QB hardware.

Parameters:

config – Input the new configuration settings to be applied

void initialize(const HeterogeneousMap &params = {}) override

Initialize the configuration of QB hardware.

Parameters:

params – Input the new configuration settings to be applied

void setup_hardware(bool check_hardware_lifesigns)

Initialise the QB hardware (reserve, get native gateset, etc.)

Parameters:

check_hardware_lifesigns – Check for a response from the hardware

void execute(std::shared_ptr<AcceleratorBuffer> buffer, const std::shared_ptr<CompositeInstruction> function, bool execute_circuit)

Submit the circuit with HTTP POST to QB hardware and poll for results with HTTP GET.

Parameters:
  • buffer – Output location and storage of intermediate results

  • function – Input circuit in XACC IR format

  • execute_circuit – Actually send the circuit to the hardware for execution

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

Converts the circuit to a representation that QB hardware accepts.

Sets up QB specific metadata, visits XACC IR to construct JSON strings for the circuit and required measurements, then combines both into the HTTP POST request body.

Parameters:
  • buffer – Output location and storage of intermediate results

  • functions – Input circuit in XACC IR format

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

Handle the response to the initial POST (circuit submission)

Parameters:
  • buffer – Output location and storage of intermediate results

  • response – Input the response body returned by the prior POST request

std::map<std::string, int> poll_for_results()

Poll QB hardware for circuit results.

Protected Functions

std::string Post(const std::string &url, const std::string &path, const std::string &postStr, std::map<std::string, std::string> headers = {})

HTTP POST, returning the HTTP status code.

std::string Get(const std::string &url, const std::string &path, std::map<std::string, std::string> headers = {}, std::map<std::string, std::string> extraParams = {})

HTTP GET, returning the HTTP status code.

std::string Put(const std::string &url, const std::string &path, const std::string &putStr, std::map<std::string, std::string> headers = {})

HTTP PUT, returning the HTTP status code.

bool resultsReady(std::map<std::string, int> &counts)

Polling for circuit execution results via HTTP GET.

Parameters:

counts – Output location for shot outcomes

Protected Attributes

bool debug
std::string qpu_name
std::string model

Model number.

std::string command = "circuit"

Command.

size_t shots = 0

Number of shots in a cycle.

double poll_secs = 0

Poll seconds.

size_t n_qubits = 0

Number of qubits.

std::vector<uint> init = {0, 0}

Init (vector of qubits, value is the initial state)

bool use_default_contrast_settings = true

Contrast thresholds.

double init_contrast_threshold = 0
std::map<int, double> qubit_contrast_thresholds = {}
uint circuit_id

Id number of last submitted circuit.

std::string results = "normal"

Format for results.

uint poll_retries = 0

HTTP poll retries allowed.

std::vector<int> order_of_m = {}

Order of measurements.

bool exclusive_access

Assume exclusive use of the hardware device. If this flag is set true, the hardware will be assumed to only accept circuits accompanied by an appropriate token.

std::string exclusive_access_token

The encrypted JSON web token used to authenticate with a hardware device operating in exclusive access mode.

std::map<std::string, std::string> http_header

The http header sent to the hardware.

std::string qbjson

The JSON string sent to the hardware.