Barren Plateau Detection¶
quprep.metrics.barren_plateau
¶
Analytical barren plateau risk estimation (McClean et al. 2018, Cerezo et al. 2021).
Classes¶
BarrenPlateauReport(encoding, n_qubits, circuit_depth, gradient_variance, risk_level, mitigations=list())
dataclass
¶
Barren plateau risk report for a quantum encoding.
Attributes:
| Name | Type | Description |
|---|---|---|
encoding |
str
|
Encoder name (lower-case, without "Encoder" suffix). |
n_qubits |
int
|
Number of qubits determined by cost estimation. |
circuit_depth |
int
|
Estimated circuit depth. |
gradient_variance |
float
|
Analytical upper bound on the gradient variance for the given cost type. Derived from the formula for the specified cost_type — no simulation is performed. |
risk_level |
str
|
One of |
mitigations |
list[str]
|
Suggested mitigation strategies (empty when risk is "none"). |
Functions¶
detect_barren_plateau(encoder, dataset, *, cost_type='global')
¶
Analytically estimate barren plateau risk for a quantum encoding.
No circuit simulation is performed. Risk is derived from qubit count using the theoretical gradient variance bounds:
- Global cost (McClean et al. 2018):
Var[∂C/∂θ] ≤ 2^(1−n)— exponential decay with qubit count. - Local cost (Cerezo et al. 2021):
Var[∂C/∂θ] ≈ 1/n²— polynomial decay; strongly preferred for large circuits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoder
|
BaseEncoder
|
A QuPrep encoder. Does not need to be fitted. |
required |
dataset
|
Dataset
|
Used only to determine qubit count and circuit depth via cost estimation. |
required |
cost_type
|
('global', local)
|
Cost function type used during training. |
"global"
|
Returns:
| Type | Description |
|---|---|
BarrenPlateauReport
|
|
Examples:
>>> import numpy as np
>>> import quprep as qd
>>> from quprep.core.dataset import Dataset
>>> ds = Dataset(data=np.random.default_rng(0).uniform(0, 1, (50, 8)))
>>> report = qd.detect_barren_plateau(qd.IQPEncoder(), ds)
>>> print(report.risk_level)
mild
References
McClean J.R. et al. "Barren plateaus in quantum neural network training landscapes." Nature Communications 9, 4812 (2018).
Cerezo M. et al. "Cost function dependent barren plateaus in shallow parametrized quantum circuits." Nature Communications 12, 1791 (2021).