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) ResourceModel

Placeholder: subclasses must implement this.

QPU classes implement this method to locally compute a 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)

Runs the QPU inside a server

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

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)