Behavioral Metrics (Execution Dynamics)

Behavioral Metrics implementation for QWARD.

This module provides the BehavioralMetrics class for analyzing quantum circuit execution patterns and behavioral characteristics from a static circuit analysis, including:

  • Normalized Depth: Circuit depth after transpilation to canonical gate set [1]

  • Program Communication: Communication requirements based on interaction graph [2]

  • Critical-Depth: Two-qubit operations on critical path analysis [2]

  • Measurement: Mid-circuit measurement and reset operations [2]

  • Liveness: Qubit activity patterns during execution [2]

  • Parallelism: Cross-talk susceptibility metric [2]

[1] T. Lubinski et al., “Application-Oriented Performance Benchmarks for Quantum Computing,” in IEEE Transactions on Quantum Engineering, vol. 4, pp. 1-32, 2023, Art no. 3100332, doi: 10.1109/TQE.2023.3253761.

[2] T. Tomesh, P. Gokhale, V. Omole, G. S. Ravi, K. N. Smith, J. Viszlai, X.-C. Wu, N. Hardavellas, M. R. Martonosi y F. T. Chong, “SupermarQ: A scalable quantum benchmark suite,” in Proc. 2022 IEEE International Symposium on High-Performance Computer Architecture (HPCA), 2022, doi: 10.1109/HPCA53966.2022.00050.

class BehavioralMetrics(circuit)[source]

Bases: MetricCalculator

Extract behavioral metrics from QuantumCircuit objects.

This class analyzes quantum circuits to compute behavioral metrics that describe how the circuit behaves as a computational process. Behavioral metrics capture dynamic characteristics such as parallelism potential, liveness of qubits across the circuit timeline, normalized depth measures, communication flow between qubits, and other indicators of execution dynamics derived from the circuit’s DAG representation.

circuit

The quantum circuit to analyze (inherited from MetricCalculator).

Type:

QuantumCircuit

_dag_circuit

DAG representation of the circuit, used to extract execution behavior, dependency structure, and parallelism characteristics.

Type:

DAGCircuit

Initialize the BehavioralMetrics calculator.

Parameters:

circuit (QuantumCircuit) – The quantum circuit to analyze

property circuit: QuantumCircuit

Get the quantum circuit.

Returns:

The quantum circuit

Return type:

QuantumCircuit

get_metrics()[source]

Calculate and return behavioral metrics.

Returns:

Validated schema with all metrics

Return type:

BehavioralMetricsSchema

Raises:

ImportError – If schemas are not available

property id: MetricsId

Get the ID of the metric.

Returns:

The ID of this metric

Return type:

MetricsId

is_ready()[source]

Check if the metric is ready to be calculated.

Returns:

True if the circuit is available, False otherwise

Return type:

bool

property metric_type: MetricsType

Get the type of this metric.

Returns:

The type of this metric

Return type:

MetricsType

property name: str

Get the name of the metric.

Returns:

The name of the metric class.

Return type:

str

Overview

The BehavioralMetrics module provides execution-oriented metrics derived from the static structure of a quantum circuit. Unlike structural or element metrics, which characterize complexity and gate composition, behavioral metrics aim to capture how the circuit behaves as a computational process.

These metrics approximate dynamic execution features without running the circuit, following methods from Lubinski et al. (2023) and Tomesh et al. (2022). The following behavioral dimensions are computed:

  1. Normalized Depth Depth of the circuit after transpilation to a canonical gate set {rx, ry, rz, cx}, normalized through basis unification.

  2. Program Communication Communication intensity derived from the interaction graph, reflecting how frequently qubits must exchange information (two-qubit operations).

  3. Critical-Depth Ratio of two-qubit operations on the DAG’s critical path to the total number of two-qubit operations, measuring how strongly entangling gates define execution time.

  4. Measurement Fraction of circuit layers involving measurement or reset operations, with emphasis on mid-circuit measurement.

  5. Liveness Ratio of active qubit-time slots across the circuit, estimating concurrency and qubit usage over time.

  6. Parallelism (Cross-Talk Susceptibility) A normalized metric derived from the ratio between gate count, depth, and qubit count, approximating susceptibility to cross-talk and parallel-execution density.

These metrics complement QWARD’s structural and element-level metrics by capturing temporal, interactive, and execution-critical behavior.

Autosummary

BehavioralMetrics(circuit)

Extract behavioral metrics from QuantumCircuit objects.

Selected Formulas

Normalized Depth Depth after transpilation to basis {rx, ry, rz, cx}.

Program Communication Based on interaction graph G: C = Σ d(qᵢ) / (N(N−1)) where d(qᵢ) is the degree of qubit i and N is the number of qubits.

Critical-Depth D = ned / ne where ned = two-qubit gates on the critical path, ne = total two-qubit gates.

Measurement Ratio M = l_mcm / d where l_mcm = layers containing measurement/reset, d = total layers (circuit depth).

Liveness L = Σ Aᵢⱼ / (n · d) where Aᵢⱼ = 1 if qubit i is active in layer j.

Parallelism P = (ng/d 1) / (n 1) where ng = number of gates excluding barrier/measure/reset.

Usage Example

from qiskit import QuantumCircuit
from qward.metrics import BehavioralMetrics

qc = QuantumCircuit(3)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()

metrics = BehavioralMetrics(qc).get_metrics()

print("Normalized Depth:", metrics.normalized_depth)
print("Program Communication:", metrics.program_communication)
print("Critical Depth:", metrics.critical_depth)
print("Liveness:", metrics.liveness)

Notes

  • All behavioral metrics are pre-runtime and require only static analysis.

  • Normalized depth depends on successful transpilation to the canonical basis.

  • Program communication and critical-depth are graph-theoretic and depend on the circuit’s DAG (Directed Acyclic Graph) representation.

  • Liveness ignores barrier operations, treating them as non-informative for execution activity.

  • Parallelism is clamped to the [0, 1] interval.

References

  • [1] T. Lubinski et al., “Application-Oriented Performance Benchmarks for

Quantum Computing,” in IEEE Transactions on Quantum Engineering, vol. 4, pp. 1-32, 2023, Art no. 3100332, doi: 10.1109/TQE.2023.3253761.

  • [2] T. Tomesh, P. Gokhale, V. Omole, G. S. Ravi, K. N. Smith, J. Viszlai,

X.-C. Wu, N. Hardavellas, M. R. Martonosi y F. T. Chong, “SupermarQ: A scalable quantum benchmark suite,” in Proc. 2022 IEEE International Symposium on High-Performance Computer Architecture (HPCA), 2022, doi: 10.1109/HPCA53966.2022.00050.