Part III. Circuit Model

Multi-Qubit Circuits

Two qubits share one four-dimensional state space, and every gate in the circuit acts on a specific piece of it. This chapter drills the discipline that keeps multi-qubit work honest: fix a basis order, expand the tensor products, and check entanglement by factoring, not by counting wires.

Listen to this chapter

Most multi-qubit mistakes are convention mistakes — a swapped control and target, a basis order that drifted mid-calculation — and they survive review precisely because the arithmetic looks locally consistent; the only defense is writing the conventions down and tracing against them.

You will expand product states by hand, apply a CNOT with full attention to gate scope, and factor the result to decide — algebraically, not visually — whether it is entangled. Then we will look at why the same tensor structure is what makes exact classical simulation exponential.

Core concepts: tensor products, gate scope, basis order, factorability.

Gate scope and basis order in a two-qubit circuit Every gate has a scope; identity fills the rest |q0> |q1> H X H on q0 means H ⊗ I X on q1 means I ⊗ X fix the order: |00>, |01>, |10>, |11> 4 amplitudes, one declared order — drift corrupts every gate trace after it
Notice that the drawing underspecifies the operator: the same H symbol means H ⊗ I here and I ⊗ H one wire down. The declared basis order on the right is what makes any of it checkable.

One state space, not two wires

A two-qubit circuit is not two one-qubit circuits sharing a page. The joint state lives in a four-dimensional space with one amplitude per computational-basis string:

Gates then have scope. A one-qubit gate drawn on one wire acts as that gate on one factor and as the identity on the other; a two-qubit gate mixes the branches according to its own rule. Entanglement appears when the result can no longer be written as one state per wire.

The working discipline is boring and absolute: choose a basis order once, write it at the top of the page, and never let it drift.

Tensor products and gate scope

A product of two one-qubit states expands by distribution:

Four amplitudes, but built from only four numbers with heavy structure — that is what separable means. A general two-qubit state has four free amplitudes and no such factorization. Wire count tells you the dimension of the space; by itself it says nothing about entanglement.

Scope is the other half of the discipline. H on the first qubit is the matrix ; on the second it is . CNOT with the first qubit controlling is a different permutation from CNOT with the second controlling. Same gate symbols, different operators.

Worked example: expand, apply, factor

Take the two states from the one-qubit chapters:

Their product expands to:

Four amplitudes, all nonzero — and yet nothing is entangled, because we built the state as a product and it factors back into one. Now apply CNOT with the first qubit as control:

The state becomes:

which factors as . On this particular input, CNOT produced no entanglement either. The lesson cuts both ways: entanglement is a property of the amplitudes, established by trying to factor — never by counting wires or nonzero terms.

Two traps: wire-counting and basis drift

The first trap is declaring every multi-qubit state entangled. A statevector with four entries may still factor cleanly, and the check is algebraic, not visual.

The second is quieter and more expensive: basis-order drift. Write your amplitudes in the order , then silently switch to halfway through, and every subsequent trace can look plausible while being wrong. This is the multi-qubit version of a sign error, and code review rarely catches it because each line is consistent with some convention.

What this looks like in code

Tensor products are why exact simulation is exponential. A statevector simulator stores complex amplitudes for qubits; a one-qubit gate becomes a strided pass that updates pairs of amplitudes; a controlled gate permutes or mixes the branches whose control bits are set. Thirty qubits is a billion amplitudes — the math from this chapter, running out of RAM.

Depth and width are software concerns too. Two circuits with the same unitary can schedule completely differently after decomposition, so treat the abstract circuit as the semantic object and the compiled circuit as the execution object. Chapter 22 prices the difference.

What to check in a platform

When you review a simulator, SDK, or compiler pass, look for the conventions page: qubit ordering, endianness of basis strings, gate scope, and measurement bit order. Most integration bugs in this space are convention mismatches between two components that are each internally correct.

A serious platform states these conventions in its API documentation and tests them with small hand-checkable traces — exactly the traces you just did. If the conventions are undocumented, expect to discover them during a debugging session instead.

Exercise

Expand, apply, factor. Expand in the computational basis, apply CNOT with the first qubit as control, then test the result for factorability. Finish with one sentence on why qubit-order conventions belong in a platform's API documentation.

  • Submit: the ordered amplitudes before and after the gate, and your factorization check with the algebra shown.
  • Check: state whether the result is entangled, justified by the product-state expansion — not by how many wires or terms are present.
  • Repair: if your basis order changed mid-trace or every four-amplitude state came out entangled, rework Chapter 16 (Circuit Notation as a Programming Language) and the tensor-product material in Chapter 13 (Tensor Products and State-Space Growth).

Check your understanding

Compute a two-qubit circuit by hand — expansion, gate action, final amplitudes — then run the same circuit in a simulator and reconcile the statevector entry by entry, in your declared basis order.

Oral defense: explain why is not entangled even though its expansion has four nonzero terms, and what calculation would prove you wrong.

If you get stuck

If you cannot keep the basis order fixed, identify which wire a gate acts on, or separate product states from entangled ones, return to Chapter 13 (Tensor Products and State-Space Growth) and Chapter 16 (Circuit Notation as a Programming Language). Every later circuit chapter assumes both are automatic.