emu-sv 2.0.1__py3-none-any.whl → 2.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
emu_sv/__init__.py
CHANGED
emu_sv/hamiltonian.py
CHANGED
|
@@ -50,10 +50,7 @@ class RydbergHamiltonian:
|
|
|
50
50
|
|
|
51
51
|
self.diag: torch.Tensor = self._create_diagonal()
|
|
52
52
|
self.inds = torch.tensor([1, 0], device=self.device) # flips the state, for σˣ
|
|
53
|
-
|
|
54
|
-
self._apply_sigma_operators = self._apply_sigma_operators_real
|
|
55
|
-
if self.phis.any():
|
|
56
|
-
self._apply_sigma_operators = self._apply_sigma_operators_complex
|
|
53
|
+
self.complex = self.phis.any()
|
|
57
54
|
|
|
58
55
|
def __mul__(self, vec: torch.Tensor) -> torch.Tensor:
|
|
59
56
|
"""
|
|
@@ -73,7 +70,10 @@ class RydbergHamiltonian:
|
|
|
73
70
|
# (-∑ⱼΔⱼnⱼ + ∑ᵢ﹥ⱼUᵢⱼnᵢnⱼ)|ψ❭
|
|
74
71
|
result = self.diag * vec
|
|
75
72
|
# ∑ⱼΩⱼ/2[cos(ϕⱼ)σˣⱼ + sin(ϕⱼ)σʸⱼ]|ψ❭
|
|
76
|
-
self.
|
|
73
|
+
if self.complex:
|
|
74
|
+
self._apply_sigma_operators_complex(result, vec)
|
|
75
|
+
else:
|
|
76
|
+
self._apply_sigma_operators_real(result, vec)
|
|
77
77
|
return result
|
|
78
78
|
|
|
79
79
|
def _apply_sigma_operators_real(
|
emu_sv/state_vector.py
CHANGED
|
@@ -36,6 +36,7 @@ class StateVector(State[complex, torch.Tensor]):
|
|
|
36
36
|
vector: torch.Tensor,
|
|
37
37
|
*,
|
|
38
38
|
gpu: bool = True,
|
|
39
|
+
eigenstates: Sequence[Eigenstate] = ("r", "g"),
|
|
39
40
|
):
|
|
40
41
|
# NOTE: this accepts also zero vectors.
|
|
41
42
|
|
|
@@ -43,6 +44,7 @@ class StateVector(State[complex, torch.Tensor]):
|
|
|
43
44
|
len(vector)
|
|
44
45
|
).is_integer(), "The number of elements in the vector should be power of 2"
|
|
45
46
|
|
|
47
|
+
super().__init__(eigenstates=eigenstates)
|
|
46
48
|
device = "cuda" if gpu and DEVICE_COUNT > 0 else "cpu"
|
|
47
49
|
self.vector = vector.to(dtype=dtype, device=device)
|
|
48
50
|
|
|
@@ -68,7 +70,12 @@ class StateVector(State[complex, torch.Tensor]):
|
|
|
68
70
|
self.vector = self.vector / norm
|
|
69
71
|
|
|
70
72
|
@classmethod
|
|
71
|
-
def zero(
|
|
73
|
+
def zero(
|
|
74
|
+
cls,
|
|
75
|
+
num_sites: int,
|
|
76
|
+
gpu: bool = True,
|
|
77
|
+
eigenstates: Sequence[Eigenstate] = ("r", "g"),
|
|
78
|
+
) -> StateVector:
|
|
72
79
|
"""
|
|
73
80
|
Returns a zero uninitialized "state" vector. Warning, this has no physical meaning as-is!
|
|
74
81
|
|
|
@@ -86,7 +93,7 @@ class StateVector(State[complex, torch.Tensor]):
|
|
|
86
93
|
|
|
87
94
|
device = "cuda" if gpu and DEVICE_COUNT > 0 else "cpu"
|
|
88
95
|
vector = torch.zeros(2**num_sites, dtype=dtype, device=device)
|
|
89
|
-
return cls(vector, gpu=gpu)
|
|
96
|
+
return cls(vector, gpu=gpu, eigenstates=eigenstates)
|
|
90
97
|
|
|
91
98
|
@classmethod
|
|
92
99
|
def make(cls, num_sites: int, gpu: bool = True) -> StateVector:
|
|
@@ -172,7 +179,14 @@ class StateVector(State[complex, torch.Tensor]):
|
|
|
172
179
|
The summed state
|
|
173
180
|
"""
|
|
174
181
|
assert isinstance(other, StateVector), "`Other` state can only be a StateVector"
|
|
175
|
-
|
|
182
|
+
assert (
|
|
183
|
+
self.eigenstates == other.eigenstates
|
|
184
|
+
), f"`Other` state has basis {other.eigenstates} != {self.eigenstates}"
|
|
185
|
+
return StateVector(
|
|
186
|
+
self.vector + other.vector,
|
|
187
|
+
gpu=self.vector.is_cuda,
|
|
188
|
+
eigenstates=self.eigenstates,
|
|
189
|
+
)
|
|
176
190
|
|
|
177
191
|
def __rmul__(self, scalar: complex) -> StateVector:
|
|
178
192
|
"""Scalar multiplication
|
|
@@ -183,7 +197,11 @@ class StateVector(State[complex, torch.Tensor]):
|
|
|
183
197
|
Returns:
|
|
184
198
|
The scaled state
|
|
185
199
|
"""
|
|
186
|
-
return StateVector(
|
|
200
|
+
return StateVector(
|
|
201
|
+
scalar * self.vector,
|
|
202
|
+
gpu=self.vector.is_cuda,
|
|
203
|
+
eigenstates=self.eigenstates,
|
|
204
|
+
)
|
|
187
205
|
|
|
188
206
|
def norm(self) -> torch.Tensor:
|
|
189
207
|
"""Returns the norm of the state
|
|
@@ -229,9 +247,6 @@ class StateVector(State[complex, torch.Tensor]):
|
|
|
229
247
|
tensor([0.7071+0.j, 0.0000+0.j, 0.0000+0.j, 0.7071+0.j],
|
|
230
248
|
dtype=torch.complex128)
|
|
231
249
|
"""
|
|
232
|
-
|
|
233
|
-
# nqubits = len(next(iter(amplitudes.keys())))
|
|
234
|
-
nqubits = cls._validate_amplitudes(amplitudes=amplitudes, eigenstates=eigenstates)
|
|
235
250
|
basis = set(eigenstates)
|
|
236
251
|
if basis == {"r", "g"}:
|
|
237
252
|
one = "r"
|
|
@@ -242,7 +257,8 @@ class StateVector(State[complex, torch.Tensor]):
|
|
|
242
257
|
else:
|
|
243
258
|
raise ValueError("Unsupported basis provided")
|
|
244
259
|
|
|
245
|
-
|
|
260
|
+
nqubits = cls._validate_amplitudes(amplitudes=amplitudes, eigenstates=eigenstates)
|
|
261
|
+
accum_state = StateVector.zero(num_sites=nqubits, eigenstates=eigenstates)
|
|
246
262
|
|
|
247
263
|
for state, amplitude in amplitudes.items():
|
|
248
264
|
bin_to_int = int(
|
emu_sv/sv_backend.py
CHANGED
|
@@ -12,7 +12,7 @@ from emu_sv.sv_config import SVConfig
|
|
|
12
12
|
from emu_sv.time_evolution import do_time_step
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
_TIME_CONVERSION_COEFF = 0.001 # Omega and delta are given in rad
|
|
15
|
+
_TIME_CONVERSION_COEFF = 0.001 # Omega and delta are given in rad/μs, dt in ns
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class SVBackend(EmulatorBackend):
|
|
@@ -90,6 +90,7 @@ class SVBackend(EmulatorBackend):
|
|
|
90
90
|
self.results,
|
|
91
91
|
)
|
|
92
92
|
self.time = time.time()
|
|
93
|
+
del H
|
|
93
94
|
|
|
94
95
|
return self.results
|
|
95
96
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: emu-sv
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.3
|
|
4
4
|
Summary: Pasqal State Vector based pulse emulator built on PyTorch
|
|
5
5
|
Project-URL: Documentation, https://pasqal-io.github.io/emulators/
|
|
6
6
|
Project-URL: Repository, https://github.com/pasqal-io/emulators
|
|
@@ -25,7 +25,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
25
25
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
26
26
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
27
27
|
Requires-Python: >=3.10
|
|
28
|
-
Requires-Dist: emu-base==2.0.
|
|
28
|
+
Requires-Dist: emu-base==2.0.3
|
|
29
29
|
Description-Content-Type: text/markdown
|
|
30
30
|
|
|
31
31
|
<div align="center">
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
emu_sv/__init__.py,sha256=
|
|
1
|
+
emu_sv/__init__.py,sha256=6ijDylrpDM3KZkI1hvmsh_uUAOKowLmjvxaE7wrAmOY,701
|
|
2
2
|
emu_sv/custom_callback_implementations.py,sha256=zvsSiDIc56gwybKq87VFZyKsniTDye6-oFd2-R0shpg,3447
|
|
3
3
|
emu_sv/dense_operator.py,sha256=NfgzVpnNitc5ZSM4RlfpAc5Ls2wFPNsTxdeFdhJSg1o,6909
|
|
4
4
|
emu_sv/density_matrix_state.py,sha256=6UBLUXaJaUdzOhflrKolcnH8737JszX7sry1WmbyakI,6993
|
|
5
|
-
emu_sv/hamiltonian.py,sha256=
|
|
6
|
-
emu_sv/state_vector.py,sha256=
|
|
7
|
-
emu_sv/sv_backend.py,sha256=
|
|
5
|
+
emu_sv/hamiltonian.py,sha256=veJlJh_Q2_Fgc0IIfKPSWb6n_oem5WWGQUGDeepl924,6138
|
|
6
|
+
emu_sv/state_vector.py,sha256=lqSbv4BMtDtgY0YUPuhIUNJxrlVa7vUWuN_XqwpG5sQ,9823
|
|
7
|
+
emu_sv/sv_backend.py,sha256=AkEtI6-SY20D0ORro3Kv8tHDRUc8gxejSiRa6d--vBE,4452
|
|
8
8
|
emu_sv/sv_config.py,sha256=QRy0VbCugmY6TQZ48nD6RxPJbpu0wzN7-E1Sud7YxLQ,5106
|
|
9
9
|
emu_sv/time_evolution.py,sha256=48C0DL_SOu7Jdjk2QKBNPsevOpQlgsPYUHE7cScY-ZM,796
|
|
10
10
|
emu_sv/utils.py,sha256=-axfQ2tqw0C7I9yw-28g7lytyk373DNBjDALh4kLBrM,302
|
|
11
|
-
emu_sv-2.0.
|
|
12
|
-
emu_sv-2.0.
|
|
13
|
-
emu_sv-2.0.
|
|
11
|
+
emu_sv-2.0.3.dist-info/METADATA,sha256=BYetdN_TW7rMls-VeLMSObauvcKONqh8an0FZqouJfw,3513
|
|
12
|
+
emu_sv-2.0.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
13
|
+
emu_sv-2.0.3.dist-info/RECORD,,
|
|
File without changes
|