qat.qpus.QPUHandler

class qat.qpus.QPUHandler(plugins=None)

Abstract class describing the mininmal QPU interface.

The minimal interface is the implementation of the submit_job method:

This method should return a Result structure corresponding to the execution of a Job.

apply_resource_consumption_limits(allocation_model: AllocationModel)

Placeholder: subclasses must implement this

estimate_resources_for_batch(batch: Batch) List[ResourceModel]

Placeholder: subclasses must implement this.

QPU classes implement this method to locally compute a list of ResourceModel which tells what resources they will need to compute a batch.

get_specs() HardwareSpecs

Returns an empty HardwareSpecs object.

serve(port, host_ip='localhost', server_type=None, ssl_cert: Optional[str] = None, ssl_key: Optional[str] = None, ssl_ca: Optional[str] = None)

Runs the QPU inside a server, optionally with the SSL protocol.

Parameters
  • port (int) – the port on which to listen

  • host_ip (str) – the url on which to publish the API. Optional. Defaults to ‘localhost’.

  • server_type (str, optional) –

    type of server. The different types of server are:

    • ”simple”: single-thread server, accepts one connection at a time (default server type)

    • ”threaded”: multi-thread server, each connection starts a new thread

    • ”pool”: multi-thread server, each connection runs in a thread, with a maximum of 10 running threads

    • ”fork”: multi-process server, each connection runs in a new process

  • ssl_cert (str, optional) – path to the server SSL certificate (mandatory for SSL) Default: None

  • ssl_key (str, optional) – path to the server SSL key (mandatory for SSL) Default: None

  • ssl_ca (str, optional) – path to the server SSL certificate authority (only serves requests with signed certificates) Default: None

submit(batch: Batch, meta_data: Optional[dict] = None) BatchResult

Executes a batch of jobs and returns the corresponding list of Results.

Parameters

batch (Batch) – a batch of jobs. If a single job is provided, the job is embedded into a Batch, executed, and the first result is returned.

Returns

a batch result

Return type

(BatchResult)

abstract submit_job(job: Job) Result

Returns a Result structure corresponding to the execution of a Job.

Note

Notice that the job can be assumed to be already compiled/optimized.

This is the end of the pipe!

Parameters

job (Job) – the job to execute

Returns

a result

Return type

(Result)