← Atlas

Basic circuits · Distribution loading

Loading a probability distribution (uniformly controlled rotations)

Puts a list of 2ⁿ probabilities into n qubits as amplitudes √p, exactly, with one uniformly controlled RY rotation per qubit.

Exact & formalUpdated

A small worked example, computed in your browser. It is not a result from this record's papers.

Loading a binomial distribution into 3 qubits

3 qubits, loading Binomial(7, ½): x = 0…7 with probability C(7, x)/128, as the amplitudes √p.

q0q1q2Step 1 of 3 · Split in halvesSplit in halvesStep 2 of 3 · Split in quartersSplit in quartersStep 3 of 3 · Split in eighthsSplit in eighths

Step 1 of 3 · Split in halves

Probability of each outcome after this step

  • 00050%
  • 10050%
  1. One RY on qubit 2 splits the probability between the lower half, x = 0…3, and the upper half, x = 4…7. Each half of this distribution holds exactly ½, so the angle is π/2.

    Probability spreads from 1 outcome to 2. All 2 are equally likely.

  2. Within each half, the next split is between its two quarters. The two halves need different angles, so qubit 2 selects the angle: a uniformly controlled rotation, two RY and two CX.

    Probability spreads from 2 outcomes to 4. This is the step that entangles the qubits: from here on no single qubit has a state of its own, only the register as a whole does.

  3. The last split, between neighbours, needs four angles, one per quarter, selected by qubits 1 and 2: four RY and four CX. After it the eight probabilities are C(7, x)/128.

    Probability spreads from 4 outcomes to 8.

Readout Measuring gives x with probability C(7, x)/128: 1, 7, 21, 35, 35, 21, 7 and 1 in 128. The check compares all eight with the input, to within 10⁻⁹.

Open in Studio
  • Steps3
  • Wires3
  • Qubits3
  • Gate count (n=3)7 RY + 6 CX
  • Rotation layers3 (RY: 1 + 2 + 4)
  • Papers4

The target state for probabilities p0,…,p2n−1p_0, \ldots, p_{2^n-1} is

∣ψ⟩=∑x=02n−1px ∣x⟩.|\psi\rangle = \sum_{x=0}^{2^n-1} \sqrt{p_x}\,|x\rangle .

Bisection. Grover and Rudolph build such a state one qubit at a time. With mm qubits holding a coarse version of the distribution over 2m2^m regions, one more qubit splits each region ii into its left and right halves: a rotation controlled on ii takes the new qubit to cos⁡θi∣0⟩+sin⁡θi∣1⟩\cos\theta_i|0\rangle + \sin\theta_i|1\rangle, with θi=arccos⁡f(i)\theta_i = \arccos\sqrt{f(i)}, where f(i)f(i) is the probability of the left half given region ii. Repeated until m=nm = n, this gives ∣ψ⟩|\psi\rangle. Their interest is the case where f(i)f(i) comes from integrals of the density that an efficient classical algorithm can compute: they compute θi\theta_i into an ancilla register, run the rotation, and uncompute. They state no gate count.

Möttönen et al.'s circuit. When the probabilities are simply a list, the angles can be computed in advance instead. The rotation on each new qubit then needs one angle for every setting of the qubits already placed, which is a uniformly controlled rotation. Möttönen, Vartiainen, Bergholm and Salomaa build a kk-fold uniformly controlled rotation from 2k2^k rotations and 2k2^k CNOTs, with the angles in closed form. Their circuit takes an arbitrary state to ∣0…0⟩|0\ldots0\rangle: zz-rotations first equalise the phases, then yy-rotations fold the magnitudes, with angles

αj,ky=2arcsin⁡ ⁣(∑l=12k−1∣a(2j−1)2k−1+l∣2  /  ∑l=12k∣a(j−1)2k+l∣2).\alpha^{y}_{j,k} = 2\arcsin\!\left(\sqrt{\textstyle\sum_{l=1}^{2^{k-1}}|a_{(2j-1)2^{k-1}+l}|^2}\;\Big/\;\sqrt{\textstyle\sum_{l=1}^{2^{k}}|a_{(j-1)2^{k}+l}|^2}\right).

Run backwards, the same circuit loads the state. For probabilities every amplitude px\sqrt{p_x} is real and non-negative, so every phase is zero and so is every zz-angle. Only the yy-rotations are left.

Cost. For turning one arbitrary state into another the paper gives 2n+2−4n−42^{n+2} - 4n - 4 CNOTs and 2n+2−52^{n+2} - 5 rotations, and says only half the gates are needed when one end is a basis vector. The yy-rotations alone, for a list of probabilities, come to 2n−22^n - 2 CNOTs and 2n−12^n - 1 RY rotations by the paper's own per-gate count; the paper does not state that figure. Either way the count grows with 2n2^n, and that is not an artefact of this circuit: counting degrees of freedom, the same paper finds that an arbitrary complex state needs at least ⌈14(2n+1−3n−2)⌉\lceil\tfrac14(2^{n+1} - 3n - 2)\rceil CNOTs. Cheaper loading needs structure in the target, such as few nonzero entries, or a smooth function whose matrix product state has small bond dimension; both have their own Atlas entries. Grover and Rudolph's case needs the integrals of the density, and the Atlas entry for their method records what obtaining those integrals costs.

The worked example. Binomial(7,12)(7, \tfrac12) on 3 qubits, px=(7x)/128p_x = \binom{7}{x}/128. The first split is exactly one half, so the first rotation is Ry(π/2)R_y(\pi/2). The second level uses two angles and the third uses four. The check compares all eight outcome probabilities with (7x)/128\binom{7}{x}/128.

References

Exact & formal
  • Exact statevector simulation
  • Verified by construction
  • Peer-reviewed paper
Method
Leona's load_distribution block builds the circuit for Binomial(7, ½) on 3 qubits, and the exact statevector's outcome probabilities are compared with C(7, x)/128 for every x. A separate test holds the block to the target amplitudes for random probability lists on 1 to 6 qubits, and holds its gate count to 2ⁿ − 2 CNOTs and 2ⁿ − 1 RY.
Result
Pass · all eight probabilities match C(7, x)/128 to within 10⁻⁹.
Caveat
The circuit is exact but not efficient: its gate count grows with 2ⁿ. The Qiskit code on this page builds the same circuit by hand from the same angles, with the CNOTs of each rotation in a different order from Leona's block and the same count, 7 RY and 6 CX. Qiskit's own StatePreparation builds a different circuit: on this example it uses 4 CNOTs (Qiskit 2.5.2, transpiled to CX and U with no optimisation).
Transformation of quantum states using uniformly controlled rotations ↗
Kind
curated reference
Reviewed by
Leona Quantum curation pass
License
CC BY 4.0-compatible reference metadata
state preparationdistribution loadingamplitude encodinguniformly controlled rotationbinomial distribution

Atlas stars stay in the public catalog. Saving this entry to your workspace starts an unstarred private copy.