Exercises: Pulse-Level Programming, and What Replaced It

These need qiskit, qiskit-aer, and qiskit-ibm-runtime. Solutions to starred exercises are in Answers to Selected Exercises.

A standing rule for this chapter: before trusting any simulated result, state what the noise model contains. Case Study 2 is what happens otherwise.


What was removed

31.1 ★ Confirm qiskit.pulse does not import, and that QuantumCircuit.add_calibration, backend.defaults, and backend.drive_channel are gone.

31.2 ★ Find a tutorial or Stack Overflow answer that uses the pulse API. What does it teach, and what would a reader hitting it today experience?

31.3 ★★ Write a test that would have alerted you to each of this book's four API removals at upgrade time. How long does the suite take?

31.4 ★★ Build a REMOVED dictionary mapping each vanished name to its replacement, and a lookup that raises with a pointer rather than an AttributeError.

31.5 ★★★ Find a published paper whose code depends on qiskit.pulse. Can you still run it? What would it take to port?


Time

31.6 ★ Report target.dt in seconds and nanoseconds. What is it physically?

31.7 ★ Report the median duration of rz, sx, x, ecr, and measure. Which is the slowest?

31.8 ★ rz has duration 0.0. Explain the virtual Z gate in three sentences.

31.9 ★★ Count the rz gates in a transpiled circuit from Chapter 29. What would they cost if they were physical rotations of the same duration as sx?

31.10 ★★ sx durations are identical across all qubits; ecr durations span 341–882 ns. What does that asymmetry tell you about how the two gates are calibrated?

31.11 ★★ Measurement costs 1,216 ns. Estimate the duration of one full surface-code syndrome extraction cycle (Chapter 25 §25.7) and compare against $T_2$. How many rounds fit?


The coherence budget

31.12 ★ Report median $T_1$ and $T_2$. Compute $T_1 / t_{\text{ecr}}$.

31.13 ★ At Chapter 12's measured gate error, what fraction of those gates survive? Which constraint binds?

31.14 ★★ Write coherence_budget(backend, gate_error) returning which constraint binds. At what gate error does the device become decoherence-limited rather than gate-error-limited?

31.15 ★★ Chapter 17 covered trapped ions, which have much longer coherence and much slower gates. Which regime are they in, and what does that change about how you would write circuits for them?

31.16 ★★★ Chapter 25 §25.9 found the QEC threshold set by syndrome-extraction gate quality. Using this chapter's durations, compute how many syndrome rounds fit in $T_2$ and what that implies for the achievable code distance.


Scheduling

31.17 ★ Schedule a transpiled circuit ALAP and report its duration in microseconds.

31.18 ★ Compute the busy/idle split of qubit-time. Reproduce the 97%.

31.19 ★★ Compare ASAP and ALAP scheduling of the same circuit. Where does the idle time go in each, and which puts less idle time immediately before measurement?

31.20 ★★ What fraction of $T_2$ does your circuit use? At what circuit depth would decoherence start to matter on this device?

31.21 ★★★ The idle fraction is 97% partly because the circuit uses 6 of 127 qubits. Recompute it counting only the qubits the circuit actually touches. Which number is the honest one?


Dynamical decoupling

31.22 ★ Apply PadDynamicalDecoupling with an XX sequence and count the added gates and delays.

31.23 ★ Measure $1-\text{TVD}$ with and without DD over six transpiler seeds. Report the difference with a standard error.

31.24 ★★ Repeat with XY4. Does more decoupling help or hurt, and by how much?

31.25 ★★ Insert a deliberate 20 μs idle window and re-measure. Does DD do better with more idle time to work on?

31.26 ★★ Inspect NoiseModel.from_backend(...). List every error channel. Is any of them correlated in time?

31.27 ★★★ Explain, in your own words and in no more than five sentences, why dynamical decoupling cannot help against a Markovian channel. Your explanation should make the sign of §31.4's result obvious in advance.

31.28 ★★★ Build a noise model with explicitly correlated dephasing — sample a slowly-varying phase offset per shot and apply it during idle windows — and re-run the comparison. Does DD win now?


Project

31.29 ★★ (Project Checkpoint) Build vqelab/timing.py with REMOVED_IN_QISKIT_2, pulse_api_replacement, gate_durations, coherence_budget, schedule_with_dd, circuit_timing, noise_model_is_markovian, and evaluate_dynamical_decoupling. Write tests asserting:

  1. qiskit.pulse raises ModuleNotFoundError, and the circuit/backend attributes are gone.
  2. Every removal has a documented replacement; asking about a non-removed name raises.
  3. target.dt is sub-nanosecond.
  4. rz duration is exactly 0.0, and sx/ecr are not.
  5. measure costs more than 2× the median two-qubit gate.
  6. sx durations are uniform; ecr durations span more than 2×.
  7. 522 gates fit in $T_1$, fewer than 5% survive, and the device is gate-error-limited.
  8. A hypothetically better device would be decoherence-limited.
  9. coherence_budget raises when no two-qubit gate is recorded.
  10. Idle fraction exceeds 90%, and the circuit runs in about 7 μs.
  11. The circuit uses under 10% of the $T_2$ budget.
  12. DD adds gates and delays; XY4 adds more than XX.
  13. The backend noise model is Markovian.
  14. evaluate_dynamical_decoupling returns NOT_EVALUABLE, not a number, and trustworthy is False.
  15. The refusal names CORRELATED, 1/f, memoryless, HARDWARE, and quotes -0.0053.
  16. No noise model is also not evaluable.
  17. The docstring states the reason where someone will read it.
  18. Shape (Ch. 29) is worth more than 5× optimization level (Ch. 28).

Tests 1, 4, 7, 10 and 14 are the ones this chapter exists to encode.

31.30 ★★★ Extend the module with schedule_comparison(circuit, backend) reporting duration, idle fraction, and idle-before-measurement for ASAP versus ALAP. Which should be the default, and why?


Going further

31.31 ★★ Read about DRAG pulses. What leakage problem do they solve, and why does a square envelope cause it?

31.32 ★★★ Qiskit Dynamics simulates the underlying Hamiltonian rather than a gate-level noise channel. Could it answer §31.4's question? What would you need to specify that AerSimulator.from_backend does not require?

31.33 ★★★ Part V ordered four levers: shape, optimization, scheduling, mitigation. Take one circuit from any earlier chapter and apply all four in order, measuring after each. Does the ordering this chapter claims hold for your circuit?