Accelerator¶
-
class
Accelerator: public xacc::OptionsProvider, public xacc::Identifiable¶ The Accelerator class provides a high-level abstraction for XACC’s interaction with attached post-exascale accelerators (quantum and neuromorphic processing units).
Derived Accelerators must provide a valid execute implementation that takes XACC IR and executes it on the attached hardware or simulator.
Derived Accelerators must provide a list of IRTransformation instances that transform XACC IR to be amenable to execution on the hardware.
Derived Accelerators must provide implementations of createBuffer that provide a valid AcceleratorBuffer instance modeling the hardware memory or bits being computed on. Upon creating an AcceleratorBuffer, derived Accelerator implementations must call the protected storeBuffer method to store the AcceleratorBuffer for future reference by Compilers and clients of Accelerator.
- Author
Alex McCaskey
Subclassed by xacc::AcceleratorDecorator, xacc::quantum::LocalIBMAccelerator, xacc::quantum::QCSAccelerator, xacc::RemoteAccelerator
Public Types
Public Functions
-
virtual void
initialize() = 0¶ Initialize this Accelerator. This method is called by the XACC framework after an Accelerator has been requested and created. Perform any work you need done before execution here.
-
virtual AcceleratorType
getType() = 0¶ Return the type of this Accelerator.
- Return
type The Accelerator type - Gate or AQC QPU, or NPU
-
virtual std::vector<std::shared_ptr<IRTransformation>>
getIRTransformations() = 0¶ Return any IR Transformations that must be applied to ensure the compiled IR is amenable to execution on this Accelerator.
- Return
transformations The IR transformations this Accelerator exposes
Execute the provided XACC IR Function on the provided AcceleratorBuffer.
- Parameters
buffer: The buffer of bits this Accelerator should operate on.function: The kernel to execute.
Execute a set of kernels with one remote call. Return a list of AcceleratorBuffers that provide a new view of the given one AcceleratorBuffer. The ith AcceleratorBuffer contains the results of the ith kernel execution.
- Return
tempBuffers The list of new AcceleratorBuffers
- Parameters
buffer: The AcceleratorBuffer to execute onfunctions: The list of IR Functions to execute
-
virtual std::shared_ptr<AcceleratorBuffer>
createBuffer(const std::string &varId) = 0¶ Create, store, and return an AcceleratorBuffer with the given variable id string. This method returns all available qubits for this Accelerator. The string id serves as a unique identifier for future lookups and reuse of the AcceleratorBuffer.
- Return
buffer The buffer instance created.
- Parameters
varId: The variable name of the created buffer
-
virtual std::shared_ptr<AcceleratorBuffer>
createBuffer(const std::string &varId, const int size) = 0¶ Create, store, and return an AcceleratorBuffer with the given variable id string and of the given number of bits. The string id serves as a unique identifier for future lookups and reuse of the AcceleratorBuffer.
- Return
buffer The buffer instance created.
- Parameters
varId: The variable name of the created buffersize: The number of bits in the created buffer
-
virtual std::shared_ptr<AcceleratorBuffer>
getBuffer(const std::string &varid)¶ Return the stored AcceleratorBuffer with the provided string id.
- Return
buffer The buffer with given varid.
- Parameters
varid: The variable name of the created buffer
-
virtual std::vector<std::string>
getAllocatedBufferNames()¶ Return all allocated AcceleratorBuffer variable names.
- Return
varNames The buffer variable names
-
virtual std::vector<std::pair<int, int>>
getAcceleratorConnectivity()¶ Return the graph structure for this Accelerator.
- Return
connectivityGraph The graph structure of this Accelerator
-
virtual OptionPairs
getOptions()¶ Return an empty options_description, this is for subclasses to implement.
-
virtual const double
getExecutionTime()¶ Return the last execute call’s execution time in seconds.
- Return
runtime The execution time in seconds.
Return a representation of the state of the Accelerator after execution of the given program Function instance. For quantum computation this is the wave vector.
This is meant to be overrided by subclasses.
- Return
wf A list of complex coefficients
- Parameters
program: The program to execute
-
virtual bool
handleOptions(const std::map<std::string, std::string> &arg_map)¶ Given user-input command line options, perform some operation. Returns true if runtime should exit, false otherwise.
- Return
exit True if exit, false otherwise
- Parameters
map: The mapping of options to values
-
virtual bool
isRemote()¶ Return true if this Accelerator is a remotely hosted resource.
- Return
remote True if this is a remote Accelerator
-
virtual
~Accelerator()¶ Destructor