qat.plugins.Junction

class qat.plugins.Junction(collective=False)

Junctions are elements of a stack that allow for iterations inside a QLM stack. They implement the standard QPU interface (submit, submit_job, etc), but can be seen as some kind of iterative plugin that delegates execution of jobs to the lower part of the stack.

Junctions can be composed via the pipe operator to be included saemlessly into QLM stacks.

Parameters

collective (bool, optional) – if set to True, the .run method will receive the full batch. If set to False, .run will receive the jobs one by one. Defaults to False.

execute(qlm_object)

Executes a new Job or Batch back using the lower part of the stack.

Parameters

qlm_object (Job or Batch) – the qlm object to transmit down the stack

Returns

a Result structure corresponding to the transmitted Job or Batch

Return type

BatchResult or Result

abstract run(initial_object, meta_data)

This function will be called upon the reception of a fresh abstract QLM object (e.g a Job or a Batch depending the Junction configuration)

Warning

This is an abstract method with no default implementation. You should build your own junction by inheriting from this class and implementing your own .run method.

Parameters
  • qlm_object (Job or Batch) – the initial abstract QLM object. The type depends on the constructor parameter collective: if set to True, a Batch will be provided. If False, a Job.

  • meta_data (dict) – the meta data of the initial batch. This is helpful to transmit arguments from the client to the Junction

Returns

this method should return a Result or BatchResult depending on the collective constructor parameter

Return type

Result, BatchResult