Circuits¶
A circuit is the central structure in vqubit: an ordered sequence of quantum operations. If gates are the words, the circuit is the sentence.
A circuit is a list of moments¶
vqubit organises operations into moments (Moment). A moment groups
operations that happen at the same time (on different qubits). This reflects
how hardware works: simultaneous operations must use different qubits.
When you build a circuit from gates, vqubit decides automatically which moment each one goes into, respecting order and avoiding conflicts:
import vqubit as vq
q0, q1, q2 = vq.LineQubit.range(3)
circuit = vq.Circuit(
vq.H(q0),
vq.CNOT(q0, q1),
vq.X(q2), # can share a moment with H(q0)
)
print(circuit)
It is drawn as text, one line per qubit:
Read the diagram left to right: each column is a moment.
Building step by step¶
You can create an empty circuit and add operations later:
Or insert at a specific moment:
Iterating over a circuit¶
A circuit can be traversed by moments or by operations:
Running the circuit¶
A circuit is a description; to get results you have to simulate it:
Next steps¶
See a complete, commented example: the Bell state.