emu-sv 1.0.0__py3-none-any.whl → 1.0.1__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
@@ -39,4 +39,4 @@ __all__ = [
39
39
  ]
40
40
 
41
41
 
42
- __version__ = "1.0.0"
42
+ __version__ = "1.0.1"
emu_sv/hamiltonian.py CHANGED
@@ -71,15 +71,14 @@ class RydbergHamiltonian:
71
71
  the resulting state vector.
72
72
  """
73
73
  # (-∑ⱼΔⱼnⱼ + ∑ᵢ﹥ⱼUᵢⱼnᵢnⱼ)|ψ❭
74
- diag_result = self.diag * vec
74
+ result = self.diag * vec
75
75
  # ∑ⱼΩⱼ/2[cos(ϕⱼ)σˣⱼ + sin(ϕⱼ)σʸⱼ]|ψ❭
76
- sigma_result = self._apply_sigma_operators(vec)
77
- result: torch.Tensor
78
- result = diag_result + sigma_result
79
-
76
+ self._apply_sigma_operators(result, vec)
80
77
  return result
81
78
 
82
- def _apply_sigma_operators_real(self, vec: torch.Tensor) -> torch.Tensor:
79
+ def _apply_sigma_operators_real(
80
+ self, result: torch.Tensor, vec: torch.Tensor
81
+ ) -> None:
83
82
  """
84
83
  Apply the ∑ⱼ(Ωⱼ/2)σˣⱼ operator to the input vector |ψ❭.
85
84
 
@@ -89,8 +88,6 @@ class RydbergHamiltonian:
89
88
  Returns:
90
89
  the resulting state vector.
91
90
  """
92
- result = torch.zeros_like(vec)
93
-
94
91
  dim_to_act = 1
95
92
  for n, omega_n in enumerate(self.omegas):
96
93
  shape_n = (2**n, 2, 2 ** (self.nqubits - n - 1))
@@ -98,9 +95,9 @@ class RydbergHamiltonian:
98
95
  result = result.reshape(shape_n)
99
96
  result.index_add_(dim_to_act, self.inds, vec, alpha=omega_n)
100
97
 
101
- return result.reshape(-1)
102
-
103
- def _apply_sigma_operators_complex(self, vec: torch.Tensor) -> torch.Tensor:
98
+ def _apply_sigma_operators_complex(
99
+ self, result: torch.Tensor, vec: torch.Tensor
100
+ ) -> None:
104
101
  """
105
102
  Apply the ∑ⱼΩⱼ/2[cos(ϕⱼ)σˣⱼ + sin(ϕⱼ)σʸⱼ] operator to the input vector |ψ❭.
106
103
 
@@ -111,7 +108,6 @@ class RydbergHamiltonian:
111
108
  the resulting state vector.
112
109
  """
113
110
  c_omegas = self.omegas * torch.exp(1j * self.phis)
114
- result = torch.zeros_like(vec)
115
111
 
116
112
  dim_to_act = 1
117
113
  for n, c_omega_n in enumerate(c_omegas):
@@ -128,8 +124,6 @@ class RydbergHamiltonian:
128
124
  alpha=c_omega_n.conj(),
129
125
  )
130
126
 
131
- return result.reshape(-1)
132
-
133
127
  def _create_diagonal(self) -> torch.Tensor:
134
128
  """
135
129
  Return the diagonal elements of the Rydberg Hamiltonian matrix
