Class qb_qpu
Defined in File qb_qpu.hpp
Inheritance Relationships
Base Type
public RemoteAccelerator
Class Documentation
-
class qb_qpu : 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:
Circuit submission via HTTP POST to QB hardware device
Using the returned ID, form a HTTP GET request and poll repeatedly until results are returned
Options are provided to handle any shortfall in the requested number of shots:
Over-request factor
Recursive request
Sample with replacement
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 qb_qpu(const bool debug_flag = false)
Default constructor that just inits the parent class.
-
inline virtual ~qb_qpu()
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 ¶ms = {}) override
Initialize the configuration of QB hardware.
- Parameters:
params – Input the new configuration settings to be applied
-
void setup_hardware()
Initialise the QB hardware (reserve, get native gateset, etc.)
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
functions – Input circuit in XACC IR format
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
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
Polling for circuit execution results via HTTP GET.
- Parameters:
buffer – Output location and storage of intermediate results
citargets – Input circuit that has been previously submitted, for which the results are being polled for
counts – Output location for shot outcomes
polling_interval – Input the time in seconds between polling attempts - used only during recursive execution
polling_attempts – Input the max number of attempts to poll for the shot outcomes - used only during recursive execution
Public Members
-
const int QB_SAFE_LIMIT_SHOTS = 512
Safe limit for QB hardware.
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.
Protected Attributes
-
bool debug
-
std::string command = "circuit"
Command.
-
int shots = 0
Number of shots in a cycle.
-
int request_id = 0
Request ID.
-
uint poll_id = 0
Poll ID.
-
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 cycles = 1
Number of cycles.
-
std::string results = "normal"
Format for results.
-
std::string hwbackend = "gen1_canberra"
Real or dummy backend.
-
uint poll_retries = 0
HTTP poll retries allowed.
-
std::vector<int> order_of_m = {}
Order of measurements.
-
uint over_request = 0
Over-request factor.
-
bool recursive_request = true
Enable recursive request to fulfill the shots.
-
bool resample = false
Enable sample-with-replacement when set to true.
-
double resample_above_percentage = 0
% threshold for valid shot results (as a proportion of requested shots) above which we will force the use of sample-with-replacement
-
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.
-
std::string previous_post_path = {}
To keep history of the HTTP POST path.