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 recomputation, call this method.
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 recomputation, call this method.
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 To use this function in a terminal or a script and get metrics as a dictionary, use it with the widget=False parameter:
haiqu_circuit.core_metrics(widget=False)

Advanced analytics

The advanced metrics are computed on demand; the computation is invoked when you call advanced_metrics() to display the advanced circuit metrics:
haiqu_circuit.advanced_metrics(help=True)
Light mode interface To use this function in a terminal or a script and get metrics as a dictionary, use it with the widget=False parameter:
haiqu_circuit.advanced_metrics(widget=False)
To get all metrics together, both core and advanced, call all_metrics function:
haiqu_circuit.all_metrics(widget=False)
If, for some reason, it is required to recompute advanced metrics, call:
compute_advanced_metrics()

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, call draw_evolution(metric) to render the plot. The optional metric parameter can be one of depth (default), gates_1q, gates_2q, or gates_total.
haiqu_circuit.draw_evolution(help=True)
Light mode interface If, for some reason, it is required to recompute evolution, call:
compute_evolution()

Comparing circuits

The function haiqu.compare_metrics shows a table with the core metrics of several circuits. This can be useful to understand the difference between the circuits or how a circuit changes with respect to a parameter.
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