emu_sv/state_vector.py CHANGED
@@ -127,7 +127,6 @@ class StateVector(State):
127
127
  """
128
128
 
129
129
  probabilities = torch.abs(self.vector) ** 2
130
- probabilities /= probabilities.sum() # multinomial does not normalize the input
131
130
 
132
131
  outcomes = torch.multinomial(probabilities, num_shots, replacement=True)
133
132
 
emu_sv/sv_backend.py CHANGED
@@ -9,6 +9,9 @@ import torch
9
9
  from time import time
10
10
  from resource import RUSAGE_SELF, getrusage
11
11
  from emu_base import DEVICE_COUNT
12
+ from copy import deepcopy
13
+
14
+ _TIME_CONVERSION_COEFF = 0.001 # Omega and delta are given in rad/ms, dt in ns
12
15
 
13
16
 
14
17
  class SVBackend(Backend):
@@ -36,24 +39,24 @@ class SVBackend(Backend):
36
39
  data = PulserData(sequence=sequence, config=sv_config, dt=sv_config.dt)
37
40
  omega, delta, phi = data.omega, data.delta, data.phi
38
41
 
42
+ target_times = data.target_times
43
+
39
44
  nsteps = omega.shape[0]
40
45
  nqubits = omega.shape[1]
41
46
  device = "cuda" if sv_config.gpu and DEVICE_COUNT > 0 else "cpu"
42
47
 
43
48
  if sv_config.initial_state is not None:
44
- state = sv_config.initial_state
49
+ state = deepcopy(sv_config.initial_state)
45
50
  state.vector = state.vector.to(device)
46
51
  else:
47
52
  state = StateVector.make(nqubits, gpu=sv_config.gpu)
48
53
 
49
- dt = sv_config.dt * 1e-3 # ns to µs
50
-
51
54
  for step in range(nsteps):
52
-
53
55
  start = time()
56
+ dt = target_times[step + 1] - target_times[step]
54
57
 
55
58
  state.vector, H = do_time_step(
56
- dt,
59
+ dt * _TIME_CONVERSION_COEFF,
57
60
  omega[step],
58
61
  delta[step],
59
62
  phi[step],
@@ -65,7 +68,7 @@ class SVBackend(Backend):
65
68
  for callback in sv_config.callbacks:
66
69
  callback(
67
70
  sv_config,
68
- (step + 1) * sv_config.dt,
71
+ target_times[step + 1],
69
72
  state,
70
73
  H, # type: ignore[arg-type]
71
74
  results,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: emu-sv
3
- Version: 1.0.0
3
+ Version: 1.0.1
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==1.2.6
28
+ Requires-Dist: emu-base==1.2.7
29
29
  Description-Content-Type: text/markdown
30
30
 
31
31
  <div align="center">
@@ -0,0 +1,11 @@
1
+ emu_sv/__init__.py,sha256=rcIsdgWgk5n75z0fSQtQsVgrFs_5jtA52WwGsTxDgAs,845
2
+ emu_sv/custom_callback_implementations.py,sha256=H7fy0trUtY00wid6VeRJ2inUazFbkMlgavTfm8QtGq8,2754
3
+ emu_sv/dense_operator.py,sha256=69rv1J5jsHSRoPsgZqKJZnttCgMLIk4tDCBsOaOBVR8,7034
4
+ emu_sv/hamiltonian.py,sha256=Rg_tLGTgaL4Y8xWtO1P2axRQNrdKfHRnHwnv_BfZTEI,6091
5
+ emu_sv/state_vector.py,sha256=s26ktVkuBID9IU6ySMup8ci7M5Tn6HHCT4jcyZGxV_w,8036
6
+ emu_sv/sv_backend.py,sha256=lIi_aTyfW-pzrfxwJHSoF5klwJnWtLv3awwU4DSL4m4,3770
7
+ emu_sv/sv_config.py,sha256=NUAxqYG0NTWbarVreFr1Tb-8FzB0LVQ0fYnb2QSCzxo,3161
8
+ emu_sv/time_evolution.py,sha256=48C0DL_SOu7Jdjk2QKBNPsevOpQlgsPYUHE7cScY-ZM,796
9
+ emu_sv-1.0.1.dist-info/METADATA,sha256=hNCpmCxzB_i_ciIRzqebQ9seyPhp8F0DiuceBYG4T7k,3513
10
+ emu_sv-1.0.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
11
+ emu_sv-1.0.1.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- emu_sv/__init__.py,sha256=Ji7PePRQka8XrVMw3N3i2k_sBwMQIj6LBOZFGZ0HNvs,845
2
- emu_sv/custom_callback_implementations.py,sha256=H7fy0trUtY00wid6VeRJ2inUazFbkMlgavTfm8QtGq8,2754
3
- emu_sv/dense_operator.py,sha256=69rv1J5jsHSRoPsgZqKJZnttCgMLIk4tDCBsOaOBVR8,7034
4
- emu_sv/hamiltonian.py,sha256=uzR7XHsv0QXBbcNuk93-phrO-On-WfJCINWz7Zofc90,6270
5
- emu_sv/state_vector.py,sha256=XsbHDNu6LDBop_qVVUoaw8blVPOystP8MOQ9demME6g,8125
6
- emu_sv/sv_backend.py,sha256=cghNpJq8ALdcoHCnx0xHcZBM9x8URLRFo0_sZ5CXXvY,3576
7
- emu_sv/sv_config.py,sha256=NUAxqYG0NTWbarVreFr1Tb-8FzB0LVQ0fYnb2QSCzxo,3161
8
- emu_sv/time_evolution.py,sha256=48C0DL_SOu7Jdjk2QKBNPsevOpQlgsPYUHE7cScY-ZM,796
9
- emu_sv-1.0.0.dist-info/METADATA,sha256=yqdJOFSlS5RqKiBC-Tx_LSL2n3hFnkt1unkv3UMNJG8,3513
10
- emu_sv-1.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
11
- emu_sv-1.0.0.dist-info/RECORD,,
File without changes