File size: 979 Bytes
6d8ed8c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
Example script for running ADAPT-AQC recompilation using a Matrix Product State (MPS) backend.
MPS is an alternative quantum state representation to state-vector, and is better suited to handle
large, low-entanglement states.
"""

import logging

from qiskit import QuantumCircuit

from adaptaqc.backends.aer_mps_backend import AerMPSBackend
from adaptaqc.compilers import AdaptCompiler

logging.basicConfig()
logger = logging.getLogger("adaptaqc")
logger.setLevel(logging.INFO)

# --------------------------------------------------------------------------------
# Very simple MPS example
# Create a large circuit where only some qubits are entangled
n = 50
qc = QuantumCircuit(n)
qc.h(0)
qc.cx(0, 1)
qc.h(2)
qc.cx(2, 3)
qc.h(range(4, n))

# Create compiler with the default MPS simulator, which has very minimal truncation.
adapt_compiler = AdaptCompiler(qc, backend=AerMPSBackend())

result = adapt_compiler.compile()
print(f"Overlap between circuits is {result.overlap}")