quri_parts.algo.mitigation.cdr package#
- quri_parts.algo.mitigation.cdr.cdr(obs: Operator | PauliLabel, circuit: NonParametricQuantumCircuit, noisy_estimator: Callable[[Sequence[Operator | PauliLabel], Sequence[GeneralCircuitQuantumState]], Iterable[Estimate[complex]]], exact_estimator: Callable[[Sequence[Operator | PauliLabel], Sequence[GeneralCircuitQuantumState]], Iterable[Estimate[complex]]], regression_method: Callable[[float, Iterable[float], Iterable[float]], float], num_training_circuits: int = 10, fraction_of_replacement: float = 0.1, seed: int | None = None) float #
Returns an error-mitigated expectation value of an observable by using clifford-data-regression (CDR).
- Parameters:
obs – Observable for which the expected value is calculated.
circuit – Circuit that CDR is applied to.
noisy_estimator – A noisy estimator that computes the expectation value from obs and circuit.
exact_estimator – An exact (noiseless) estimator that computes the expectation value from obs and training circuits. This is assumed a simulator that can do a fast simulation of the (almost) Clifford circuit.
regression_method – Method used for regression.
num_training_circuits – A number of training circuits to be used for CDR.
fraction_of_replacement – Fraction of the number of non-Clifford gates that are to be replaced by Clifford gates.
seed – Seed to choose which gates to replace with Clifford ones.
- quri_parts.algo.mitigation.cdr.create_cdr_estimator(noisy_estimator: Callable[[Sequence[Operator | PauliLabel], Sequence[GeneralCircuitQuantumState]], Iterable[Estimate[complex]]], exact_estimator: Callable[[Sequence[Operator | PauliLabel], Sequence[GeneralCircuitQuantumState]], Iterable[Estimate[complex]]], regression_method: Callable[[float, Iterable[float], Iterable[float]], float], num_training_circuits: int = 10, fraction_of_replacement: float = 0.1, seed: int | None = None) Callable[[Operator | PauliLabel, GeneralCircuitQuantumState], Estimate[complex]] #
Wrap the given
ConcurrentQuantumEstimator
to create aQuantumEstimator
where clifford-data-regression is automatically applied to the result.- Parameters:
noisy_estimator – A noisy estimator that computes the expectation value from obs and circuit. This is assumed a given ConcurrentQuantumEstimator which will be wrapped.
exact_estimator – An exact (noiseless) estimator that computes the expectation value from obs and training circuits. This is assumed a simulator that can do a fast simulation of the (almost) Clifford circuit.
regression_method – Method used for regression.
num_training_circuits – A number of training circuits to be used for CDR.
fraction_of_replacement – Fraction of the number of non-Clifford gates that are to be replaced by Clifford gates.
seed – Seed to choose which gates to replace with Clifford ones.
- quri_parts.algo.mitigation.cdr.create_exp_regression(order: int) Callable[[float, Iterable[float], Iterable[float]], float] #
Returns a
RegressionMethod
that gives a value which is evaluated by using the curve regression and exponential function f(x) = a + b exp(p(x)), where p(x) is a polynomial of a given order.- Parameters:
order – Order of the polynomial used for regression.
- quri_parts.algo.mitigation.cdr.create_exp_regression_with_const(order: int, constant: float) Callable[[float, Iterable[float], Iterable[float]], float] #
Returns a
RegressionMethod
that gives a value which is evaluated by using the curve regression and exponential function f(x) = constant + b exp(p(x)), where p(x) is a polynomial of a given order and constant is a known parameter (obtained as the infinite limit f(x->inf) when f(x) converges to a finite asymptotic value).- Parameters:
order – Order of the polynomial used for regression.
constant – A constant deduced from asymptotic behavior f(x->inf).
- quri_parts.algo.mitigation.cdr.create_exp_regression_with_const_log(order: int, constant: float) Callable[[float, Iterable[float], Iterable[float]], float] #
Returns a
RegressionMethod
that gives a value which is evaluated by using the log regression and exponential function f(x) = constant + b exp(p(x)), where p(x) is a polynomial of a given order and constant is a known parameter (obtained as the infinite limit f(x->inf) when f(x) converges to a finite asymptotic value).- Parameters:
order – Order of the polynomial used for regression.
constant – A constant deduced from asymptotic behavior f(x->inf).
- quri_parts.algo.mitigation.cdr.create_polynomial_regression(order: int) Callable[[float, Iterable[float], Iterable[float]], float] #
Returns a
RegressionMethod
that gives a value which is evaluated by using the polynomial regression.- Parameters:
order – Order of the polynomial used for regression.
- quri_parts.algo.mitigation.cdr.make_training_circuits(circuit: NonParametricQuantumCircuit, num_non_clifford_untouched: int, num_training_circuits: int = 10, seed: int | None = None) list[NonParametricQuantumCircuit] #
Returns a list of near Clifford circuits obtained by replacing some non- Clifford gates in the input circuit by the nearest Clifford gates. The gate to be replaced is chosen at random.
- Parameters:
circuit – Original circuit from which the near Clifford circuit is constructed.
num_non_clifford_untouched – A number of non-Clifford gates that remain untouched in the replacing.
num_training_circuits – Number of circuits to be returned.
seed – Seed to choose which gates to replace with Clifford ones.