qermit.mitex¶
- class qermit.taskgraph.mitex.MitEx(backend, _label='MitEx', **kwargs)[source]¶
- A TaskGraph extension for mitigation of expectation values for individual QubitPauliStrings
contained in some ObservableTracker/QubitPauliOperator.
MitEx objects are defined by the backend object experiments are run through. However, as experiments run through some MitRes object, kwargs can be used to run through any mitres of choice.
- Parameters:
backend (
Backend
) – Pytket backend default constructor which tasks are generated from.label – Name for identification of MitEx object.
- Key mitres:
MitEx object experiments are run through
- __call__(experiment_wires, cache=False, characterisation={})[source]¶
Call self as a function.
- Return type:
- __init__(backend, _label='MitEx', **kwargs)[source]¶
MitEx objects are defined by the backend object experiments are run through. However, as experiments run through some MitRes object, kwargs can be used to run through any mitres of choice.
- Parameters:
backend (
Backend
) – Pytket backend default constructor which tasks are generated from.label – Name for identification of MitEx object.
- Key mitres:
MitEx object experiments are run through
- 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 MitEx, 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 MitEx, 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[QubitPauliOperator] and that its return type is Tuple[List[QubitPauliOperator]].
- 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[ObservableExperiment] and that its return type is Tuple[List[ObservableExperiment]].
- from_TaskGraph(task_graph)[source]¶
Returns a MitEx object from a TaskGraph object.
- Parameters:
task_graph (
TaskGraph
) – TaskGraph object to copy tasks from.- Returns:
Copied TaskGraph as MitEx
- parallel(task)[source]¶
Requests to add new MitTask/TaskGraph to TaskGraph object in parallel. Not permitted for MitEx, raises TypeError.
- run(mitex_wires, cache=False, characterisation={})[source]¶
Overloaded run method. A single observable experiment is defined by a Tuple containg an Ansatz Circuit object and an ObservableTracker object. An AnsatzCircuit is a tuple containing a Circuit without measures (the ansatz circuit), the number of shots to be taken of each Measurement Circuit later run and a SymbolsDict object holding a dictionary between Circuit Symbolics (if present) and values for substituting them with when running measurement circuits (i.e. parameters). It is useful to keep parameters as symbolics until measurement circuits are executed as some mitigation methods benefit from being able to run differently parameterised circuits. An ObservableTracker object is defined by a QubitPauliOperator defining the observable of interest (a dictionary between QubitPauliStrings and coefficients), and later stores MeasurementCircuit objects for running on devices.
- Parameters:
mitex_wires (
List
[ObservableExperiment
]) – Each Tuple pertains to a different Observable measuring experiment, and contains the minimum amount of information to run an Mitigated Experiment for calculating observables.- Return type:
- Returns:
Observable experiment results as QubitPauliOperator, where values are expectations.
- run_basic(mitex_wires)[source]¶
Additional run option for MitEx which simplifies the arguments required for basic experiments. An experiment is defined here as just the ansatz circuit, number of shots and the operator being measured. This method converts these into the arguments for using run, calls run and then returns the desired operator.
- Parameters:
mitex_wires (
List
[Tuple
[CircuitShots
,QubitPauliOperator
]]) – Each tuple pertains to a different basic observable measuring experiment.- Return type:
- Returns:
Observable experiment results as QubitPauliOperator, where values are expectations.
- qermit.taskgraph.mitex.gen_compiled_MitRes(backend, optimisation_level=1)[source]¶
Returns a MitRes object with a compilation task prepended that compiles circuit wires via backend.compile_circuit. Optimisaion level can be optionally set as defined by backend.compile_circuit.
- qermit.taskgraph.mitex.gen_compiled_shot_split_MitRes(backend, max_shots, optimisation_level=1)[source]¶
Returns a shot splitting MitRes object with a compilation task prepended that compiles circuit wires via backend.compile_circuit. Optimisation level can be optionally set as defined by backend.compile_circuit.
- Parameters:
- Return type:
- Returns:
shot splitting MitRes object with compilation task prepended.
- qermit.taskgraph.mitex.get_basic_measurement_circuit(string)[source]¶
Given a Qubit Pauli String, returns a circuit for measuring qubits in given basis via changing of basis through quantum gates.
- Parameters:
string (
QubitPauliString
) – Qubit Pauli String to be measured- Return type:
- Returns:
Measurement circuit for appending on some ansatz
- qermit.taskgraph.mitex.filter_observable_tracker_task_gen()[source]¶
Generates basic (changing measurement basis via Pauli gates) MeasurementCircuit for every QubitPauliString passed that has no Measurementcircuit in ObservableTracker object passed on wire.
- Return type:
- Returns:
Pure function that adds MeasurementCircuit objects to ObservableTracker.
- qermit.taskgraph.mitex.collate_circuit_shots_task_gen()[source]¶
Each wire contains a single experiment with its own List of Circuits to run. To improve parallelisation (i.e. reduce queueing time), these lists are collated and queued for a device at the same time.
- Return type: