Back to Articles
Technical blog · I-314 Security Research

The silent Quantum-Hadamard bug: when initializing your qubits “the usual way” destroys your risk model

AuthorJuan Pablo Braña — i-314 Security Research TopicQuantum finance · Amplitude encoding DateJuly 2026 Reading time~7 min
The Silent Bug — a single Hadamard gate turns a portfolio's riskiest asset into its safest. Circuit: |0⟩ → H (the culprit) → RY → measure.

A single Hadamard gate can turn your riskiest asset into — apparently — your safest one. And the worst part: the circuit never complains.

If you learned quantum computing from the usual examples — Grover, amplitude estimation, the quantum Fourier transform — you have one reflex burned in: step 1 is to apply a Hadamard to every qubit to build a uniform superposition. It’s almost muscle memory. And in many algorithms it’s exactly the right thing.

In a risk model built with amplitude encoding, that same reflex breaks everything. Silently: the circuit runs, returns probabilities, and the numbers look reasonable. It’s only when you check where the portfolio’s most dangerous asset ended up that you realize something broke.

Working on a portfolio-risk pipeline over 110 qubits, I ran into exactly this. Here’s the story, because the lesson goes beyond quantum.

Left: the faithful encoding is the identity line P(|1⟩) = risk; initializing with H bends it into a circular arc that peaks at risk 0.5. Right: the riskiest asset SMCI drops from rank #1 to #100, ENPH #2→#30, MSTR #3→#26.
The whole failure in one picture. Left: the faithful encoding tracks true risk exactly (blue), while “Hadamard everything” folds it into the upper half of a circle (red). Right: the consequence — the riskiest names collapse toward the safe end of the ranking.

The setup: one qubit per asset

The idea behind amplitude encoding is to write a classical number — here, each asset’s risk — into a qubit’s amplitude. With an RY(θ) rotation on a qubit that starts in |0⟩, choosing θ = 2·arcsin(√risk), you get something very clean: the probability of measuring |1⟩ is exactly the asset’s risk.

Risk 0 → you measure |1⟩ 0% of the time. Maximum risk → nearly 100%. The relationship is the identity line on the left of the chart: faithful, monotonic, no surprises. That’s the criterion. And it hinges on a detail that’s easy to overlook: the qubit has to start in |0⟩, because that initial state is the blank page the rotation writes the data onto.


Why the Hadamard breaks it

Now let’s add the textbook reflex: a Hadamard on each qubit before the rotation. The Hadamard takes |0⟩ to |+⟩, a superposition where the probability of |1⟩ is already 0.5. The risk rotation no longer writes on a blank page: it writes on top of something already halfway there.

The math gives a function that’s beautiful and disastrous at once:

Probability of measuring |1⟩P(|1⟩) = ½·(1 + sin θ) = 0.5 + √(risk·(1 − risk))

It’s the upper half of a circle (the red curve in the chart). And it has two properties that are lethal for measuring risk:

Side by side, the numbers make the failure concrete — our encoding tracks the true risk exactly, while the Hadamard version folds it back on itself:

Table: for true risk from 0.00 to 1.00, the faithful encoding returns exactly the risk, while the with-H version returns 0.50, 0.80, 0.90, 0.96, 0.99, 1.00, 0.99, 0.96, 0.90, 0.80, 0.50 — non-monotonic, collapsing both extremes to 0.50.
The same value read two ways. Our approach (qubit in |0⟩, no H) returns the risk verbatim; with the Hadamard, both risk 0 and maximum risk report 0.50, and everything in between is folded.

The information wasn’t lost to noise or decoherence. It was lost to one extra gate, in the initial state, before the interesting part even began.


The cost: the ranking flips exactly where it matters

Here’s what makes this especially treacherous: if you measure the rank correlation across the whole portfolio, the aggregate number can still look high enough to pass a quick sanity check. In our universe almost every asset lives in the low-risk zone — where the curve is still rising — so very few names fall into the region where it folds back. The average hides it.

But the damage isn’t evenly spread: it concentrates in the tail, which is the entire reason risk management exists. In our run, SMCI — the riskiest of the 110 assets, ranked number 1 — dropped to rank 100. Practically the safest on the list. ENPH went from 2nd to 30th; MSTR, from 3rd to 26th. The five most dangerous, evaporated from the top.

A risk system that tells you your most volatile position is one of the calmest isn’t slightly off-key: it’s broken. And the aggregate metric was smiling at you the whole time.


The most uncomfortable part: it isn’t a “bug”

Here’s what made me think the most. Technically, this isn’t a code bug. The Hadamard did exactly what we asked — it executed perfectly: no typo, no off-by-one, no NaN. The circuit ran clean and returned well-formed probabilities.

What was wrong was the reasoning. We put a uniform superposition — a flawless recipe in Grover, in amplitude estimation, in interference-based ansätze like VQE or QAOA — into an encoding-and-measurement phase, where it doesn’t belong. It’s a design error, not a software one. And that makes it more dangerous: an error that never complains isn’t caught by any test. It only surfaces when someone looks at the final result and asks whether it makes sense.


Three things I’m taking away

  1. In amplitude encoding, |0⟩ isn’t “empty”: it’s the canvas. Superposition isn’t free; it overwrites. Before adding a gate to the initial state, ask what information already lives there.
  2. Borrowed recipes carry someone else’s assumptions. “Hadamard on everything” is right when you want to explore an unknown space uniformly (search, estimation over states you don’t control). A model where you choose each qubit’s amplitude is the opposite case. Copying the pattern without copying the context is how these errors sneak in.
  3. Validate in the tail, not on the average. No exception fired and the aggregate metric looked healthy. What exposed the problem was a domain check: does the ranking make sense where it matters most? When the error hides in the few critical cases, averaging over all of them hands you a reassuring, false answer.

Quantum computing still carries a thick layer of mystique. But many of its practical stumbles are old acquaintances in new clothes: implicit assumptions, recipes copied out of context, and metrics that average away the exact error that matters most.

Sometimes it all comes down to one extra gate. What’s the most silent bug — the one that ran without complaining — you’ve had to hunt down?


Keep in touch

First published on LinkedIn.


Juan Pablo Braña
Juan Pablo Braña — Founder & CEO, I-314.
AI red-teaming, agentic-AI security and post-quantum cryptography. LinkedIn