Benchmark: Dynamic Coupling (Quantum Hebbian Learning)
July 7, 2026 · View on GitHub
Module: scpn_quantum_control.qsnn.dynamic_coupling
Class: DynamicCouplingEngine
Overview
The Dynamic Coupling Engine implements quantum-classical co-evolution where a classical coupling matrix drives quantum XY Hamiltonian evolution, and quantum correlation measurements feed back to update via a Hebbian rule:
Each co-evolution step requires: Hamiltonian construction, sparse time evolution, correlation matrix measurement, and coupling update.
Rust Acceleration
The correlation measurement step uses correlation_matrix_xy from
scpn_quantum_engine when available, providing 2.9x speedup over the
pure NumPy/Qiskit path.
| Operation | Python (ms) | Rust (ms) | Speedup |
|---|---|---|---|
correlation_matrix_xy (4q) | 0.29 | 0.10 | 2.9x |
Co-evolution Step Timing
Each .step(dt) call performs one full loop: evolve + measure + update .
| System Size | Step Time | Notes |
|---|---|---|
| N=2 | <1 ms | Trivial 4x4 Hilbert space |
| N=4 | ~2 ms | Sparse evolution dominates |
| N=6 | ~8 ms | 64-dimensional Hilbert space |
| N=8 | ~35 ms | 256-dimensional, correlation matrix 8x8 |
Multi-step Co-evolution
run_coevolution(steps, dt) runs multiple steps and returns the full trajectory.
| Steps | N=4 Time | N=6 Time | N=8 Time |
|---|---|---|---|
| 10 | ~20 ms | ~80 ms | ~350 ms |
| 50 | ~100 ms | ~400 ms | ~1.8 s |
| 100 | ~200 ms | ~800 ms | ~3.5 s |
Physical Invariants (Verified by Tests)
- remains symmetric at every step
- (non-negative coupling)
- Diagonal (no self-coupling)
- Statevector normalised ()
- Correlation matrix symmetric ()
- Decay drives when learning rate is zero
Test Coverage
9 tests in tests/test_dynamic_coupling.py:
test_dynamic_coupling_engine_step— single step produces valid outputtest_run_coevolution— multi-step trajectory length and structuretest_k_symmetry_preserved— symmetry invariant across stepstest_correlation_matrix_symmetric—test_k_diagonal_stays_zero— no self-couplingtest_k_non_negative— coupling positivitytest_decay_drives_k_toward_zero— thermodynamic limittest_statevector_normalised— quantum state normalisationtest_rust_python_correlation_parity— Rust and Python paths agree
Running Benchmarks
pytest tests/test_dynamic_coupling.py -v -s
pytest tests/test_rust_path_benchmarks.py -k correlation_matrix -v -s