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.
Step 1 of 3 · Split in halves
Probability of each outcome after this step
- 00050%
- 10050%
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.
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.
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
Many quantum algorithms start from classical numbers loaded into amplitudes. Holmes and Matsuura give Monte Carlo style algorithms, which compute expectation values of functions over a probability distribution, as an example that needs the distribution as a state. For a list of 2ⁿ probabilities with no further structure, the exact construction is a cascade of uniformly controlled rotations, and its gate count grows with 2ⁿ.
TakesNothingWhat joins here
Nothing goes in, and that is what this entry is: a pipeline starts here. There is no upstream to choose — what you pick is what comes after.
Nothing in the Atlas meets this end.
Returns3 qubitsWhat joins here
Returns a 3-qubit register a next stage can take. This is the end that joins.
3 entries meet this end · 14 entries line up on shape, composition unverified. Named below.
Prepares a state. Nothing goes in, and what comes out is a register another stage can take. See all 13 →
- Bernstein–Vazirani all-ones oracle · 3 qubits
- Clifford brickwork benchmark · 3 qubits
- GHZ chain benchmark · 3 qubits
- RY-CX hardware-efficient ansatz · 3 qubits
- RZ-RY-CZ hardware-efficient ansatz · 3 qubits
- Ising Trotter-step benchmark · 3 qubits
- and 8 more
The widths and types line up. What is not established is everything a width does not carry — the basis convention, the normalisation, the state each was written to start from — so this is not a claim that the two compose.
The target state for probabilities is
Bisection. Grover and Rudolph build such a state one qubit at a time. With qubits holding a coarse version of the distribution over regions, one more qubit splits each region into its left and right halves: a rotation controlled on takes the new qubit to , with , where is the probability of the left half given region . Repeated until , this gives . Their interest is the case where comes from integrals of the density that an efficient classical algorithm can compute: they compute 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 -fold uniformly controlled rotation from rotations and CNOTs, with the angles in closed form. Their circuit takes an arbitrary state to : -rotations first equalise the phases, then -rotations fold the magnitudes, with angles
Run backwards, the same circuit loads the state. For probabilities every amplitude is real and non-negative, so every phase is zero and so is every -angle. Only the -rotations are left.
Cost. For turning one arbitrary state into another the paper gives CNOTs and rotations, and says only half the gates are needed when one end is a basis vector. The -rotations alone, for a list of probabilities, come to CNOTs and RY rotations by the paper's own per-gate count; the paper does not state that figure. Either way the count grows with , 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 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 on 3 qubits, . The first split is exactly one half, so the first rotation is . The second level uses two angles and the third uses four. The check compares all eight outcome probabilities with .
TakesNothingWhat joins here
Nothing goes in, and that is what this entry is: a pipeline starts here. There is no upstream to choose — what you pick is what comes after.
Nothing in the Atlas meets this end.
Returns3 qubitsWhat joins here
Returns a 3-qubit register a next stage can take. This is the end that joins.
3 entries meet this end · 14 entries line up on shape, composition unverified. Named below.
Prepares a state. Nothing goes in, and what comes out is a register another stage can take. See all 13 →
- Bernstein–Vazirani all-ones oracle · 3 qubits
- Clifford brickwork benchmark · 3 qubits
- GHZ chain benchmark · 3 qubits
- RY-CX hardware-efficient ansatz · 3 qubits
- RZ-RY-CZ hardware-efficient ansatz · 3 qubits
- Ising Trotter-step benchmark · 3 qubits
- and 8 more
The widths and types line up. What is not established is everything a width does not carry — the basis convention, the normalisation, the state each was written to start from — so this is not a claim that the two compose.
- Qubits
- 3
- Gate count (n=3)
- 7 RY + 6 CX
- Rotation layers
- 3 (RY: 1 + 2 + 4)
- State
- Σ √(C(7,x)/128) |x⟩
- Distribution
- Binomial(7, ½)
- Construction
- Möttönen et al. 2004
RY(π/2)on q[2]UC-RY, 2 angleson q[1], q[2]UC-RY, 4 angleson q[0], q[1], q[2]
Quantum vs classical
Classical baseline
Use a classical state-vector or matrix simulation at the same width, precision, and measurement objective.
Quantum claim
The quantum record demonstrates a state or operator behavior; it does not make classical simulation or communication costs disappear.
How to compare
Compare fidelity, samples, gate depth, noise, memory, and the cost of preparing and reading the state.
Nobody has reviewed this record for gaps yet.
import numpy as np
from math import comb
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
def gray(i):
return i ^ (i >> 1)
def uniformly_controlled_ry(qc, alphas, controls, target):
# Möttönen et al. (quant-ph/0407010), Fig. 2 and Eq. (3):
# 2^k RY rotations and 2^k CNOTs for k controls.
k = len(controls)
if k == 0:
qc.ry(alphas[0], target)
return
size = 2**k
thetas = [
sum((-1) ** bin(j & gray(i)).count("1") * alphas[j] for j in range(size)) / size
for i in range(size)
]
for i in range(size):
qc.ry(thetas[i], target)
flipped = (gray(i) ^ gray((i + 1) % size)).bit_length() - 1
qc.cx(controls[flipped], target)
def load_distribution(p):
# Qubit 0 is the least significant bit of x. Level k splits each block of
# 2^k consecutive values between its lower and upper half.
p = np.asarray(p, dtype=float)
n = int(np.log2(len(p)))
qc = QuantumCircuit(n)
for k in range(n, 0, -1):
blocks = p.reshape(-1, 2**k)
upper = blocks[:, 2 ** (k - 1):].sum(axis=1)
total = blocks.sum(axis=1)
alphas = [2 * np.arcsin(np.sqrt(u / t)) if t > 0 else 0.0 for u, t in zip(upper, total)]
uniformly_controlled_ry(qc, alphas, controls=list(range(k, n)), target=k - 1)
return qc
p = np.array([comb(7, x) for x in range(8)]) / 128
qc = load_distribution(p)
probabilities = Statevector.from_instruction(qc).probabilities()
print(np.allclose(probabilities, p, atol=1e-9)) # True
print(qc.count_ops()) # 7 ry, 6 cx
FINAL_CIRCUIT = qc
Where the map uses this
This record is an instance of an object the map names, so these are the processes that consume or produce one. None of them is about this record in particular.
State you can prepare 5 of 34 processes
- Quantum linear solve hands one back
- Prepare an input state hands one back
- Amplify a success branch hands one back
- Estimate an observable takes one
- Minimise the objective over the parameters hands one back
Related entries
- W state (three-qubit)
Basic circuits
- Dicke state |D²₄⟩
Basic circuits
- Quantum amplitude estimation
Algorithms
References
- Transformation of quantum states using uniformly controlled rotations
Mikko Mottonen, Juha J. Vartiainen, Ville Bergholm, Martti M. Salomaa · 2004
Primary source: the uniformly controlled rotation, its decomposition into 2ᵏ rotations and 2ᵏ CNOTs, the closed-form angles, and the gate counts for transforming one state into another.
- Creating superpositions that correspond to efficiently integrable probability distributions
Lov Grover, Terry Rudolph · 2002
The bisection this circuit performs, one qubit per halving. It is stated for distributions whose integrals can be computed efficiently, and gives no gate count.
- Efficient Quantum Circuits for Accurate State Preparation of Smooth, Differentiable Functions
Adam Holmes, A. Y. Matsuura · 2020
An approximate alternative for smooth functions: a matrix product state of small bond dimension turned into a circuit of linear size.
- Entanglement scaling in matrix product state representation of smooth functions and their shallow quantum circuit approximations
Vladyslav Bohun, Illia Lukin, Mykola Luhanko, Georgios Korpas, Philippe J. S. De Brouwer, Mykola Maksymenko, Maciej Koch-Janusz · 2024
Proves how entanglement decays across a smooth function's matrix product state, and runs the resulting shallow circuits on IBM hardware.