emu-sv 2.4.0__py3-none-any.whl → 2.4.2__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 +1 -1
- emu_sv/dense_operator.py +2 -2
- emu_sv/state_vector.py +1 -1
- emu_sv/sv_backend_impl.py +9 -5
- emu_sv/sv_config.py +10 -3
- emu_sv/time_evolution.py +15 -4
- {emu_sv-2.4.0.dist-info → emu_sv-2.4.2.dist-info}/METADATA +2 -2
- emu_sv-2.4.2.dist-info/RECORD +15 -0
- emu_sv-2.4.0.dist-info/RECORD +0 -15
- {emu_sv-2.4.0.dist-info → emu_sv-2.4.2.dist-info}/WHEEL +0 -0
emu_sv/__init__.py
CHANGED
emu_sv/dense_operator.py
CHANGED
|
@@ -138,8 +138,8 @@ class DenseOperator(Operator[complex, torch.Tensor, StateVector]):
|
|
|
138
138
|
# and potentially user defined strings in terms of {r, g} or {0, 1}
|
|
139
139
|
operators_with_tensors |= {
|
|
140
140
|
"gg": torch.tensor([[1.0, 0.0], [0.0, 0.0]], dtype=dtype),
|
|
141
|
-
"
|
|
142
|
-
"
|
|
141
|
+
"rg": torch.tensor([[0.0, 0.0], [1.0, 0.0]], dtype=dtype),
|
|
142
|
+
"gr": torch.tensor([[0.0, 1.0], [0.0, 0.0]], dtype=dtype),
|
|
143
143
|
"rr": torch.tensor([[0.0, 0.0], [0.0, 1.0]], dtype=dtype),
|
|
144
144
|
}
|
|
145
145
|
elif set(eigenstates) == {"0", "1"}:
|
emu_sv/state_vector.py
CHANGED
|
@@ -275,7 +275,7 @@ class StateVector(State[complex, torch.Tensor]):
|
|
|
275
275
|
return accum_state, amplitudes
|
|
276
276
|
|
|
277
277
|
def overlap(self, other: StateVector, /) -> torch.Tensor:
|
|
278
|
-
return self.inner(other)
|
|
278
|
+
return torch.abs(self.inner(other)) ** 2
|
|
279
279
|
|
|
280
280
|
|
|
281
281
|
def inner(left: StateVector, right: StateVector) -> torch.Tensor:
|
emu_sv/sv_backend_impl.py
CHANGED
|
@@ -105,6 +105,11 @@ class BaseSVBackendImpl:
|
|
|
105
105
|
raise NotImplementedError(
|
|
106
106
|
"Initial state and state preparation error can not be together."
|
|
107
107
|
)
|
|
108
|
+
requested_gpu = self._config.gpu
|
|
109
|
+
if requested_gpu is None:
|
|
110
|
+
requested_gpu = True
|
|
111
|
+
|
|
112
|
+
self.resolved_gpu = requested_gpu
|
|
108
113
|
|
|
109
114
|
def init_dark_qubits(self) -> None:
|
|
110
115
|
if self._config.noise_model.state_prep_error > 0.0:
|
|
@@ -180,13 +185,12 @@ class SVBackendImpl(BaseSVBackendImpl):
|
|
|
180
185
|
pulser_data: The data for the sequence to be emulated.
|
|
181
186
|
"""
|
|
182
187
|
super().__init__(config, pulser_data)
|
|
183
|
-
|
|
184
188
|
self.state: StateVector = (
|
|
185
|
-
StateVector.make(self.nqubits, gpu=self.
|
|
189
|
+
StateVector.make(self.nqubits, gpu=self.resolved_gpu)
|
|
186
190
|
if self._config.initial_state is None
|
|
187
191
|
else StateVector(
|
|
188
192
|
self._config.initial_state.vector.clone(),
|
|
189
|
-
gpu=self.
|
|
193
|
+
gpu=self.resolved_gpu,
|
|
190
194
|
)
|
|
191
195
|
)
|
|
192
196
|
|
|
@@ -222,10 +226,10 @@ class NoisySVBackendImpl(BaseSVBackendImpl):
|
|
|
222
226
|
self.pulser_lindblads = pulser_data.lindblad_ops
|
|
223
227
|
|
|
224
228
|
self.state: DensityMatrix = (
|
|
225
|
-
DensityMatrix.make(self.nqubits, gpu=self.
|
|
229
|
+
DensityMatrix.make(self.nqubits, gpu=self.resolved_gpu)
|
|
226
230
|
if self._config.initial_state is None
|
|
227
231
|
else DensityMatrix(
|
|
228
|
-
self._config.initial_state.matrix.clone(), gpu=self.
|
|
232
|
+
self._config.initial_state.matrix.clone(), gpu=self.resolved_gpu
|
|
229
233
|
)
|
|
230
234
|
)
|
|
231
235
|
|
emu_sv/sv_config.py
CHANGED
|
@@ -6,6 +6,8 @@ from types import MethodType
|
|
|
6
6
|
from typing import Any, ClassVar
|
|
7
7
|
|
|
8
8
|
from emu_sv.utils import choose
|
|
9
|
+
from emu_sv.state_vector import StateVector
|
|
10
|
+
from emu_sv.dense_operator import DenseOperator
|
|
9
11
|
|
|
10
12
|
from emu_sv.custom_callback_implementations import (
|
|
11
13
|
qubit_occupation_sv_impl,
|
|
@@ -41,8 +43,11 @@ class SVConfig(EmulationConfig):
|
|
|
41
43
|
the size of the krylov subspace that the Lanczos algorithm maximally builds
|
|
42
44
|
krylov_tolerance:
|
|
43
45
|
the Lanczos algorithm uses this as the convergence tolerance
|
|
44
|
-
gpu:
|
|
45
|
-
|
|
46
|
+
gpu: choosing the number of gpus to use during the simulation
|
|
47
|
+
- if `gpu = True`, use 1 GPU to store the state.
|
|
48
|
+
(causes errors if True when GPU not available)
|
|
49
|
+
- if `gpu = False`, use CPU to run the entire simulation.
|
|
50
|
+
- if `gpu = None` (the default value), the backend internally chooses 1 GPU.
|
|
46
51
|
interaction_cutoff: Set interaction coefficients below this value to `0`.
|
|
47
52
|
Potentially improves runtime and memory consumption.
|
|
48
53
|
log_level: How much to log. Set to `logging.WARN` to get rid of the timestep info.
|
|
@@ -59,6 +64,8 @@ class SVConfig(EmulationConfig):
|
|
|
59
64
|
|
|
60
65
|
# Whether to warn if unexpected kwargs are received
|
|
61
66
|
_enforce_expected_kwargs: ClassVar[bool] = True
|
|
67
|
+
_state_type = StateVector
|
|
68
|
+
_operator_type = DenseOperator
|
|
62
69
|
|
|
63
70
|
def __init__(
|
|
64
71
|
self,
|
|
@@ -66,7 +73,7 @@ class SVConfig(EmulationConfig):
|
|
|
66
73
|
dt: int = 10,
|
|
67
74
|
max_krylov_dim: int = 100,
|
|
68
75
|
krylov_tolerance: float = 1e-10,
|
|
69
|
-
gpu: bool =
|
|
76
|
+
gpu: bool | None = None,
|
|
70
77
|
interaction_cutoff: float = 0.0,
|
|
71
78
|
log_level: int = logging.INFO,
|
|
72
79
|
log_file: pathlib.Path | None = None,
|
emu_sv/time_evolution.py
CHANGED
|
@@ -140,7 +140,10 @@ class EvolveStateVector(torch.autograd.Function):
|
|
|
140
140
|
interaction_matrix=interaction_matrix,
|
|
141
141
|
device=state.device,
|
|
142
142
|
)
|
|
143
|
-
|
|
143
|
+
|
|
144
|
+
def op(x: torch.Tensor) -> torch.Tensor:
|
|
145
|
+
return -1j * dt * (ham * x)
|
|
146
|
+
|
|
144
147
|
res = krylov_exp(
|
|
145
148
|
op,
|
|
146
149
|
state,
|
|
@@ -273,7 +276,10 @@ class EvolveStateVector(torch.autograd.Function):
|
|
|
273
276
|
)
|
|
274
277
|
|
|
275
278
|
if any(ctx.needs_input_grad[1:5]):
|
|
276
|
-
|
|
279
|
+
|
|
280
|
+
def op(x: torch.Tensor):
|
|
281
|
+
return -1j * dt * (ham * x)
|
|
282
|
+
|
|
277
283
|
lanczos_vectors_state, dS, lanczos_vectors_grad = double_krylov(
|
|
278
284
|
op, state, grad_state_out, tolerance
|
|
279
285
|
)
|
|
@@ -316,7 +322,10 @@ class EvolveStateVector(torch.autograd.Function):
|
|
|
316
322
|
grad_int_mat[i, j] = (-1j * dt * torch.tensordot(Vg.conj(), v)).real
|
|
317
323
|
|
|
318
324
|
if ctx.needs_input_grad[5]:
|
|
319
|
-
|
|
325
|
+
|
|
326
|
+
def op(x: torch.Tensor):
|
|
327
|
+
return (1j * dt) * (ham * x)
|
|
328
|
+
|
|
320
329
|
grad_state_in = krylov_exp(op, grad_state_out.detach(), tolerance, tolerance)
|
|
321
330
|
|
|
322
331
|
return (
|
|
@@ -353,7 +362,9 @@ class EvolveDensityMatrix:
|
|
|
353
362
|
device=density_matrix.device,
|
|
354
363
|
)
|
|
355
364
|
|
|
356
|
-
op
|
|
365
|
+
def op(x: torch.Tensor) -> torch.Tensor:
|
|
366
|
+
return -1j * dt * (ham @ x)
|
|
367
|
+
|
|
357
368
|
return (
|
|
358
369
|
krylov_exp(
|
|
359
370
|
op,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: emu-sv
|
|
3
|
-
Version: 2.4.
|
|
3
|
+
Version: 2.4.2
|
|
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.4.
|
|
28
|
+
Requires-Dist: emu-base==2.4.2
|
|
29
29
|
Description-Content-Type: text/markdown
|
|
30
30
|
|
|
31
31
|
<div align="center">
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
emu_sv/__init__.py,sha256=HmN1DY_0fQUrgBqa3eRVIqqSg1pg11_w4FwuwepfgV4,771
|
|
2
|
+
emu_sv/custom_callback_implementations.py,sha256=_7XLIDzJ-p3DVqz-Jyv0eYbl8nih2x2p-pM4cBCLumA,6367
|
|
3
|
+
emu_sv/dense_operator.py,sha256=GvF0swsiFRqp83bpyaU_CXap2vm74-JLI5lHo-0Hbdk,5901
|
|
4
|
+
emu_sv/density_matrix_state.py,sha256=6QmLZvqEHLR64r0nD7D2jZIiAYOgciNVCjh3ywfvIs0,7243
|
|
5
|
+
emu_sv/hamiltonian.py,sha256=CqNGuWJlO2ZljK47wt130s-5uKiOldQUsC3tjwk1mKA,6106
|
|
6
|
+
emu_sv/lindblad_operator.py,sha256=pgjRNLBcvEM2-qxM8uy9wL74OtrD4A8trQeERi_AXH8,8892
|
|
7
|
+
emu_sv/state_vector.py,sha256=Ookw_BDqzs9OFppQd7kaMxDSkaj5F_clhOCgo-LSaMg,9910
|
|
8
|
+
emu_sv/sv_backend.py,sha256=-soOkSEzEBK1dCKnYnbtvYjmNZtZra1_4jP3H1ROOtM,737
|
|
9
|
+
emu_sv/sv_backend_impl.py,sha256=-xWE30B5RI32nOG2pUR8lL3q-wufwvzxegiJexW5g4w,8952
|
|
10
|
+
emu_sv/sv_config.py,sha256=xgKyEPOGzqM-jC_xJ5VYJak4CNntbp2wywbdYqCGEoM,6318
|
|
11
|
+
emu_sv/time_evolution.py,sha256=Uy3qMdt3BlLB6Aq1-o5uajRTu_3fPuBCtcusHxFPPJc,13545
|
|
12
|
+
emu_sv/utils.py,sha256=t0nMDVo6DF5bQW-vbsyRMCmvkyNxCU-v0Enmns9aOAU,1151
|
|
13
|
+
emu_sv-2.4.2.dist-info/METADATA,sha256=RuXcAiQTi84jywPv_UkYs5OVJ0QQAGap55xNEgVSlvY,3595
|
|
14
|
+
emu_sv-2.4.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
15
|
+
emu_sv-2.4.2.dist-info/RECORD,,
|
emu_sv-2.4.0.dist-info/RECORD
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
emu_sv/__init__.py,sha256=Oc9_UlpE7Nioggmg-pX4_8iQnh7_o9jl8n_wBTu5NJg,771
|
|
2
|
-
emu_sv/custom_callback_implementations.py,sha256=_7XLIDzJ-p3DVqz-Jyv0eYbl8nih2x2p-pM4cBCLumA,6367
|
|
3
|
-
emu_sv/dense_operator.py,sha256=AvgntJNwwtf3Wl66CIWSwUezVYV3vignCL24SQQQwQg,5901
|
|
4
|
-
emu_sv/density_matrix_state.py,sha256=6QmLZvqEHLR64r0nD7D2jZIiAYOgciNVCjh3ywfvIs0,7243
|
|
5
|
-
emu_sv/hamiltonian.py,sha256=CqNGuWJlO2ZljK47wt130s-5uKiOldQUsC3tjwk1mKA,6106
|
|
6
|
-
emu_sv/lindblad_operator.py,sha256=pgjRNLBcvEM2-qxM8uy9wL74OtrD4A8trQeERi_AXH8,8892
|
|
7
|
-
emu_sv/state_vector.py,sha256=dkAnxEQxK-4Fn6UxhDbcb1z1EsHFUpOyVy0mjHkKFBI,9894
|
|
8
|
-
emu_sv/sv_backend.py,sha256=-soOkSEzEBK1dCKnYnbtvYjmNZtZra1_4jP3H1ROOtM,737
|
|
9
|
-
emu_sv/sv_backend_impl.py,sha256=OYsJK_DJ8dmq3QZLKiBejXrq22R5Auyye-pai07NeeY,8798
|
|
10
|
-
emu_sv/sv_config.py,sha256=J4yb9-Na5hAbShDySzPfbt0WXvL8JpfrTEikTK8nH9s,5943
|
|
11
|
-
emu_sv/time_evolution.py,sha256=_VH4f2RF6lGKzO08WxTYJ5Aw8_pTTMRKcyMnIuxH03I,13382
|
|
12
|
-
emu_sv/utils.py,sha256=t0nMDVo6DF5bQW-vbsyRMCmvkyNxCU-v0Enmns9aOAU,1151
|
|
13
|
-
emu_sv-2.4.0.dist-info/METADATA,sha256=HKTJmI_Ra3dcFw2QthE2TEvEiYcvcZmrHkrFMuGY794,3595
|
|
14
|
-
emu_sv-2.4.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
15
|
-
emu_sv-2.4.0.dist-info/RECORD,,
|
|
File without changes
|