emu-base 2.4.1__py3-none-any.whl → 2.4.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_base/__init__.py CHANGED
@@ -21,4 +21,4 @@ __all__ = [
21
21
  "unix_like",
22
22
  ]
23
23
 
24
- __version__ = "2.4.1"
24
+ __version__ = "2.4.3"
@@ -2,43 +2,59 @@ from pulser.noise_model import NoiseModel
2
2
  import torch
3
3
  import math
4
4
 
5
+ dtype = torch.complex128
6
+
5
7
 
6
8
  def get_lindblad_operators(
7
- *, noise_type: str, noise_model: NoiseModel
9
+ *, noise_type: str, noise_model: NoiseModel, dim: int = 2
8
10
  ) -> list[torch.Tensor]:
11
+
9
12
  assert noise_type in noise_model.noise_types
10
13
 
11
14
  if noise_type == "relaxation":
12
15
  c = math.sqrt(noise_model.relaxation_rate)
13
- return [
14
- torch.tensor([[0, c], [0, 0]], dtype=torch.complex128),
15
- ]
16
+ relaxation = torch.zeros(dim, dim, dtype=dtype)
17
+ relaxation[0, 1] = c
18
+ return [relaxation]
16
19
 
17
20
  if noise_type == "dephasing":
18
21
  if noise_model.hyperfine_dephasing_rate != 0.0:
19
22
  raise NotImplementedError("hyperfine_dephasing_rate is unsupported")
20
23
 
21
24
  c = math.sqrt(noise_model.dephasing_rate / 2)
22
- return [
23
- torch.tensor([[-c, 0], [0, c]], dtype=torch.complex128),
24
- ]
25
+ dephasing = torch.zeros(dim, dim, dtype=dtype)
26
+
27
+ dephasing[0, 0] = c
28
+ dephasing[1, 1] = -c
29
+
30
+ return [dephasing]
25
31
 
26
32
  if noise_type == "depolarizing":
27
33
  c = math.sqrt(noise_model.depolarizing_rate / 4)
28
- return [
29
- torch.tensor([[0, c], [c, 0]], dtype=torch.complex128),
30
- torch.tensor([[0, 1j * c], [-1j * c, 0]], dtype=torch.complex128),
31
- torch.tensor([[-c, 0], [0, c]], dtype=torch.complex128),
32
- ]
34
+ depolarizing_x = torch.zeros(dim, dim, dtype=dtype)
35
+ depolarizing_x[0, 1] = c
36
+ depolarizing_x[1, 0] = c
37
+
38
+ depolarizing_y = torch.zeros(dim, dim, dtype=dtype)
39
+ depolarizing_y[0, 1] = torch.tensor(-c * 1.0j, dtype=dtype)
40
+ depolarizing_y[1, 0] = torch.tensor(c * 1.0j, dtype=dtype)
41
+
42
+ depolarizing_z = torch.zeros(dim, dim, dtype=dtype)
43
+ depolarizing_z[0, 0] = c
44
+ depolarizing_z[1, 1] = -c
45
+
46
+ return [depolarizing_x, depolarizing_y, depolarizing_z]
33
47
 
34
48
  if noise_type == "eff_noise":
35
49
  if not all(
36
- isinstance(op, torch.Tensor) and op.shape == (2, 2)
50
+ isinstance(op, torch.Tensor) and op.shape == (dim, dim)
37
51
  for op in noise_model.eff_noise_opers
38
52
  ):
39
- raise ValueError("Only 2 * 2 effective noise operator matrices are supported")
53
+ raise ValueError(
54
+ "Only 2 by 2 or 3 by 3 effective noise operator matrices are supported"
55
+ )
40
56
 
