Visualization Tools (qiskit_addon_slc.visualization)

Visualization methods for shaded lightcones.

This module provides visualization methods for shaded lightcones.

draw_shaded_lightcone(circuit, bounds, noise_model_paulis, *, pauli_filter=None, include_empty_boxes=True, **rendering_kwargs)[source]

Draws a shaded lightcone.

First, the provided bounds are accumulated and filtered according to pauli_filter. See also accumulate_filtered_bounds(). Then, the resulting bounds are overlaid onto the provided circuit (see overlay_bounds_onto_circuit()) and subsequently rendered (see render_bounds()).

Parameters:
  • circuit (QuantumCircuit) – the circuit whose shaded lightcone to draw.

  • bounds (dict[str, PauliLindbladMap]) – the bounds to use for the shaded lightcone.

  • noise_model_paulis (dict[str, QubitSparsePauliList]) – the Pauli error terms of the circuit’s noise models.

  • pauli_filter (Pauli | str | int | None) – the optional Pauli type by which the bounds were filtered.

  • include_empty_boxes (bool) – whether to include empty boxes or not.

  • rendering_kwargs – any additional keyword arguments are forwarded to QuantumCircuit.draw().

Returns:

The mpl figure.

Return type:

Figure

accumulate_filtered_bounds(circuit, bounds, noise_model_paulis, pauli_filter=None)[source]

Accumulates the bound values filtered by a specified Pauli type.

Parameters:
  • circuit (QuantumCircuit) – the circuit whose bounds to accumulate.

  • bounds (dict[str, PauliLindbladMap]) – the bounds whose values to accumulate.

  • noise_model_paulis (dict[str, QubitSparsePauliList]) – the Pauli noise terms for each noise model.

  • pauli_filter (Pauli | str | int | None) – the optional Pauli type to filter by. It behaves as follows: - None: accumulates all noise term bounds of equal support. - int: only accumulates noise term bounds of the specified Pauli weight. - str: selects this specific Pauli noise term. - Pauli: selects this specific Pauli noise term.

Returns:

A nested dictionary. The outer most key is the InjectNoise.modifier_ref (same as the original bounds). The next key is the support of the accumulated and filtered bound value (i.e. a tuple of integers). This maps to the actual bound value as a float.

Return type:

dict[str, dict[tuple[int, …], float]]

overlay_bounds_onto_circuit(pauli_bounds, circuit, *, include_empty_boxes=True)[source]

Overlays the bounds onto the circuit.

This produces a new “QuantumCircuit” with “fake” gates reproducing those BoxOp instructions from the original circuit that had an InjectNoise annotation. Those boxes are replaced by visual representations of the computed bounds for Pauli errors of their respective support (see also accumulate_filtered_bounds()).

Parameters:
  • pauli_bounds (dict[str, dict[tuple[int, ...], float]]) – the accumulated and filtered bounds.

  • circuit (QuantumCircuit) – the circuit on which to overlay the bounds.

  • include_empty_boxes (bool) – whether to include empty boxes or not.

Returns:

A “fake” quantum circuit with “Gate” instructions displaying the computed bound values. The returned quantum circuit’s QuantumCircuit.metadata contains the maximum bound value under “max_bound”.

Return type:

QuantumCircuit

render_bounds(bounds_circuit, *, pauli_filter=None, **kwargs)[source]

Renders a quantum circuit with overlaid bounds and according styling.

Parameters:
  • bounds_circuit (QuantumCircuit) – the quantum circuit with overlaid bounds. See also overlay_bounds_onto_circuit().

  • pauli_filter (Pauli | str | int | None) – the optional Pauli type by which the bounds were filtered. This will be indicated in the produced figure’s title.

  • kwargs – any additional keyword arguments are forwarded to QuantumCircuit.draw().

Returns:

The mpl figure.

Return type:

Figure