Module: scpn_quantum_control.phase.structured_ansatz
Function: build_structured_ansatz
The structured ansatz constructs topology-informed variational quantum circuits. Instead of generic two-local entanglement, it places entangling gates exclusively between qubit pairs with non-zero coupling in the physical Hamiltonian. This produces fewer parameters and better VQE convergence.
| System Size | Reps | Parameters | Entangling Gates | Build Time |
|---|---|---|---|---|
| L=2 | 2 | 8 | 2 (1 per rep) | <0.1 ms |
| L=4 | 2 | 16 | varies by topology | <0.1 ms |
| L=8 | 2 | 32 | varies by topology | <0.1 ms |
| L=16 | 1 | 32 | varies by topology | <0.1 ms |
For a 3-qubit system with ring coupling (
| Ansatz | Parameters | VQE Energy (100 iter) | Gate Count |
|---|---|---|---|
build_structured_ansatz (Knm-informed) |
12 | 9 (3 CZ) | |
qiskit.circuit.library.TwoLocal (full) |
18 | 12 (6 CZ) |
The Knm-informed ansatz achieves 19% lower energy with 33% fewer parameters by exploiting the physical coupling topology.
The ansatz adapts to coupling sparsity:
| Coupling Topology | Edges (4q) | CZ Gates/Rep | Parameters/Rep |
|---|---|---|---|
| Ring ( |
4 | 4 | 8 |
| Full ( |
6 | 6 | 8 |
| Star ( |
3 | 3 | 8 |
| Sparse (threshold filtered) | varies | varies | 8 |
Single-qubit rotation count is fixed at
- Coupling matrix symmetrised before use (
$K \to (K + K^T)/2$ ) - Threshold filtering respects absolute values
- Empty graph (all below threshold) produces rotation-only circuit
- Full graph matches generic
TwoLocalstructure - Parameter count:
$2n \times \text{reps}$ (single-qubit only) - Custom entanglement gates (
cz,cx) applied correctly
11 tests in tests/test_structured_ansatz.py:
test_build_empty_graph— sub-threshold coupling produces no entanglementtest_build_full_graph— fully connected couplingtest_custom_entanglement_gate— CX vs CZ selectiontest_invalid_coupling_matrix— non-square matrix rejectiontest_invalid_entanglement_gate— unknown gate rejectiontest_parameter_count— correct parametrisationtest_threshold_boundary— exact-threshold coupling inclusiontest_below_threshold_excluded— sub-threshold filteringtest_asymmetric_matrix_symmetrised— automatic symmetrisationtest_multiple_reps_gate_count— gate scaling with reps- Additional edge-case tests
pytest tests/test_structured_ansatz.py -v -s
pytest tests/test_ansatz_bench.py -v -s