41
- return [
57
+ return [ # lindblad operators are coming from pulser
42
58
  math.sqrt(rate)
43
59
  * torch.flip(op if isinstance(op, torch.Tensor) else torch.tensor(op), (0, 1))
44
60
  for rate, op in zip(noise_model.eff_noise_rates, noise_model.eff_noise_opers)
@@ -47,14 +63,17 @@ def get_lindblad_operators(
47
63
  raise ValueError(f"Unknown noise type: {noise_type}")
48
64
 
49
65
 
50
- def compute_noise_from_lindbladians(lindbladians: list[torch.Tensor]) -> torch.Tensor:
66
+ def compute_noise_from_lindbladians(
67
+ lindbladians: list[torch.Tensor], dim: int = 2
68
+ ) -> torch.Tensor:
51
69
  """
52
- Compute the single-qubit Hamiltonian noise term -0.5i∑L†L from all the given lindbladians.
70
+ Compute the single-qubit Hamiltonian noise term -0.5i∑L†L from all the
71
+ given lindbladians.
53
72
  """
54
73
  assert all(
55
- lindbladian.shape == (2, 2) for lindbladian in lindbladians
74
+ lindbladian.shape == (dim, dim) for lindbladian in lindbladians
56
75
  ), "Only single-qubit lindblad operators are supported"
57
76
 
58
- zero = torch.zeros(2, 2, dtype=torch.complex128)
77
+ zero = torch.zeros(dim, dim, dtype=dtype)
59
78
 
60
79
  return -0.5j * sum((L.mH @ L for L in lindbladians), start=zero)
@@ -20,7 +20,7 @@ _NON_LINDBLADIAN_NOISE = {"SPAM", "doppler", "amplitude", "detuning", "register"
20
20
 
21
21
 
22
22
  def _get_all_lindblad_noise_operators(
23
- noise_model: NoiseModel | None,
23
+ noise_model: NoiseModel | None, dim: int = 2
24
24
  ) -> list[torch.Tensor]:
25
25
  if noise_model is None:
26
26
  return []
@@ -29,7 +29,9 @@ def _get_all_lindblad_noise_operators(
29
29
  op
30
30
  for noise_type in noise_model.noise_types
31
31
  if noise_type not in _NON_LINDBLADIAN_NOISE
32
- for op in get_lindblad_operators(noise_type=noise_type, noise_model=noise_model)
32
+ for op in get_lindblad_operators(
33
+ noise_type=noise_type, noise_model=noise_model, dim=dim
34
+ )
33
35
  ]
34
36
 
35
37
 
@@ -150,6 +152,7 @@ class PulserData:
150
152
  )
151
153
 
152
154
  int_type = self.hamiltonian.interaction_type
155
+ self.dim = self.hamiltonian.dim
153
156
  if int_type == "ising": # for local and global
154
157
  self.hamiltonian_type = HamiltonianType.Rydberg
155
158
  elif int_type == "XY":
@@ -157,7 +160,9 @@ class PulserData:
157
160
  else:
158
161
  raise ValueError(f"Unsupported basis: {int_type}")
159
162
 
160
- self.lindblad_ops = _get_all_lindblad_noise_operators(config.noise_model)
163
+ self.lindblad_ops = _get_all_lindblad_noise_operators(
164
+ config.noise_model, dim=self.dim
165
+ )
161
166
  self.has_lindblad_noise: bool = self.lindblad_ops != []
162
167
 
163
168
  if config.interaction_matrix is not None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: emu-base
3
- Version: 2.4.1
3
+ Version: 2.4.3
4
4
  Summary: Pasqal base classes for emulators
5
5
  Project-URL: Documentation, https://pasqal-io.github.io/emulators/
6
6
  Project-URL: Repository, https://github.com/pasqal-io/emulators
@@ -26,7 +26,7 @@ Classifier: Programming Language :: Python :: Implementation :: CPython
26
26
  Classifier: Programming Language :: Python :: Implementation :: PyPy
27
27
  Requires-Python: >=3.10
28
28
  Requires-Dist: pulser-core==1.6.*
29
- Requires-Dist: torch>=2.8.0
29
+ Requires-Dist: torch>=2.9.0
30
30
  Description-Content-Type: text/markdown
31
31
 
32
32
  <div align="center">
@@ -1,7 +1,7 @@
1
- emu_base/__init__.py,sha256=hxXLbvqH2yhva3QXRtTws6oSFnVPMndrgvENXzze9Rw,725
1
+ emu_base/__init__.py,sha256=2_F4En9Wj4MwnJXavLN7LqV5CnOnV0JGSCFBSCuGhsw,725
2
2
  emu_base/constants.py,sha256=41LYkKLUCz-oxPbd-j7nUDZuhIbUrnez6prT0uR0jcE,56
3
- emu_base/jump_lindblad_operators.py,sha256=Y30f8emVFS4Dazljc_Rh4lX9qU4QQY_AxPNahnzcsfY,2101
4
- emu_base/pulser_adapter.py,sha256=bb529P2tspLgX_EcJxCT4bJjFM8SOIttgsFIznTeN58,6979
3
+ emu_base/jump_lindblad_operators.py,sha256=b5xL62aCVFjbNRigyBtRTacG4Xg2A3eYXRe2KBNlt9w,2588
4
+ emu_base/pulser_adapter.py,sha256=NB220g-ESyi8Te-mcmj0ciLpi4JG-Bj7dVKy5sKJuUU,7099
5
5
  emu_base/utils.py,sha256=OoJ0GjL1K8m9Jq-BeBfmbWuFp9bvwXp8UcI3BMW94Js,2974
6
6
  emu_base/math/__init__.py,sha256=6BbIytYV5uC-e5jLMtIErkcUl_PvfSNnhmVFY9Il8uQ,97
7
7
  emu_base/math/brents_root_finding.py,sha256=AVx6L1Il6rpPJWrLJ7cn6oNmJyZOPRgEaaZaubC9lsU,3711
@@ -9,6 +9,6 @@ emu_base/math/double_krylov.py,sha256=X16dyCbyzdP7fFK-hmKS03Q-DJtC6TZ8sJrGTJ6akI
9
9
  emu_base/math/krylov_energy_min.py,sha256=iR4hmE0eXptbAg3opikd5d4Zv7dhnDrawH-n_4KG-cc,4009
10
10
  emu_base/math/krylov_exp.py,sha256=mGFddVQ8mEbwypbZtnlRPFpi4Nf8JZT6OKLHloIwCDQ,3934
11
11
  emu_base/math/matmul.py,sha256=lEAnV0b5z_f1xEA-9p-WXxA8bM3QbShiHdXQ3ZkZFcQ,877
12
- emu_base-2.4.1.dist-info/METADATA,sha256=8ikaKvc4pjqEikcqgoCUj4WnRUlClI5xBQfIPDRuFO8,3604
13
- emu_base-2.4.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
- emu_base-2.4.1.dist-info/RECORD,,
12
+ emu_base-2.4.3.dist-info/METADATA,sha256=atbuyLSrlYZNsVpLubWaBV4yblkgllwW45DvmFKvZlE,3604
13
+ emu_base-2.4.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
+ emu_base-2.4.3.dist-info/RECORD,,