Q&A-1How do core quantum programming frameworks (e.g., Qiskit, Cirq, PennyLane) differ in their circuit representations, execution models, and target hardware abstractions?
Answer
The 90-second answer. All three build circuits from gates on wires; they disagree about what a circuit is. Qiskit treats it as a program to compile: QuantumCircuit is a mutable instruction list on virtual qubits, the transpiler lowers it to a DAGCircuit, and a Target supplies the coupling map, native basis, durations and error rates of one device. Cirq treats it as a schedule: a Circuit is an ordered list of Moments, each a set of operations on mutually disjoint qubits, so concurrency is explicit from construction. PennyLane treats it as a function: a QNode records ops onto a QuantumTape inside a classical autodiff graph, and the framework's core competence is analytic gradients, not device compilation. Compiler, scheduler, autodiff engine.
Representation.
- Qiskit:
QuantumCircuitholds(operation, qubits, clbits)instructions;DAGCircuitis the transpiler IR (qiskit.converters.circuit_to_dag). No time offsets until a scheduling pass adds them. Control flow is native:IfElseOp,WhileLoopOp,SwitchCaseOp(1.0),Store(1.1). - Cirq:
Momentenforces disjointness:cirq.Moment(cirq.X(q0), cirq.Y(q0))raises.cirq.Circuitinserts withInsertStrategy.EARLIESTby default, packing each op into the earliest moment whose qubits are free. That is why Cirq circuits read like hardware schedules. - PennyLane:
QuantumTapeis a linear record of ops plus measurements;QNodebinds it to a device and a diff method. Since 0.36,qml.capture.enable()traces QNodes into PLxPR, a JAXPR-like IR, so JAX can compile the whole hybrid loop.
Execution.
- Qiskit:
SamplerV2/EstimatorV2with PUBs:(circuit,),(circuit, parameter_values),(circuit, observables, parameter_values).SamplerV2returnsBitArrays,EstimatorV2returnsevs/stds. Qiskit 1.0 removedqiskit.opflowandQuantumInstance; 2.0 removedBackendV1andassemble(). - Cirq:
cirq.Simulatorfor state vectors,cirq.Samplerfor shots,cirq.Studyfor sweeps;cirq_googlereaches Google's Engine.cirq.googlemoved tocirq_googlein Cirq 1.0, andClassicallyControlledOperationwas replaced byCircuitOperation.with_classical_controls. - PennyLane:
qml.device("default.qubit")(exact statevector),"lightning.qubit"(C++),"default.mixed"(density matrix).diff_method="parameter-shift"costs two circuit executions per parameter for a single-parameter rotation;"adjoint"costs one extra circuit regardless of parameter count but needs measurements at the end.
Worked example: why the representation decides the cost. Route a CX between qubits 0 and 2 on a line coupling map 0–1–2. Track target bits over GF(2), where CX(i,j) does x_j ^= x_i:
start (x0, x1, x2)
CX(0,1) (x0, x1^x0, x2)
CX(1,2) (x0, x1^x0, x2^x1^x0)
CX(0,1) (x0, x1, x2^x1^x0)
CX(1,2) (x0, x1, x2^x0) == CX(0,2)One long-range CX becomes four native CX gates. IBM's heavy-hex lattice (max degree 3, e.g. the 127-qubit Eagle) puts typical qubit pairs several hops apart, so SabreSwap: the default routing method since Qiskit Terra 0.20: spends its budget picking a layout that keeps that multiplier down. Cirq's GridQubit sidesteps it by making you place qubits on the grid up front; PennyLane mostly doesn't care, because its target is a simulator or a plugin.
| Qiskit | Cirq | PennyLane | |
|---|---|---|---|
| Core object | QuantumCircuit → DAGCircuit | Circuit of Moments | QuantumTape in a QNode |
| Qubit id | virtual Qubit in a QuantumRegister | GridQubit, LineQubit, NamedQubit | integer/string wires |
| Device model | Target (basis, coupling map, durations, error rates) | Device/GridDevice (geometry, moment validation) | backend plugin (Device/DeviceV2) |
| Optimised for | compilation, dynamic circuits, error mitigation | pulse/moment scheduling, noise modelling | variational algorithms, gradients |
Failure modes.
- Layout blowup. Each long-range CX costs at least 4 CX gates (the identity above), so an all-to-all Qiskit circuit transpiled onto heavy-hex can see two-qubit gate counts multiply several-fold, and depth grows faster than gate count once SWAPs serialize. Compare
count_ops()anddepth()before and aftertranspile(); don't eyeball the drawing. - Re-transpiling inside a variational loop. Calling
transpile()per optimizer step re-runs layout and routing. Transpile once and bind parameters later, or pass a parameter array through anEstimatorV2PUB. - Cirq moment explosion.
InsertStrategy.NEW, or ops added in a bad order, gives one moment per gate: a 100-gate circuit reports depth 100 and the scheduler has nothing to pack. Checklen(circuit.moments)againstlen(list(circuit.all_operations())). - Gradient cost. Parameter-shift on a 100-parameter ansatz is 200 circuit executions per gradient: fine on
default.qubit, fatal on hardware.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.