liveBook · Manning

Qiskit

As explained in Quantum Programming in Depth

Qiskit is an open-source software development kit for writing and executing quantum programs, including a Python library interface.

Qiskit is a Python library for constructing quantum circuits: fixed collections of qubits, gates, and optional classical bits for measurements. A circuit is a QuantumCircuit instance, and built-in gate methods such as ry, x, h, z, cx, and measure append operations to it. Qiskit code lives in ordinary Python projects and can be run as Python scripts. section 1.5 section 2.1.2

A typical workflow builds a circuit, runs it on a backend, and analyzes the returned data in Python. AerSimulator can expose a saved statevector for amplitude-level inspection; measured runs instead return shot counts keyed by classical bit strings. Classical post-processing happens after circuit execution rather than as arbitrary decision-making inside the circuit. section 2.2.1 section 4.1.2 section 5.1.2

Compose and inspect circuits by:

  • Allocating qubits and classical bits up front, then appending gates or reusable subcircuits to specified qubit indices. section 2.1.2 section 6.5.2
  • Turning circuits into gates, controlling them, taking inverses, and raising them to powers to assemble larger operations. section 2.5.2 section 7.2.3
  • Transpiling for a simulator, executing repeated shots, and checking statevectors, matrices, counts, or classical outputs. section 2.4.1 section 3.5.3 section 7.2.3

Prepare and verify a one-qubit state

For amplitudes 0.6 and 0.8, compute theta as 2 * atan2(beta, alpha), create QuantumCircuit(1), and apply ry(theta, 0). Saving and retrieving the simulator statevector yields amplitudes for |0⟩ and |1⟩, which can be compared with the intended values in a Python test. section 2.1.2 section 2.2.1 section 2.4.1

Qiskit supports implementations ranging from state preparation and unitary construction to measurement, reversible Boolean evaluation, phase estimation, and Grover search. Circuit layout matters: qubit order affects displayed states, matrix indices, measurements, and how subcircuits are appended. Auxiliary qubits remain part of the full circuit, even when later reused. section 6.2.2 section 7.1.2 section 7.2.3

Listing 7.3 Qiskit code for Grover’s search algorithm
def grovers_search(n_bits, marking_oracle, prepare_mean, n_iterations):

  iter = QuantumCircuit(n_bits + 1)  #1
  
  phase_or = phase_oracle(n_bits, marking_oracle)  #2

  iter.append(phase_or, range(n_bits + 1))  #3
  
  iter.append(prepare_mean.inverse(), range(n_bits)) 
  iter.x(range(n_bits))
  iter.append(ZGate().control(n_bits - 1), 
              range(n_bits))
  iter.x(range(n_bits))
  iter.append(prepare_mean, range(n_bits))            #4

  circ = QuantumCircuit(n_bits + 1, n_bits)  #5
  circ.append(prepare_mean, range(n_bits))   #6
  circ.append(iter.to_gate().power(n_iterations),  #7
              range(n_bits + 1))
  circ.measure(range(n_bits), range(n_bits))  #8

  return circ
  

Inspect a complete hand-built Grover circuit that combines a marking oracle, phase kickback, reflection about the mean, repeated iterations, and final measurement. section 7.2.3

How Quantum Programming in Depth covers it

How deep it goes
Works through circuit construction, simulation, composition, and pytest-based verification; defers environment setup to an appendix.
Examples
Uses Ry state preparation, multiqubit recursion, measurement counts, Boolean circuits, phase estimation, and a marking oracle.
What it assumes
Assumes comfort with Python projects, variables, loops, and methods while introducing Qiskit language elements as needed.
What you can do after
Build circuits from scratch, simulate them, inspect quantum and measurement results, and test expected behavior with Python tools.
How it connects
Connects QuantumCircuit with AerSimulator, statevectors, measurement, transpilation, unitary gates, phase estimation, and Grover’s search algorithm.

Also explained in

Compare how 2 books explain Qiskit →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quantum Programming in Depth. The section links point to the parts of the book it draws on.