When a variational quantum model produces gradients that are effectively zero, increasing the optimiser budget is rarely the best first move. This guide provides a repeatable way to diagnose barren plateaus and other trainability failures, compare likely causes, and test changes to circuit depth, ansatz structure, initialisation, data encoding, gradient estimation, noise, and cost functions.
Overview
A barren plateau is a region of parameter space where the gradient of a quantum circuit’s objective becomes so small that a classical optimiser cannot make useful progress. In practice, the symptom is familiar: the loss appears flat, parameter updates are negligible, and different random seeds produce little improvement.
“Barren plateau” is useful shorthand, but it should not be the first diagnosis. Small gradients can also result from an unsuitable observable, an incorrectly scaled loss, poor parameter initialisation, an implementation bug, finite-shot estimation error, device noise, or an optimiser that is receiving gradients in an unexpected format. The practical objective is therefore not simply to prove that a barren plateau exists. It is to identify which design choice is suppressing useful signal.
For a parameter vector theta and objective L(theta), record the gradient vector g = dL/dtheta at several points rather than inspecting one training run. Useful summary values include the mean absolute gradient, the median absolute gradient, the standard deviation, the largest absolute gradient, and the fraction of values below a chosen threshold. Plotting log10(abs(g) + epsilon) is often more informative than plotting raw values because gradient magnitudes can span several orders of magnitude.
This investigation belongs alongside ordinary quantum resource analysis. Circuit depth, width, gate count, and shot requirements affect how much signal reaches the optimiser. See the quantum circuit resource estimation guide before treating an expensive or noisy experiment as a purely mathematical problem.
How to estimate trainability
Use the following diagnostic workflow whenever you change an ansatz, dataset, optimiser, backend, or training budget.
- Freeze the experiment. Fix the dataset subset, preprocessing, circuit architecture, parameter ordering, observable, number of shots, backend, and random seed policy. A moving target makes gradient comparisons unreliable.
- Check the gradient implementation. Verify that every trainable parameter is differentiable, that the returned gradient has the expected shape, and that the loss is scalar. Compare the framework’s gradient with a finite-difference estimate on a very small circuit. Finite differences are a debugging tool, not necessarily the method to use for production training.
- Sample initial points. Draw parameters from the same distribution used at the start of training. Evaluate gradients at multiple independent points and across multiple seeds. One unusually small vector does not establish a plateau.
- Separate local and global behaviour. Measure gradients for the full training objective and for a local observable or subsystem objective. If the local objective has a usable signal while the global objective does not, the cost function may be the dominant problem.
- Compare ideal and noisy evaluation. Run the same circuit with exact or high-precision simulation, finite-shot simulation, and—where appropriate—the target hardware. This separates an optimisation landscape issue from sampling variance and hardware noise.
- Change one variable. Reduce depth, alter the entangling pattern, rescale parameters, change the encoding, or replace the cost function, but do not change everything at once. Record the result in a comparison table.
There is no universal gradient threshold that proves trainability or failure. As a practical screening rule, flag a run when most sampled absolute gradients are close to machine precision, below the resolution supported by the chosen shot budget, or several orders of magnitude smaller than the gradients from a working baseline. Treat these as investigation triggers rather than scientific cut-offs. A small gradient can be acceptable near a well-converged optimum; a flat gradient at random initialisation is more concerning.
Comparison table: what to test next
| Factor | Warning sign | First comparison | Typical response |
|---|---|---|---|
| Circuit depth | Gradient scale falls as layers are added | Shallow, medium, and full-depth circuits | Start shallow and grow depth only when the task needs it |
| Ansatz structure | Strong entanglement with little local control | Hardware-efficient versus problem-informed layout | Use structured connectivity and avoid unnecessary entanglers |
| Initialisation | Many seeds begin with near-zero gradients | Small-angle, identity-near, and wider random distributions | Choose a scale that preserves signal without destabilising training |
| Data encoding | Input features create excessive depth or repeated rotations | Reduced features or an alternative encoding | Match encoding cost to the available circuit and data budget |
| Gradient estimation | Signs change between repeated evaluations | Exact, analytic, parameter-shift, and finite-shot estimates | Increase shots or use a lower-variance estimator where appropriate |
| Noise | Gradients disappear only in noisy evaluation | Ideal simulation versus a calibrated noise model | Shorten circuits, improve measurements, or test mitigation carefully |
| Cost function | Global loss is flat but local terms are informative | Global observable versus local or layerwise terms | Use decomposed objectives or staged training |
For background on choosing the input representation, use the guide to quantum data encoding methods for machine learning. Encoding is not a separate pre-processing detail: it changes circuit depth, parameter interactions, measurement cost, and the shape of the optimisation landscape.
Inputs and assumptions
A useful trainability estimate needs more than the number of qubits. Record these inputs before comparing experiments:
- Model: qubit count, trainable parameter count, ansatz family, entangling connectivity, depth, and measurement observable.
- Data: feature count, normalisation range, encoding map, batch size, and whether the same circuit is evaluated for every example.
- Objective: global expectation, local expectation, classification loss, regression loss, or a weighted sum of terms. Include the scale of each term.
- Gradient method: automatic differentiation, parameter-shift, adjoint simulation, finite differences, or another estimator. Record shots and grouping choices.
- Optimiser: algorithm, learning rate, momentum or adaptive settings, gradient clipping, stopping criteria, and whether parameters are constrained.
- Execution environment: ideal simulator, finite-shot simulator, noisy simulator, or hardware. Record transpilation settings and the backend configuration because the executed circuit may differ from the logical circuit.
- Repetition plan: number of initialisation seeds, sampled parameter points, batches, and repeated evaluations. Report distributions, not only the best run.
A simple diagnostic score is the median absolute gradient, median(|g_i|), paired with the interquartile range and the percentage of parameters below your operational threshold. Define that threshold from the experiment: for example, the smallest gradient that produces a measurable loss change above sampling noise over one optimiser step. This is more defensible than copying a threshold between simulators, devices, and objectives.
Keep ideal and noisy results separate. Error mitigation may recover some expectation-value information, but it can also increase sampling requirements or variance. It should be tested as an intervention with its own cost and uncertainty, not assumed to restore trainability automatically. The quantum error mitigation comparison provides a framework for making that trade-off explicit.
Worked examples
Example 1: depth is suppressing the signal
Suppose a classifier uses a four-qubit circuit with repeated rotation and entangling layers. The baseline experiment samples 20 seeds at depths 2, 4, and 8, using the same data batch and objective. For each seed, calculate the median absolute gradient at initialisation and after a fixed number of optimiser steps.
If depth 2 shows a broad, non-zero gradient distribution, depth 4 shows a smaller but usable distribution, and depth 8 places nearly all values below the operational threshold, depth is a credible contributor. The next test is not a different optimiser. Start with depth 2, train until progress slows, then add a layer and continue from the learned parameters. Compare this progressive strategy with training the full depth from random initialisation.
Example 2: the cost function is too global
Assume the full objective measures agreement with a many-qubit target observable. Its gradients are consistently tiny under ideal simulation, while single-qubit observables and nearest-neighbour terms produce measurable gradients. Build a second objective from local terms, or train with local terms first and introduce the global term gradually. Keep the original objective as a validation metric so that improved gradient statistics are not mistaken for improved task performance.
Minimal reproducible experiment template
# Framework-neutral pseudocode
for depth in [2, 4, 8]:
for cost_name in ["global", "local"]:
for seed in seeds:
rng = make_rng(seed)
theta = initialise(depth, rng)
value, grad = evaluate_loss_and_gradient(theta, depth, cost_name,
backend="ideal", shots=None)
stats.append({
"depth": depth,
"cost": cost_name,
"seed": seed,
"median_abs_grad": median(abs(grad)),
"mean_abs_grad": mean(abs(grad)),
"max_abs_grad": max(abs(grad)),
"small_fraction": mean(abs(grad) < threshold)
})
plot_log_gradient_distributions(stats)
report_grouped_medians(stats, by=["depth", "cost"])Repeat the same matrix with finite shots and, if relevant, a documented noise model. Save the circuit definition, parameter arrays, raw gradient vectors, loss values, shot counts, software versions, and backend settings. The experiment reproducibility checklist is useful when several developers or platforms are involved.
When to recalculate
Re-run the trainability diagnostics whenever a change can alter the optimisation landscape or the reliability of gradient estimates. That includes adding layers, changing entangling connectivity, replacing the data encoding, altering feature scaling, switching from a simulator to hardware, changing the shot budget, enabling mitigation, or moving between gradient APIs in a quantum SDK.
Recalculate after changing the optimiser or learning-rate schedule as well. An optimiser can make a usable gradient appear ineffective, but it cannot create information that the circuit and measurement process do not provide. Compare the same initialisation seeds where possible, and retain the previous baseline rather than overwriting it.
For an ongoing project, maintain a small trainability dashboard with gradient distributions, loss curves, seed-to-seed variation, circuit resources, shot counts, and backend details. Review it at each model revision and formally revisit the diagnostic assumptions at least twice a year, or sooner when frameworks, hardware targets, or noise and mitigation settings change. When a model stops learning, return to the matrix: ideal versus noisy evaluation, shallow versus deep circuits, local versus global cost, and multiple initialisation schemes. That sequence usually identifies the next useful experiment more quickly than simply increasing the training budget.
Finally, connect trainability results to the wider workflow. Use the hybrid quantum-classical workflow guide to place the circuit in its full data and optimisation loop, and document every comparison so that a later change in backend, SDK, or budget can be evaluated rather than guessed.