tensorcircuit.results.qem.qem_methodsΒΆ
quantum error mitigation functionalities
- tensorcircuit.results.qem.qem_methods.add_dd(c: Any, rule: Callable[[int], Any]) Any[source]ΒΆ
Add DD sequence to A circuit
- Parameters:
c (Any) β circuit
rule (Callable[[int], Any]) β The rule to conduct the DD sequence
- Returns:
new circuit
- Return type:
Any
- tensorcircuit.results.qem.qem_methods.apply_dd(circuit: Any, executor: Callable[[Any], Any], rule: Callable[[int], Any] | List[str], rule_args: Dict[str, Any] | None = None, num_trials: int = 1, full_output: bool = False, ignore_idle_qubit: bool = True, fulldd: bool = False, iscount: bool = False) float | Tuple[float, List[Any]] | Dict[str, float] | Tuple[Dict[str, float], List[Any]][source]ΒΆ
Apply dynamic decoupling (DD) and return the mitigated results.
- Parameters:
circuit (Any) β The aim circuit.
executor (Callable[[Any], Any]) β A executor that executes a circuit and return results.
rule β The rule to construct DD sequence, can use default rule βdd_option.rules.xxβ
or custom rule β[βXβ,βXβ]β :type rule: Union[Callable[[int], Any], List[str]] :param rule_args:An optional dictionary of keyword arguments for
rule, defaults to {}. :type rule_args: Dict[str, Any], optional :param num_trials: The number of independent experiments to average over, defaults to 1 :type num_trials: int, optional :param full_output: IfFalseonly the mitigated expectation value isreturned. If
Truea dictionary containing all DD data is returned too, defaults to False- Parameters:
ig_idle_qubit (bool, optional) β ignore the DD sequences that added to unused qubits, defaults to True
fulldd (bool, optional) β dd sequence full fill the idle circuits, defaults to False
iscount (bool, optional) β whether the output is bit string, defaults to False
- Returns:
mitigated expectation value or mitigated expectation value and DD circuit information
- Return type:
Union[float, Tuple[float, Dict[str, Any]]]
- tensorcircuit.results.qem.qem_methods.apply_rc(circuit: Any, executor: Callable[[Any], Any], num_to_average: int = 1, simplify: bool = True, iscount: bool = False, **kws: Any) Tuple[float, List[Any]][source]ΒΆ
Apply Randomized Compiling or Pauli twirling on two-qubit gates.
- Parameters:
circuit (Any) β Input circuit
executor (Callable[[Any], Any]) β A executor that executes a circuit and return results.
num_to_average (int, optional) β Number of circuits for RC, defaults to 1
simplify (bool, optional) β Whether simplify the circuits by merging single qubit gates, defaults to True
iscount (bool, optional) β whether the output is bit string, defaults to False
- Returns:
Mitigated results by RC
- Return type:
float
- tensorcircuit.results.qem.qem_methods.apply_zne(circuit: Any, executor: Callable[[Any | Sequence[Any]], Any], factory: Any | None, scale_noise: Callable[[Any, float], Any] | None = None, num_to_average: int = 1, **kws: Any) Any[source]ΒΆ
Apply zero-noise extrapolation (ZNE) and return the mitigated results.
- Parameters:
circuit (Any) β The aim circuit.
executor (Callable[[Union[Any, Sequence[Any]]], Any]) β A executor that executes a single circuit or a batch of circuits and return results.
factory (Optional[Factory]) β Determines the extropolation method.
scale_noise (Callable[[Any, float], Any], optional) β The scaling function for the aim circuit, defaults to fold_gates_at_random
num_to_average (int, optional) β Number of times expectation values are computed by the executor, average each point, defaults to 1.
- Returns:
Mitigated average value by ZNE.
- Return type:
float
- tensorcircuit.results.qem.qem_methods.prune_ddcircuit(c: Any, qlist: List[int]) Any[source]ΒΆ
Discard DD sequence on idle qubits and Discard identity gate (no identity/idle gate on device now) filled in DD sequence.
- Parameters:
c (Any) β circuit
qlist (list) β qubit list to apply DD sequence
- Returns:
new circuit
- Return type:
Any