Skip to main content
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. These can be accessed in the standard manner, exported, or shared with other components of the quantum experiment.
haiqu_circuit.core_metrics()Renders a widget that displays a table of core analytics metrics. This core analysis provides insights into the high-level structure of the quantum circuit.
haiqu_circuit.advanced_metrics()Renders a widget that displays a table with advanced quantum circuit metrics. The advanced analysis provides insights into critical components of the circuit, including connectivity, the depth of two-qubit interactions, the amount of entanglement present, and the circuit’s capacity to execute operations concurrently.
haiqu_circuit.evolutionProvides raw metrics data for the circuit evolution, as the circuit is traversed, represented as Python objects. These too can be accessed in the standard manner, exported, or shared with other components of the quantum experiment.
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, providing insights into changes in connectivity, depth of two-qubit interactions, degree of entanglement, and concurrent operation performance.
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.
# Standard setup: Connect to the Haiqu backend. Replace with your access 
# key and URL if running outside the Haiqu Lab environment. 
from haiqu.sdk import haiqu

haiqu.login() # Login setup 
haiqu.init("Analyze the circuit!") # Initialize the experiment

Step 1. Define and submit a quantum circuit

Haiqu SDK supports the Qiskit circuit and QASM formats.

1.1. Load a quantum circuit as a QASM file:

from qiskit import QuantumCircuit

# Replace 'qasm_circuit.qasm' with the actual filename
# qasm_file_path = "qasm_circuit.qasm"

# Load the QASM file into a QuantumCircuit
# circuit = QuantumCircuit.from_qasm_file(qasm_file_path)

# Optional: visualize the circuit
# circuit.draw("mpl")

1.2. Define a standard Qiskit circuit:

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 (shallow circuit with 1 layer)
    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)  # Optional: Visualize the circuit

1.3. Submit a circuit for analysis

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 a circuit for analysis with Haiqu quantum backend:
haiqu_circuit = haiqu.log(circuit)
The job for circuit analysis and computation of metrics requires a certain amount of time to complete. The duration depends on the depth of the original circuit and the number of qubits involved. The function wait_for_analytics() polls for a completed job and then loads the metrics into the local Haiqu circuit object.
haiqu_circuit.wait_for_analytics()

Step 2. Run 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:
haiqu_circuit.core_metrics(help=True)
The metrics computed in this step include:
  • The number of qubits in the original circuit.
  • The depth of the original circuit and the depth of the circuit normalized (transpiled) to basis gates.
  • The count of 1-qubit and 2-qubit gates for the normalized circuit.
  • The total number of gates.

Step 3. Run advanced analysis

Understanding the additional properties of a quantum circuit may be essential for predicting performance and optimizing execution. This step evaluates entanglement, circuit density, and qubit connectivity, which impact simulability, execution time, and hardware performance. By analyzing long-range interactions, gate expressivity, and parameterized structures, users can assess whether their circuit is well-structured for efficient computation and whether alternative implementations could improve performance. To display the advanced circuit metrics call:
haiqu_circuit.advanced_metrics(help=True)
The metrics computed in this step include:
  • Program communication: Evaluates qubit connectivity by computing the sum of interaction degrees in the circuit’s interaction graph.
  • Critical depth: Determines the depth of two-qubit interactions relative to their total count, assessing the circuit’s parallel execution potential.
  • Entangling Gates Ratio: Calculates the fraction of two-qubit gates in the circuit, which may impact the present entanglement.
  • Parallelism: Measures the circuit’s ability to execute operations simultaneously by comparing total gate count to circuit depth.
  • Liveness: Computes how often qubits are active during execution relative to total circuit depth, indicating qubit utilization.

Step 4. Other metric visualizations

4.1. Radar Plot

The Radar Plot aids visualizing and comparing circuit properties such as Program Communication, Critical Depth, Entangling Gates Ratio, Parallelism, and Liveness, providing an intuitive way to assess and contrast the performance trade-offs of different circuits.
haiqu_circuit.draw_radar(help=True)

4.2. Gate Diversity

The Gate Diversity chart visualizes the number and type of gates used in a quantum circuit. This metric is widely used in benchmarking, hardware-specific tuning, and noise-aware optimization. Haiqu SDK allows you to display either the original gate diversity or the normalized diversity (converted to a specified set of basis gates). When the option basis_gates is omitted it displays the gate diversity in the original instructions submitted by the user, when the option basis_gates is set to True it displays it transpiled to the RX, RY, RZ, CX basis.
haiqu_circuit.draw_gate_diversity(help=True)
haiqu_circuit.draw_gate_diversity(help=True, basis_gates=True)

4.3. Liveness per Qubit

The Liveness per Qubit plot indicates how frequently each qubit is active during the circuit execution, relative to the total circuit depth. This reflects qubit utilization and is particularly important because idle qubits are more susceptible to decoherence unless techniques like Dynamical Decoupling are applied.
haiqu_circuit.draw_liveness_per_qubit(help=True)

4.4. Matrix of correlations between qubits

Computes a normalized interaction matrix (heatmap) that quantifies how frequently each pair of qubits participates together in two-qubit gates within a given quantum circuit.
haiqu_circuit.draw_correlation_matrix(help=True)

4.5. “Evolution” of the circuit

Generate a plot showing the “evolution” of key circuit metrics, as the circuit is traversed. The original circuit is divided into slices. Metrics are calculated for each slice, providing insights into changes in connectivity, depth of two-qubit interactions, degree of entanglement, and concurrent operation performance.
haiqu_circuit.draw_evolution(help=True)