qiskit_noise_learning.analysis.PositivityMinSolve
class qiskit_noise_learning.analysis.PositivityMinSolve(coefficients: dict[str, float], epsilon: Callable[[LinearSystemData], float] | None = None, deltas: Callable[[LinearSystemData], Mapping[Hashable, float]] | None = None, weights: Callable[[LinearSystemData], IndexedMatrix] | None = None, non_negative: bool = False)
Bases: ModelSolve
Solves for the ModelData while minimizing Pauli-Lindblad rate positivity.
Requires that the Fit uses a PauliLindbladModel.
For a gate set , let denote the Pauli-Lindblad rates over gate-dependent generator sets , the design matrix and the observed data. For the user-specified algorithm parameters:
- Gate coefficients ,
- Global fit bound , and
- Local fit bounds for each path measured in the design matrix,
this class solves the convex optimization problem:
subject to:
- for each row
- (optional)
See ModelSolve for more details about the general responsibility of a model solver in this library.
The constraint bounds are specified as policies: callables that receive the solve-time LinearSystemData and return the corresponding bound.
Parameters
- coefficients – Per-gate coefficients for the objective function, as a mapping from gate name to float.
- epsilon – Policy returning the tolerance for the overall weighted L2 norm constraint. At least one of
epsilonordeltasmust be provided. - deltas – Policy returning per-row tolerances as a mapping from
Pathto float. It must cover every row of the linear system, since a row absent from the mapping would be left unconstrained. At least one ofepsilonordeltasmust be provided. - weights – Policy returning the weight matrix
Wfor the L2 constraint as anIndexedMatrixwhose row and column indices arePathobjects. Defaults to identity. A row or column of the linear system absent fromWis weighted zero, which drops its residual from the norm. Only used whenepsilonis provided. - non_negative – Whether to enforce
x >= 0.
Raises
- TypeError – If
epsilon,deltasorweightsis given as a fixed value rather than a policy. Usefrom_constants()for fixed values. - ValueError – At solve time, if the
deltasorweightspolicy produces a label that is not a row of the linear system, or ifdeltasomits one. - RuntimeError – At solve time, if the convex solver does not return a solution, for instance because the constraints are infeasible.
__init__
__init__(coefficients: dict[str, float], epsilon: Callable[[LinearSystemData], float] | None = None, deltas: Callable[[LinearSystemData], Mapping[Hashable, float]] | None = None, weights: Callable[[LinearSystemData], IndexedMatrix] | None = None, non_negative: bool = False)
Methods
Column 1 | Column 2 |
|---|---|
__init__(coefficients[, epsilon, deltas, ...]) | |
from_constants(coefficients[, epsilon, ...]) | Construct from fixed constant bounds instead of data-driven policies. |
from_data_scaled_deltas(coefficients[, ...]) | Build with a delta-only policy based on statistical uncertainty of observables. |
run(fit) | Run this stage, returning a new Fit with the output level populated. |
Attributes
Column 1 | Column 2 |
|---|---|
input_level | The data level this stage reads. |
output_level | The data level this stage writes. |
from_constants
classmethod from_constants(coefficients: dict[str, float], epsilon: float | None = None, deltas: Mapping[Path, float] | None = None, weights: IndexedMatrix | None = None, non_negative: bool = False) → Self
Construct from fixed constant bounds instead of data-driven policies.
Each supplied constant is wrapped in a policy that ignores the data and returns it. See the class docstring for the meaning of each argument; here they are fixed values rather than callables.
from_data_scaled_deltas
classmethod from_data_scaled_deltas(coefficients: dict[str, float], scale: float = 1.0, non_negative: bool = False) → Self
Build with a delta-only policy based on statistical uncertainty of observables.
Each row’s tolerance is set from that row’s own statistical uncertainty and its exponential-fit goodness-of-fit. For row , with statistical 1-sigma sigma_b and the reduced chi-squared chi2_red read from the "reduced_chi_squared" entry of row_diagnostics:
Setting delta_i proportional to sigma follows the Morozov discrepancy principle (allow about scale standard deviations of slack). Because curve_fit reports sigma_b with absolute_sigma=True, it is blind to model mismatch; the sqrt(chi2_red) factor loosens rows whose exponential fit is poor, and the max(1, .) clamp means mismatch can only loosen a row, never tighten it below its statistical uncertainty. Rows with an undefined chi2_red (nan, e.g. averaged rows), and every row when the system carries no "reduced_chi_squared" diagnostic at all, get no inflation. If the model cannot be fit within the resulting tolerances the solve reports an infeasible problem, and scale is the knob that loosens every row at once.
A row whose uncertainty is non-positive or non-finite carries no statistical information to scale by, so rather than being treated as an extremely precise row it is assigned the median tolerance of the rows that do have a usable uncertainty. This keeps such a row in the fit at a typical scale without letting it constrain the solution as a near-equality, and no row’s tolerance ever depends on another row’s uncertainty except through this substitution.
Parameters
- coefficients – Per-gate coefficients for the objective function, as a mapping from gate name to float.
- scale – Multiplier on the per-row tolerance, in units of (inflated) standard deviations.
- non_negative – Whether to enforce
x >= 0.
Raises
ValueError – At solve time, if no row of the linear system has a positive, finite uncertainty, leaving nothing to derive tolerances from.