-
Notifications
You must be signed in to change notification settings - Fork 2
/
03_Qiskit2MPS.Rmd
82 lines (67 loc) · 1.6 KB
/
03_Qiskit2MPS.Rmd
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
jupyter:
jupytext:
formats: ipynb,Rmd
text_representation:
extension: .Rmd
format_name: rmarkdown
format_version: '1.2'
jupytext_version: 1.9.1
kernelspec:
display_name: Python 3
language: python
name: python3
---
```{python}
# Visualization
import matplotlib.pyplot as plt
from MPS_QFT.helper import print_state
# Numpy
import numpy as np
from numpy import linalg as LA
# importing Qiskit
from qiskit import QuantumCircuit, execute, Aer
from qiskit.circuit import library as lb
# %config InlineBackend.figure_format = 'svg' # Makes the images look nice
# Tensor networks
import quimb as quimb
from ncon import ncon
#gates
from MPS_QFT.gates import CPHASE, cphase_swap_qiskit, GATES
from MPS_QFT.circuit import qft_circuit_qiskit, circ_data, MPS_circ
```
```{python}
Gates = GATES()
# Dictionary of the gates
gates = Gates.gate_dict
```
```{python}
n_qub = 2
qc = QuantumCircuit(n_qub)
qc.h(0)
qc.cx(0, 1)
qft_circuit_qiskit(qc, n_qub)
#qc.draw('mpl')
```
```{python}
psi0 = MPS_circ(qc, gates)
psi0.graph(color=['cp', 'swap', 'h', 'psi0'], show_inds=True) #Plot the network
print_state(psi0.to_dense())
```
# Test quimb bond dimension
```{python}
n_qub = 2
qc = QuantumCircuit(n_qub)
qc.h(0)
qc.cx(0, 1)
qc.draw('mpl')
```
```{python}
psi0 = quimb.tensor.MPS_computational_state('00', tags = 'psi0')
psi0.gate_(gates['h'], 0, tags='h', max_bond=10, contract='split-gate')
psi0.gate_(gates['cx'], (0, 1), tags='cx', max_bond=1, contract='split-gate')
psi0.graph(color=['cx', 'h', 'psi0'], show_inds=True) #Plot the network
print_state(psi0.to_dense())
```
```{python}
```