qermit.mitres

class qermit.taskgraph.mitres.MitRes(backend: pytket.backends.backend.Backend, _label: str = 'MitRes')

A TaskGraph extension of mitigation of counts/shots for individual circuits.

__call__(circuits_wire: List[List[qermit.taskgraph.mittask.CircuitShots]])Tuple[List[pytket.backends.backendresult.BackendResult]]

Call self as a function.

__init__(backend: pytket.backends.backend.Backend, _label: str = 'MitRes')None

MitRes objects are defined by the backend objects all circuits are executed on.

Parameters
  • backend (Backend) – Pytket backend default constructor which tasks are generated from.

  • label (str) – Name for identification of MitRes object.

__str__()str

Return str(self).

add_n_wires(num_wires: int)

Requests to add num_wires number of edges between the input vertex and output vertex, with no type restrictions. Not permitted for MitRes, raises TypeError.

Parameters

num_wires (int) – Number of edges to add between input and output vertices.

add_wire()

Requests to add a single edge between the input vertex and output vertex. Not permitted for MitRes, raises TypeError.

check_append_wires(task: Union[qermit.taskgraph.mittask.MitTask, qermit.taskgraph.task_graph.TaskGraph])bool

Confirms that the number of in wires the passed task has is equal to the number of in wires to the output, and that the number of out wires the passed task has is 1. Also checks that the task.run attribute argument is List[BackendResult] and that its return type is Tuple[List[BackendResult]].

Parameters

task (Union[MitTask, Taskgraph]) – MitTask or TaskGraph object for checking wire numbers of.

Returns

True if task is suitable for apppending, False if not.

Return type

bool

check_prepend_wires(task: Union[qermit.taskgraph.mittask.MitTask, qermit.taskgraph.task_graph.TaskGraph])bool

Confirms that the number of out wires the passed task has is equal to the number of out wires from the input, and that the number of in wires the passed task has is 1. Also checks that the task.run attribute argument is List[CircuitShots] and that its return type is Tuple[List[CircuitShots]].

Parameters

task (Union[MitTask, Taskgraph]) – MitTask or TaskGraph object for checking wire numbers of.

Returns

True if task is suitable for prepending, False if not.

Return type

bool

from_TaskGraph(task_graph: qermit.taskgraph.task_graph.TaskGraph)

Returns a MitRes object from a TaskGraph object.

Parameters

task_graph (TaskGraph) – TaskGraph object to copy tasks from.

Returns

Copied TaskGraph as MitRes

Return type

MitRes

parallel(task: Union[qermit.taskgraph.mittask.MitTask, qermit.taskgraph.task_graph.TaskGraph])

Requests to add new MitTask/TaskGraph to TaskGraph object in parallel. Not permitted for MitRes, raises TypeError.

Parameters

task (MitTask) – New task to be added in parallel.

run(circuit_shots: List[qermit.taskgraph.mittask.CircuitShots])List[pytket.backends.backendresult.BackendResult]

Overloaded run method from TaskGraph class to add type checking. A single experiment is defined by a Tuple containing a circuit to be run on some backend and the number of shots to take of said circuit. For each combination of Circuit and shots run returns a BackendResult object containing counts/shots.

Parameters

circuit_shotss – Each tuple in circuit_wires contains a Circuit to run on internal backends and the number of shots to take of said circuit.

Returns

A BackendResult object for each combination of circuit and shots.

Return type

List[BackendResult]

mitres.backend_compile_circuit_shots_task_gen(optimisation_level: int = 1)qermit.taskgraph.mittask.MitTask

For each circuit in passed List[CircuitShots] argument, pass circuit to compile_circuit method of given backend with given optimisation level. Returns new wire wherein each circuit has been compiled.

Parameters
  • backend (Backend) – Backend object from which compile circuit method is called

  • optimisation_level – Optimisation level of backend called.

mitres.backend_handle_task_gen()qermit.taskgraph.mittask.MitTask

Passes every tuple of Circuit and Shots to the backend object MitTask is defined by, returning a handle for later retrieving results for each circuit. If different numbers of shots are passed, each circuit is run with the maximum number of shots.

Parameters

backend (Backend) – Backend circuits are run through.

Returns

Pure function that adds passes circuits to backend and gets handles.

Return type

MitTask

mitres.backend_res_task_gen()qermit.taskgraph.mittask.MitTask

For each ResultHandle passed to task, retrieves a BackendResult object from the backend the task is defined by.

Parameters

backend (Backend) – backend holding results for handles.