Spaces:
Sleeping
Sleeping
Download utils/adapt-aqc/examples/simple_mps_example.py from ansysresearch/quantum: direct link, hf CLI and curl.
- Browser
- Download file 979 Bytes
-
https://huggingface.co/spaces/ansysresearch/quantum/resolve/main/utils/adapt-aqc/examples/simple_mps_example.py
- Command line
-
hf download hf://spaces/ansysresearch/quantum/utils/adapt-aqc/examples/simple_mps_example.py
-
curl -L -o simple_mps_example.py https://huggingface.co/spaces/ansysresearch/quantum/resolve/main/utils/adapt-aqc/examples/simple_mps_example.py
979 Bytes
| """ | |
| 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}") | |