Skip to main content
Quantum circuit analysis is important for understanding the structure, complexity, and feasibility of executing a circuit on quantum hardware or simulators. It helps to identify key properties such as gate composition, depth, connectivity, and noise susceptibility, which impact performance and accuracy. Haiqu SDK provides a number of analytics functions, properties and widgets:
Property or FunctionDescription
haiqu_circuit.analyticsProvides ALL raw metrics data, represented as Python objects.
haiqu_circuit.core_metrics()Renders a widget that displays a table of core analytics metrics.
haiqu_circuit.compare_metrics()Renders a widget with a comparison table of core analytics for provided circuits.
haiqu_circuit.compute_advanced_metrics()The advanced metrics are computed on demand, to invoke the computation, call this method first.
haiqu_circuit.advanced_metrics()Renders a widget that displays a table with advanced quantum circuit metrics.
haiqu_circuit.compute_evolution()The circuit evolution data are computed on demand, to invoke the computation, call this method first.
haiqu_circuit.evolutionProvides raw metrics data for the circuit, as the circuit is traversed, represented as Python objects.
haiqu_circuit.draw_evolution()Generates a plot showing the evolution of key circuit metrics as the circuit is traversed. The original circuit is divided gate-by-gate or into slices, based on the initial depth. Metrics are calculated for each slice.
haiqu_circuit.draw_radar()Renders a widget displaying the radar (wind-rose) plot.
haiqu_circuit.draw_gate_diversity()Renders a widget showing the number of different gates in the circuit. It has two modes: original and normalized to basis gates. The basis_gates=True option will display the normalized (transpiled to basis gates set RX, RY, RZ and CX) view for gate diversity.
haiqu_circuit.draw_liveness_per_qubit()Renders a widget displaying the liveness per qubit plot. The liveness metric reveal the frequency of qubit activity during execution in relation to the total circuit depth, indicating qubit utilization.
haiqu_circuit.draw_correlation_matrix()Renders a normalized interaction matrix (heatmap) that quantifies how frequently each pair of qubits participates together in two-qubit gates within a given quantum circuit.
Each analytics widget includes built-in help for the displayed metrics, turned on with help=True option. Whenever possible, the widget displays a column to provide assistance for each metric. Data can be exported in formats including JSON, CSV, or used in Pandas for further analysis. Let’s start by defining an example quantum circuit, then display it:
from qiskit.circuit.random import random_circuit

# Generate a random quantum circuit with the following parameters:
circuit = random_circuit(
    num_qubits=16,   # Total number of qubits in the circuit (16-qubit system)
    depth=4,         # The number of gate layers applied
    max_operands=4,  # Maximum number of qubits any multi-qubit gate can act on
    seed=42,         # Random seed for reproducibility (ensures same circuit structure on each run)
    measure=False    # Do not include measurement operations at the end of the circuit
)

# Assign a name to the circuit for easy identification
circuit.name = "Haiqu 16-qubit hello world"

# Display the generated circuit
haiqu.draw(circuit)
Light mode interface To utilize the analytics functions invoke the haiqu.log() method. This computes the complete set of quantum metrics using the Haiqu API and returns them in a single metadata object. Let’s submit our circuit to the Haiqu quantum backend for analysis:
haiqu_circuit = haiqu.log(circuit)

Basic analysis

Before executing a quantum circuit, it is crucial to assess its fundamental properties to ensure feasibility and compatibility with available simulators or hardware. This step helps determine circuit size, gate composition, and whether it contains custom or unsupported operations. By analyzing these factors, users can make informed decisions about device selection, potential optimizations, and whether additional modifications are needed before execution. The circuit’s basic metrics are displayed using core_metrics:
haiqu_circuit.core_metrics(help=True)
Light mode interface

Advanced analytics

The advanced metrics are computed on demand; to invoke the computation, call compute_advanced_metrics() first. Then, to display the advanced circuit metrics, call advanced_metrics():
haiqu_circuit.compute_advanced_metrics()
haiqu_circuit.advanced_metrics(help=True)
Light mode interface

Evolution of the circuit

Generate a plot showing the evolution of key circuit metrics during simulated execution of the circuit. The original circuit is divided into slices, and metrics are calculated for each slice, providing insights into changes in connectivity, depth of two-qubit interactions, degree of entanglement, and concurrent operation performance. The evolution of metrics is computed on demand; to invoke the computation, call compute_evolution() first. Then call draw_evolution(metric) to render the plot. The metric parameter set according to which metric to plot the evolution. Possible values are depth, gates_1q, gates_2q, gates_total. Defaults to depth.
haiqu_circuit.compute_evolution()
haiqu_circuit.draw_evolution(help=True)
Light mode interface

Comparing circuits

The function haiqu.compare_metrics could be useful for comparing the different circuits or the circuit built with different parameters. It could compare up to N different circuit and provide a table-like widget.
haiqu.compare_metrics(circuit1, circuit2, ...)
For instance, the following example compares two circuits obtained as a transpilation of the same initial circuit but with different options:
transpiled_circuit_opt0 = haiqu.transpile(circuit, device, optimization_level=0)
transpiled_circuit_opt3 = haiqu.transpile(circuit, device, optimization_level=3)
haiqu.compare_metrics(transpiled_circuit_opt0, transpiled_circuit_opt3)
Light mode interface For practical examples of Circuit Analytics explore Circuit-Analytics.ipynb notebook in Haiqu Lab.