liveBook · Manning

Grid state

As explained in Building Quantum Software with Python

A grid state is a two-dimensional visual arrangement of quantum-state outcomes in rows and columns, often used to display selection and encoded-value coordinates.

A grid state is a two-dimensional visualization of a quantum state. Columns represent input or key-register outcomes, rows represent output or value-register outcomes, and each pixel or amplitude bar represents an outcome's amplitude. section 12.4 section 10.1.1

Use the grid to read and transform a state visually:

  • Interpret pixel color as amplitude phase and intensity or bar length as amplitude magnitude. section 12.4
  • Partition qubits into prefix and suffix registers, then reshape the one-dimensional state array into rows and columns. section 12.4
  • For function encoding, read each column as an input and the nonzero row as its encoded output. section 10.1.1
  • Visualize gates as recombinations of columns when the target lies in the prefix, or rows when it lies in the suffix. section 12.4

Visualizing an encoded function

Call grid_state(qc.run(), n_key, neg=False, show_probs=False) after preparing the circuit. The resulting grid displays encoded function inputs as columns and outputs as rows; enabling show_probs adds numeric probabilities beside amplitude bars. section 10.1.1

Figure 12.7 A three-qubit quantum state (top) and a four-qubit quantum state (bottom) illustrated as two-dimensional arrays of pixels
figure

Compare one-dimensional pixel arrays with their two-dimensional grid arrangements for three- and four-qubit states. section 12.4

Figure 12.8 Visualizations of quantum transformations on different target qubits
figure

Inspect how applying gates to different target qubits changes rows or columns in the visual state representation. section 12.4

How Building Quantum Software with Python covers it

How deep it goes
Explains reshaping, amplitude display, register partitioning, and gate-driven row or column recombination without deriving the underlying quantum operations.
Examples
Uses pixel arrays, three- and four-qubit grids, encoded key-value functions, and X-gate row swaps as visual examples.
What it assumes
Assumes basic qubits, registers, amplitudes, gates, and measurement while making their visual relationships concrete.
What you can do after
Evaluate quantum-state structure and function encodings by reading amplitudes, probabilities, input columns, output rows, and measurement coordinates.
How it connects
Connects quantum states, qubit registers, amplitudes, phase, quantum gates, measurement, and function encoding.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Quantum Software with Python. The section links point to the parts of the book it draws on.