Markowitz handed us a beautiful machine. Feed it expected returns and a covariance matrix, turn the crank, and out comes the portfolio with the least risk for a target return. For the continuous version of that problem — “hold any fraction of each asset” — the machine is genuinely solved: it is a convex quadratic program, and we can crack it in polynomial time before lunch.
Then a portfolio manager walks in and says: “Lovely. But I want to hold exactly 8 names, never a position smaller than 2%, and only in round lots of 100 shares.” And the beautiful convex machine seizes up. Those innocent-sounding requests turn a polynomial-time problem into a combinatorial one — the kind that, in the worst case, is NP-hard.
This lesson is about that phase change, and the bet quantum computing makes on it. We will recast the discrete portfolio problem as a QUBO (Quadratic Unconstrained Binary Optimization), see how a quantum annealer (D-Wave) and QAOA (gate model) attack a QUBO, and — crucially — keep a clear head about whether any of it currently beats a good classical solver. Spoiler from the start: the math is real and elegant; the advantage is, as of today, mostly aspirational.
Why continuous portfolios are easy and discrete ones are hard
Before you read — take a guess
Continuous mean–variance optimization (hold any fraction of each asset) is a convex quadratic program. Adding 'hold exactly k names' does what to its difficulty?
Analogy. The continuous problem is rolling a marble into the bottom of a smooth bowl: wherever you start, gravity slides you to the single lowest point. The discrete problem is finding the lowest valley across a vast mountain range while only being allowed to stand on a finite set of peaks. There is no slope to follow — you must, in principle, check combinations.
Definition — continuous mean–variance. With weights , expected returns , covariance , and risk-aversion , Markowitz minimizes
Because is positive semidefinite, the objective is convex and the constraint is linear. Convex quadratic programs are solvable in polynomial time (interior-point methods). This is the “easy” world.
Where it breaks. Real mandates add constraints that are not convex:
- Cardinality: hold exactly (or at most) of the names.
- Minimum lot / position sizes: a holding is either or at least some floor (e.g. at least 2% or at least 100 shares) — a “semi-continuous” variable.
- Buy-in thresholds / round lots: weights must land on a discrete grid.
Each of these introduces a yes/no decision per asset. With assets there are up to on/off combinations, and the feasible region is no longer a single convex blob — it is a scatter of disconnected islands. Branch-and-bound can prune, but the worst case is exponential. This combinatorial core is exactly what QAOA and quantum annealing claim to attack.
Worked example — the explosion. Pick the best 5 names out of 30 by brute force: portfolios — trivial. Now best 15 out of 100: . At a billion evaluations per second that is roughly 8 years of compute for one rebalance. The continuous version of the same 100-asset problem solves in milliseconds. The discreteness, not the size, is the enemy.
The convexity cliff
It is tempting to “just round” the continuous solution to satisfy a cardinality limit — solve the smooth problem, then keep the 8 biggest weights. This is fast but provably suboptimal: the best 8-name portfolio is frequently not the 8 largest weights of the 30-name solution, because dropping names reshuffles the optimal mix among those that remain. Rounding gives you an answer, not the answer.
When to use it
Stay in the continuous convex world whenever you legitimately can — if the only “discrete” constraint is soft (a preference, not a hard rule), encode it as a penalty in a convex solver and move on. Reach for combinatorial machinery (and only then consider quantum) when the discreteness is a hard, binding business constraint: a fixed name count, a regulatory lot size, a minimum ticket that can’t be fractioned.
State the phase change in one line.
Pick the right option for each blank, then check.
Mean–variance optimization is a convex in the continuous case, but a cardinality or minimum-lot constraint makes it combinatorial and NP-hard.
QUBO: minimize x-transpose Q x over binary x
Before you read — take a guess
A QUBO minimizes x^T Q x over x in {0,1}^n. Since x_i is binary, x_i squared equals x_i. What does that let you fold into the diagonal of Q?
Analogy. A QUBO is a set of light switches (one per asset, each on or off) wired together so that every pair of switches has a reward or penalty for being on together, and each switch has its own solo reward for being on. You are hunting for the switch configuration with the lowest total “energy.” That is the whole model — pairs plus singles, nothing else.
Definition. A QUBO is
where is an matrix and we used to merge linear terms into the diagonal. “Unconstrained” means there are no separate equality/inequality constraints — every preference and rule must be baked into , usually as a quadratic penalty.
Mapping mean–variance + cardinality onto a QUBO. Let if we hold asset (equal-weight the chosen names for simplicity). We want three things:
- Reward expected return — a linear term (negative because we minimize). Fold it into the diagonal: it lowers .
- Penalize risk — a quadratic term from the covariance. On-diagonal it adds variance; off-diagonal it adds covariance.
- Enforce the cardinality “choose exactly ” with a penalty for a large weight . This is zero when exactly switches are on and strictly positive otherwise.
Expanding the penalty is the key trick:
and using this contributes to each diagonal and to each off-diagonal pair (the is a constant offset that does not change which is best).
Worked example — a 3-asset QUBO. Three assets, choose exactly . Take risk-aversion , penalty , and these (toy) numbers:
| Asset | Expected return | Variance |
|---|---|---|
| A | 0.10 | 0.04 |
| B | 0.08 | 0.02 |
| C | 0.06 | 0.01 |
Pairwise covariances: .
Build term by term. Diagonal . With , :
Off-diagonal . With :
Now evaluate the energy for two candidate selections (the constant is the same for every , so we drop it and compare relative energies). Energy = sum of diagonal entries of chosen assets + the off-diagonal term of each chosen pair.
Candidate 1 — pick A and B (), which meets the constraint (2 names):
Candidate 2 — pick A only (), which violates the constraint (1 name):
The valid two-name portfolio has the lower (better) energy, — the penalty did its job: under-filling leaves a big chunk of the diagonal rewards unclaimed. For completeness, the three valid pairs:
| Selection | Energy (offset dropped) | Constraint |
|---|---|---|
| A, B | met (k = 2) | |
| A, C | met (k = 2) | |
| B, C | met (k = 2) | |
| A only | violated |
The optimum here is A + C at — it grabs the two best return/risk diagonals while paying the lowest pairwise penalty (their covariance is zero). Notice how close the valid energies are: real QUBOs have a rugged landscape where the best and second-best differ by a hair, which is exactly what makes the search hard.
Tuning lambda is the whole ballgame
The penalty weight must be large enough that violating the constraint always costs more than any return you could gain by cheating — but not so large it swamps the return/risk signal in floating-point noise and flattens the landscape. Too small and the “optimum” quietly breaks your cardinality rule; too large and the solver can’t tell good valid portfolios apart. Setting is a real engineering chore, not a footnote.
When to use it
Reach for a QUBO formulation when your problem is natively about on/off decisions with pairwise interactions — asset in-or-out, edge in-or-out, bit set-or-not — and when your constraints can be written as quadratic penalties. If your variables are genuinely continuous (fractional weights), forcing them into QUBO via binary expansion (one bit per 0.1% of weight) bloats the variable count and is usually a step backward.
Pick a term, then click its definition.
The Ising equivalence
Before you read — take a guess
Quantum annealers natively minimize an Ising energy with spins s_i in {-1, +1}, not binary x_i in {0, 1}. What converts one to the other?
A QUBO over and an Ising model over spins are the same optimization in different clothing. Substitute and any QUBO becomes an Ising Hamiltonian
where are coupling strengths and are local fields, both linear functions of the original . This single line matters because quantum annealers minimize Ising energies natively — the hardware is a programmable spin glass. So “solve my portfolio QUBO” becomes “set these couplers and fields, then let the physics relax to the ground state.” Keep the equivalence in your pocket; the rest of the lesson uses QUBO and Ising interchangeably.
Name the bridge between the two formulations.
Pick the right option for each blank, then check.
The substitution x_i = (1 + s_i) / 2 converts a QUBO (binary 0/1) into an model (spins minus-one/plus-one), which is what annealing hardware minimizes.
Quantum annealing: the adiabatic descent
Before you read — take a guess
What is the core promise of the adiabatic theorem that quantum annealing leans on?
Analogy. Annealing is named after metallurgy for a reason. Heat a metal until its atoms jiggle freely, then cool it slowly: the atoms settle into a low-energy, well-ordered crystal. Cool it fast (quench it) and they freeze into a messy, high-energy glass. Quantum annealing does the same trick on a problem’s energy landscape — it “cools” a quantum system slowly enough that it slides into the lowest valley (the optimum) rather than getting stuck in a local dent.
Definition — adiabatic / quantum annealing. The machine prepares the ground state of a simple driver Hamiltonian (one whose lowest-energy state is easy and known — a uniform superposition of all configurations). It then slowly interpolates to the problem Hamiltonian that encodes your Ising model:
By the adiabatic theorem, if the total time is long compared to — where is the smallest energy gap between the ground state and the first excited state along the way — the system stays in the ground state, and at a measurement returns the optimum of . That gap is the catch: for hard problems it can shrink exponentially, demanding an exponentially long anneal.
- Current energy
- 0.68
- Best energy found
- 0.68
- Temperature
- 0.02
A live QUBO descent. Each asset is one binary variable (one qubit): toggle names in or out, set the cardinality K, then press Run annealer. Watch the energy zig-zag downward — the hot uphill jumps early on are the 'temperature' letting the search escape local minima, exactly like slow cooling. The chips track current energy, the best energy found, the falling temperature, and whether the K-names constraint is met.
Play with the island above before reading on. Notice three things the physics buys you: the search accepts occasional uphill moves while hot (so it doesn’t get trapped in the first dip), those uphill jumps shrink as temperature falls (so it eventually commits), and the constraint chip can flicker red mid-search — a QUBO doesn’t forbid invalid states, it just makes them expensive, so the annealer wanders through them on its way down.
Worked example — why “slowly enough” can be ruinous. Suppose the minimum gap on a particular problem is (energy units). The adiabatic condition demands roughly time units. Halve the gap to and the required time quadruples to . For genuinely hard instances the gap closes exponentially in problem size, so the “guaranteed” anneal time blows up exponentially — which is precisely why real D-Wave anneals are short and repeated and treated as a heuristic, not a guarantee.
The hardware is sparse, your problem is dense
A D-Wave machine has thousands of qubits, but each qubit couples to only a handful of neighbors (its connectivity graph, e.g. Pegasus). A portfolio QUBO is typically dense — every asset pair has a covariance, so every variable couples to every other. To run a dense problem you must embed each logical variable across a chain of physical qubits to fake the missing connections. Chains eat qubits fast (a fully-connected problem of variables can need physical qubits) and can break mid-anneal, corrupting the answer. The headline qubit count is not the problem size you can actually solve.
When to use it
Quantum annealing is worth a pilot when your problem is natively Ising-shaped, sparse (so embedding overhead stays manageable), and you are content with a good heuristic answer rather than a certified optimum. Treat it as you would simulated annealing or tabu search: run it many times, keep the best sample, and always benchmark against a strong classical solver on the same instance before claiming any benefit.
Think first
A portfolio QUBO over 200 assets is fully dense (every pair has covariance). Your annealer has 5,000 qubits, each connecting to ~15 neighbors. Why might you still not be able to run it?
QAOA: the gate-model variational cousin
Before you read — take a guess
QAOA is a variational algorithm with p alternating layers. As the depth p grows toward infinity, what is the theoretical guarantee?
Analogy. If annealing is a marble cooling into a valley, QAOA is a relay race between two coaches. One coach (the problem Hamiltonian) nudges the team toward low-cost configurations; the other (the mixer) shakes things up so the team explores. They alternate for rounds, and a classical optimizer outside the race tunes how long each coach gets the baton (the angles) to make the final lineup as low-cost as possible.
Definition — QAOA. The Quantum Approximate Optimization Algorithm prepares a state by alternating layers of a problem unitary (encoding your Ising cost) and a mixer unitary (typically transverse-field spin flips):
A classical optimizer adjusts the angles to minimize the measured expected energy . It is a quantum–classical loop: the quantum chip evaluates the cost of a parameter setting, the classical optimizer proposes the next setting. As the layers can mimic the slow adiabatic sweep, so QAOA can in principle reach the optimum.
Worked example — the cost of depth. At depth you must optimize angles. For a modest that is 10 parameters — and each evaluation means running the circuit and sampling it thousands of times to estimate to acceptable precision. Say 5,000 shots per evaluation and 200 optimizer steps: that is circuit executions for one problem, on hardware where each multi-qubit gate injects noise. Deeper means deeper circuits, more noise accumulation, and a higher-dimensional angle landscape to search.
Barren plateaus and noisy gradients
QAOA’s classical optimization is not a formality. For many problem classes and random initializations, the cost landscape exhibits barren plateaus — regions where the gradient is exponentially small in the number of qubits, so the optimizer wanders almost flat ground with no signal pointing downhill. Layer hardware noise on top (today’s gate devices are noisy, with no error correction at scale) and the measured energy is a blurry, biased estimate. “Just increase ” makes the circuit deeper and noisier, often hurting more than it helps. This is why shallow QAOA has, so far, not demonstrated a clear win over good classical heuristics.
When to use it
Today, QAOA is primarily a research and learning tool, not a production portfolio optimizer. Use it to understand variational quantum algorithms, to benchmark small instances, and to track the field — but do not stake a rebalance on it expecting it to beat branch-and-bound or simulated annealing. If you are running QAOA in anger, keep shallow, warm-start the angles from known good values or the adiabatic schedule, and (again) always benchmark classically on the identical instance.
Sort each statement under the method it most accurately describes.
Place each item in the right group.
- Slowly morphs an easy Hamiltonian into the problem Hamiltonian
- A classical optimizer tunes 2p angles in a quantum–classical loop
- Leans directly on the adiabatic theorem and the minimum spectral gap
- Alternates problem and mixer layers for depth p
- Needs chain embedding for dense, all-to-all problems
- Can stall on barren plateaus during angle optimization
The sober verdict
Before you read — take a guess
Which statements honestly reflect the state of quantum portfolio optimization today? (Select all that apply.)
Time for the unglamorous truth. Classical combinatorial optimization is very good. Commercial mixed-integer programming (MIP) solvers using branch-and-bound and cutting-planes routinely crack cardinality-constrained portfolios with hundreds of assets to certified optimality, and metaheuristics like simulated annealing and tabu search deliver excellent near-optimal solutions fast when exactness isn’t required. Quantum annealing and QAOA are scientifically fascinating and may one day help on instances with especially nasty discrete structure — but as of today, no clear, reproducible advantage over these classical methods has been demonstrated on realistic portfolio problems.
| Method | What it solves | Guarantee vs heuristic | Maturity | Finance relevance today |
|---|---|---|---|---|
| Branch-and-bound MIP | Exact integer/cardinality programs | Certified optimum (with optimality gap) | Mature, commercial (Gurobi, CPLEX) | High — the default for hard discrete portfolios up to hundreds of names |
| Simulated annealing | Any QUBO/Ising, large instances | Heuristic (good near-optimal samples) | Mature, trivial to run on a laptop | High — strong baseline and the thing quantum must beat |
| Quantum annealing (D-Wave) | Sparse Ising/QUBO after embedding | Heuristic, no gap guarantee | Real hardware, sparse connectivity, embedding overhead | Low–emerging — pilots only; dense portfolios fit poorly |
| QAOA (gate model) | Small QUBO/Ising at shallow depth p | Heuristic; optimum only as p → ∞ | Early, noisy hardware, barren plateaus | Low — research and benchmarking, not production |
The disciplined posture is the same one this whole course preaches about machine learning: benchmark honestly, beware the hype, and let the classical baseline have the first and last word. If a vendor demos a quantum portfolio win, ask whether they ran the same instance through a tuned classical solver — the answer is usually that they didn’t, or that the classical solver also won.
Where the quantum bet actually lives
The interesting case is not “quantum is faster at Markowitz.” It is narrow: problems whose discrete structure is so rugged that even good classical heuristics struggle, that are naturally sparse (so they embed cleanly), and where a slightly better heuristic sample has real economic value. That is a small, specific niche — not “all of portfolio optimization.” Knowing exactly how small that niche is, today, is the expert’s edge.
When to use it
Default to classical: a MIP solver when you need a certified optimum and the instance is tractable, simulated annealing or tabu when you need fast, good-enough answers on large QUBOs. Consider quantum annealing only for sparse, genuinely hard discrete instances and only as a benchmarked pilot. Treat QAOA as a research instrument. In every case, the rule is identical: run the classical baseline on the same instance, and believe the numbers over the narrative.
If classical solvers already win, why study QUBO at all?
Answer. Three reasons. First, the QUBO formulation itself is portable: writing your cardinality-constrained portfolio as a QUBO lets you throw it at any of these backends — including the very good classical simulated-annealing and tabu solvers — so the modeling skill pays off immediately, quantum or not. Second, hardware and algorithms are improving; the practitioner who already speaks QUBO/Ising fluently is positioned to evaluate (and debunk) advantage claims the day they arrive. Third, the discipline of encoding messy business constraints as quadratic penalties sharpens how you think about the problem, regardless of what minimizes the energy. You learn QUBO to be ready and to stay honest — not because the quantum hardware is winning today.
Recap
You watched a beautiful convex machine seize up the moment a portfolio manager asked for a fixed name count, a minimum lot, or a round-share grid — the convexity cliff that turns polynomial-time mean–variance into a combinatorial, NP-hard search. You recast that search as a QUBO (minimize over binary ), folding return into the diagonal, risk into the quadratic term, and the cardinality rule into a penalty. You saw the one-line Ising equivalence that lets annealing hardware minimize it natively, the adiabatic descent of quantum annealing (and its gap-and-embedding caveats), and the variational QAOA loop (and its barren plateaus). And you ended where an expert should: classical solvers are strong, quantum advantage on real portfolios is not yet demonstrated, and the honest move is always to benchmark.
Big picture
QUBO and portfolio optimization
- QUBO portfolio optimization
- Why it gets hard
- Continuous mean–variance = convex QP (easy)
- Cardinality / min-lot = non-convex
- Combinatorial, NP-hard worst case
- QUBO recast
- min x^T Q x over binary x
- Return → diagonal (x^2 = x)
- Risk → quadratic covariance term
- Cardinality → lambda(sum x − k)^2 penalty
- Ising equivalence
- x_i = (1 + s_i)/2
- What annealers minimize natively
- Quantum annealing (D-Wave)
- Adiabatic: easy H → problem H
- Slow-cooling analogy
- Gap-limited, sparse, embedding chains
- Heuristic, not a guarantee
- QAOA (gate model)
- Problem + mixer layers, depth p
- Classical optimizer tunes 2p angles
- p → ∞ approaches optimum
- Barren plateaus, noise, no clear win yet
- Sober verdict
- Classical MIP / SA / tabu are strong
- No reproducible quantum advantage today
- Niche: sparse, genuinely hard structure
- Why it gets hard
Mixed check: can you recast and stay honest?
Why does adding a 'hold exactly k names' rule make mean–variance hard?
Check your answer to continue.