Overview
Curated: · Written: · Reviewed:
Quantum Programming Frameworks
In one line
Qiskit, Cirq and PennyLane are the toolchains you build, compile and run circuits in. Reach for them when you need to move a circuit from a local simulator to a hardware backend, because that move is where most of the interview questions sit.
Key definitions
- Target: Qiskit's description of a device's basis gates, coupling map and limits. Transpilation compiles against it.
- Sampler: Qiskit primitive that returns bitstring counts from shots.
- Estimator: Qiskit primitive that returns expectation values of observables.
- Moment: Cirq time slice. Operations in one moment act on disjoint qubits.
- QNode: PennyLane function binding a circuit to a device and a differentiation method.
Formulas and complexity
Standard error of a probability estimated from N shots. At p = 0.5 and N = 4096 it is under 1%.
Statevector memory at complex128. A 30-qubit state needs 16 GiB.
Parameter-shift for standard Pauli rotations. Each parameter costs two circuit evaluations per gradient, so 40 parameters cost 80 evaluations, each repeated for every shot batch.
How it works
- Build the circuit with free parameters as objects.
- Bind values, keeping each parameter bound by object identity.
- Transpile against the target's basis gates and coupling map.
- Check the target's live capabilities at submission time.
- Simulate, or submit with a durable idempotency key.
- Store counts together with provider metadata and the exact executed circuit.
When to use and when not to
| Option | Use when | Limit |
|---|---|---|
| Statevector simulator | Ideal amplitudes, small n, CI tests | Memory grows as 2^n, no noise or shots |
| Density-matrix or trajectory simulator | Modelled noise matters | Cost rises quickly with qubit count |
| Hardware QPU | Device behaviour is the question | Queue time, per-shot fee, calibration drift |
| Adjoint or backprop gradients | Exact gradients on a simulator | Not available on hardware |
| Parameter-shift gradients | Hardware, or any device without analytic gradients | Two evaluations per parameter, all shot-limited |
Traps interviewers probe
- Reading bit order as fixed. Qiskit labels qubit 0 on the right. Check histogram conventions with an asymmetric fixture before computing fidelity.
- Estimating a Pauli expectation from computational-basis counts. Z-type terms work on raw counts, but X-type terms need a basis change before measurement. Fix: use the Estimator, or rotate each term's basis explicitly.
- Calling Operator on a circuit with measure, reset or conditionals. It raises QiskitError, while depth() and count_ops() still return. Fix: simulate the circuit, or compare only its unitary part.
- Retrying a timed-out submit without an idempotency key. The provider may have accepted the first request, so the retry bills twice. Fix: persist the key before sending, look the job up by key on timeout, and retry only if no job exists.
- Binding parameters by name. Independent subroutines that both declare theta collide in a name-keyed table. Fix: bind by parameter object, or give each subroutine a unique parameter.
Interview tips
Open by naming the workflow stage the question tests: compile, execute, or interpret. Then state the one assumption that decides the answer, such as whether the target is a simulator or hardware.
Expect these follow-ups: How many executions does one gradient cost on hardware? What changes if the target has a different coupling map? How do you know two frameworks agree on bit order? What does a passing local simulator not prove?
30-second outline: Name the stage. Give the mechanism in one sentence, for example transpilation rewrites gates to the target's basis and routes two-qubit gates across the coupling map. State the cost, such as extra CX gates and depth, and the trap, such as a silent bit-order flip. Close with the control you use, such as a canary circuit with a known answer at fixed shots.
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.