qermit.mitres¶
- class qermit.taskgraph.mitres.MitRes(backend, _label='MitRes')[source]¶
A TaskGraph extension of mitigation of counts/shots for individual circuits.
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 – Name for identification of MitRes object.
- __call__(circuits_wire, cache=False, characterisation={})[source]¶
Call self as a function.
- Return type:
- __init__(backend, _label='MitRes')[source]¶
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 – Name for identification of MitRes object.
- add_n_wires(num_wires)[source]¶
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()[source]¶
Requests to add a single edge between the input vertex and output vertex. Not permitted for MitRes, raises TypeError.
- check_append_wires(task)[source]¶
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]].
- check_prepend_wires(task)[source]¶
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]].
- from_TaskGraph(task_graph)[source]¶
Returns a MitRes object from a TaskGraph object.
- Parameters:
task_graph (
TaskGraph
) – TaskGraph object to copy tasks from.- Returns:
Copied TaskGraph as MitRes
- parallel(task)[source]¶
Requests to add new MitTask/TaskGraph to TaskGraph object in parallel. Not permitted for MitRes, raises TypeError.
- run(circuit_shots, cache=False, characterisation={})[source]¶
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.
- Return type:
- Returns:
A BackendResult object for each combination of circuit and shots.
- qermit.taskgraph.mitres.backend_compile_circuit_shots_task_gen(backend, optimisation_level=1)[source]¶
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.
- qermit.taskgraph.mitres.backend_handle_task_gen(backend)[source]¶
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.
- qermit.taskgraph.mitres.backend_res_task_gen(backend)[source]¶
For each ResultHandle passed to task, retrieves a BackendResult object from the backend the task is defined by.
- qermit.taskgraph.mitres.gen_shot_split_MitRes(backend, max_shots)[source]¶
Wraps a mitres in tasks which ensures shots requested by individual jobs never exceed max_shots. It does so by splitting the shots over several jobs if necessary.
- qermit.taskgraph.mitres.split_shots_task_gen(max_shots)[source]¶
When the number of shots requested is higher than max_shots, this task splits the jobs into several individual jobs, where the total number of shots matches that initially requested.