← Back to projects

·Qiskit · PyTorch · NumPy

Quantum Machine Learning

Can a neural network learn to emulate a quantum gate? The answer is about data, not architecture.

?

The questions

  • When you train a neural network to imitate a quantum gate, does the representation of its output decide whether the learned gate composes?

How it builds up

Each block answers a piece of the question and feeds the next — foundations at the top, the answer at the bottom.

flowchart TD
  Q(["Does the output representation<br/>decide if a learned gate composes?"]):::q
  D["exact data<br/>Qiskit statevectors"]
  P["probability mode<br/>trains on Born-rule p(b)"]
  U["unitary mode<br/>trains on (Re, Im) amplitudes"]
  C["composition test<br/>apply the gate U^k"]
  NZ["noisy channel<br/>density matrix vs populations"]
  Q --> D
  D --> P --> C
  D --> U --> C
  C -->|"phase squared away"| FAIL(["probability mode diverges"]):::a
  C -->|"phase kept"| HOLD(["unitary mode holds ~0.998"]):::a
  D --> NZ
  classDef q fill:#1a1206,stroke:#f0a83e,color:#f3c98a;
  classDef a fill:#f0a83e,stroke:#f0a83e,color:#10141a;

Inside the build

Each stage of the calculation. Click one to expand its full write-up and validation figure.

01exact data generation — ground truth

Qiskit builds the exact input/output statevectors for target gates (CNOT, RY, RZ). The input is identical across modes; only the training target differs.

02probability mode — phase discarded

Trains the network on Born-rule probabilities p(b) = |⟨b|Uψ⟩|². Squaring the amplitude throws away phase — the network learns a single gate fine, but has no phase to hand back.

03unitary mode — phase kept

Trains on the full output statevector as (Re, Im) amplitudes. The learned gate can be composed because its output is a well-posed next input.

04composition test — the tell

Feeds each learned gate’s output back in and applies it again (U^k). Probability mode diverges from the truth as k grows; unitary mode holds to ~0.998–0.9997 fidelity.

05noisy channel — generalization

Repeats the argument for an unknown noisy channel: the full density-matrix representation composes; a populations-only (coherence-discarded) representation diverges.

Figures

Click any figure to enlarge. Use ← → to move through the set.

What it shows

  • The barrier is the information in the target, not the network. Training on probabilities squares away phase, so U² diverges from the truth; training on amplitudes keeps phase and composition holds to ~0.998.
  • It is a representation problem, provably so: feed the probability model tomographically complete (X/Y/Z-basis) data and it recovers phase after all — the wall is what the target encodes, not the architecture.
  • The same logic extends to open systems: under noise the density matrix composes while its diagonal alone does not.