BPResult#
- class pyqit.utils.diagnostic.BPResult(n_qubits: int, n_samples: int, layer_variances: dict[str, float], layer_ratios: dict[str, float], overall_variance: float, expected_variance: float, is_barren: bool, quantum_variance: float, classical_variance: float | None = None, n_executions: int | None = None, n_parameters: int | None = None, n_dead_parameters: int | None = None)[source]#
Bases:
objectResult of check_barren_plateau.
repr(result) or print(result) renders a table (rich if installed, ASCII otherwise).
- n_qubits#
Width of the circuit that sets the baseline. For a pipeline, that is its one trainable quantum stage.
- Type:
int
- n_samples#
Random weight draws the gradients were sampled at.
- Type:
int
- layer_variances#
Gradient variance per weight tensor, keyed by its name in model.weights, such as “main_circuit.weights”. Circuit tensors count live parameters only. Classical tensors are included.
- Type:
dict of {str: float}
- layer_ratios#
Each entry of layer_variances divided by expected_variance. The table marks a ratio below 1 as a plateau.
- Type:
dict of {str: float}
- overall_variance#
The same value as quantum_variance.
- Type:
float
- expected_variance#
Theoretical floor from McClean et al., scaled by bp_scale_factor. For a local cost it is about twice the gradient variance of a random circuit, so a flagged model is within a factor of two of random.
- Type:
float
- is_barren#
True when quantum_variance is below expected_variance.
- Type:
bool
- quantum_variance#
Mean of the circuit tensors’ variances. This is the number the verdict is made on. NaN when the model has no circuit weights.
- Type:
float
- classical_variance#
Mean of the classical tensors’ variances. None when the model has no classical weights.
- Type:
float, optional
- n_parameters#
Circuit parameters sampled, dead ones included.
- Type:
int, optional
- n_dead_parameters#
Circuit parameters whose gradient was zero in every sample because they cannot reach the measured wires. They are left out of the variance.
- Type:
int, optional
- n_executions#
Circuit executions the sampling cost, as counted by the device: one per sample under backprop, one plus two per parameter under parameter-shift. None when the model runs no QNode.
- Type:
int, optional