pennylane-lightning-tensor 0.42.0__cp311-cp311-manylinux_2_28_aarch64.whl → 0.43.0__cp311-cp311-manylinux_2_28_aarch64.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.
@@ -34,7 +34,6 @@ import pennylane as qml
34
34
  from pennylane.devices.qubit.sampling import _group_measurements
35
35
  from pennylane.measurements import (
36
36
  ClassicalShadowMP,
37
- CountsMP,
38
37
  ExpectationMP,
39
38
  MeasurementProcess,
40
39
  ProbabilityMP,
@@ -373,15 +372,7 @@ class LightningTensorMeasurements:
373
372
  wires = reduce(sum, (mp.wires for mp in mps))
374
373
 
375
374
  def _process_single_shot(samples):
376
- processed = []
377
- for mp in mps:
378
- res = mp.process_samples(samples, wires)
379
- if not isinstance(mp, CountsMP):
380
- res = qml.math.squeeze(res)
381
-
382
- processed.append(res)
383
-
384
- return tuple(processed)
375
+ return tuple(mp.process_samples(samples, wires) for mp in mps)
385
376
 
386
377
  try:
387
378
  samples = self._measurement_lightning.generate_samples(
@@ -405,6 +405,7 @@ class LightningTensorNet:
405
405
  cutoff_mode (str): Singular value truncation mode for MPS tensors can be done either by
406
406
  considering the absolute values of the singular values (``"abs"``) or by considering
407
407
  the relative values of the singular values (``"rel"``). Default is ``"abs"``.
408
+ worksize_pref (str): Preference for workspace size for cutensornet backend. The options are ``recommended``, ``min``, and ``max``. Default is ``recommended``.
408
409
  """
409
410
 
410
411
  # pylint: disable=too-many-arguments, too-many-positional-arguments
@@ -439,6 +440,9 @@ class LightningTensorNet:
439
440
  else:
440
441
  raise DeviceError(f"The method {self._method} is not supported.")
441
442
 
443
+ worksize_pref = kwargs.get("worksize_pref", "recommended")
444
+ self.set_worksize_pref(worksize_pref)
445
+
442
446
  @property
443
447
  def dtype(self):
444
448
  """Returns the tensor network data type."""
@@ -648,6 +652,8 @@ class LightningTensorNet:
648
652
  gate_matrix, wires, max_mpo_bond_dim, self._c_dtype
649
653
  )
650
654
 
655
+ # Convert to C-contiguous arrays for C++ bindings
656
+ mpos = [np.ascontiguousarray(mpo) for mpo in mpos]
651
657
  self._tensornet.applyMPOOperation(mpos, sorted_wires, max_mpo_bond_dim)
652
658
 
653
659
  # pylint: disable=too-many-branches
@@ -765,6 +771,18 @@ class LightningTensorNet:
765
771
 
766
772
  self._apply_lightning(operations)
767
773
 
774
+ def set_worksize_pref(self, worksize_pref: str):
775
+ """Set the worksize preference for the cutensornet backend.
776
+
777
+ Args:
778
+ worksize_pref (str): Preference for workspace size for cutensornet backend. The options are ``recommended``, ``max``, or ``min``. Default is ``recommended``.
779
+ """
780
+ if worksize_pref not in ("recommended", "max", "min"):
781
+ raise ValueError(
782
+ f'Worksize preference "{worksize_pref}" is not valid. Please select one of the following options: "recommended", "max", or "min".'
783
+ )
784
+ self._tensornet.setWorksizePref(worksize_pref)
785
+
768
786
  def set_tensor_network(self, circuit: QuantumScript):
769
787
  """
770
788
  Set the tensor network that results from executing the given quantum script.
@@ -17,15 +17,16 @@ It is a device to perform tensor network simulations of quantum circuits using `
17
17
  """
18
18
  from dataclasses import replace
19
19
  from numbers import Number
20
- from typing import Callable, Optional, Sequence, Tuple, Union
20
+ from typing import Callable, Optional, Sequence, Tuple
21
21
  from warnings import warn
22
22
 
23
23
  import numpy as np
24
24
  import pennylane as qml
25
- from pennylane.devices import DefaultExecutionConfig, Device, ExecutionConfig
25
+ from pennylane.devices import Device, ExecutionConfig
26
26
  from pennylane.devices.modifiers import simulator_tracking, single_tape_support
27
27
  from pennylane.devices.preprocess import (
28
28
  decompose,
29
+ device_resolve_dynamic_wires,
29
30
  validate_device_wires,
30
31
  validate_measurements,
31
32
  validate_observables,
@@ -57,9 +58,9 @@ except ImportError as ex:
57
58
  warn(str(ex), UserWarning)
58
59
  LT_CPP_BINARY_AVAILABLE = False
59
60
 
60
- Result_or_ResultBatch = Union[Result, ResultBatch]
61
+ Result_or_ResultBatch = Result | ResultBatch
61
62
  QuantumTapeBatch = Sequence[QuantumTape]
62
- QuantumTape_or_Batch = Union[QuantumTape, QuantumTapeBatch]
63
+ QuantumTape_or_Batch = QuantumTape | QuantumTapeBatch
63
64
  PostprocessingFn = Callable[[ResultBatch], Result_or_ResultBatch]
64
65
 
65
66
 
@@ -72,7 +73,6 @@ _methods = frozenset({"mps", "tn"})
72
73
  _operations = frozenset(
73
74
  {
74
75
  "Identity",
75
- "BasisState",
76
76
  "MPSPrep",
77
77
  "QubitUnitary",
78
78
  "ControlledQubitUnitary",
@@ -175,9 +175,6 @@ def stopping_condition(op: Operator) -> bool:
175
175
  if isinstance(op, qml.MPSPrep):
176
176
  return True
177
177
 
178
- if op.name in ("C(SProd)", "C(Exp)"):
179
- return True
180
-
181
178
  return op.has_matrix and op.name in _operations
182
179
 
183
180
 
@@ -245,6 +242,7 @@ class LightningTensor(Device):
245
242
  cutoff (float): (Only for ``method=mps``) The threshold used to truncate the singular values of the MPS tensors. The default is 0.
246
243
  cutoff_mode (str): (Only for ``method=mps``) Singular value truncation mode for MPS tensors. The options are ``"rel"`` and ``"abs"``. Default is ``"abs"``.
247
244
  backend (str): Supported backend. Currently, only ``cutensornet`` is supported. Default is ``cutensornet``.
245
+ worksize_pref (str): Preference for workspace size for cutensornet backend. The options are ``recommended``, ``min``, and ``max``. Default is ``recommended``.
248
246
 
249
247
  **Example for the MPS method**
250
248
 
@@ -290,12 +288,10 @@ class LightningTensor(Device):
290
288
  """
291
289
 
292
290
  # pylint: disable=too-many-instance-attributes
293
- pennylane_requires = ">=0.41"
294
- version = __version__
295
291
 
296
292
  _device_options = {
297
- "mps": ("backend", "max_bond_dim", "cutoff", "cutoff_mode"),
298
- "tn": ("backend"),
293
+ "mps": ("backend", "max_bond_dim", "cutoff", "cutoff_mode", "worksize_pref"),
294
+ "tn": ("backend", "worksize_pref"),
299
295
  }
300
296
 
301
297
  _CPP_BINARY_AVAILABLE = LT_CPP_BINARY_AVAILABLE
@@ -340,6 +336,7 @@ class LightningTensor(Device):
340
336
  self._c_dtype = c_dtype
341
337
 
342
338
  self._backend = kwargs.get("backend", "cutensornet")
339
+ self._worksize_pref = kwargs.get("worksize_pref", "recommended")
343
340
 
344
341
  for arg in kwargs:
345
342
  if arg not in self._device_options[self._method]:
@@ -397,19 +394,22 @@ class LightningTensor(Device):
397
394
  max_bond_dim=self._max_bond_dim,
398
395
  cutoff=self._cutoff,
399
396
  cutoff_mode=self._cutoff_mode,
397
+ worksize_pref=self._worksize_pref,
400
398
  )
401
399
  return LightningTensorNet(num_wires, self._method, self._c_dtype, device_name=self.name)
402
400
 
403
401
  dtype = c_dtype
404
402
 
405
- def _setup_execution_config(
406
- self, config: Optional[ExecutionConfig] = DefaultExecutionConfig
403
+ # pylint: disable=unused-argument
404
+ def setup_execution_config(
405
+ self, config: ExecutionConfig | None = None, circuit=None
407
406
  ) -> ExecutionConfig:
408
407
  """
409
408
  Update the execution config with choices for how the device should be used and the device options.
410
409
  """
410
+ if config is None:
411
+ config = ExecutionConfig()
411
412
  # TODO: add options for gradients next quarter
412
-
413
413
  updated_values = {}
414
414
 
415
415
  new_device_options = dict(config.device_options)
@@ -431,10 +431,10 @@ class LightningTensor(Device):
431
431
 
432
432
  return circuit.map_to_standard_wires() if self.num_wires is None else circuit
433
433
 
434
- def preprocess(
434
+ def preprocess_transforms(
435
435
  self,
436
- execution_config: ExecutionConfig = DefaultExecutionConfig,
437
- ):
436
+ execution_config: ExecutionConfig | None = None,
437
+ ) -> TransformProgram:
438
438
  """This function defines the device transform program to be applied and an updated device configuration.
439
439
 
440
440
  Args:
@@ -451,28 +451,30 @@ class LightningTensor(Device):
451
451
  * Does not support derivatives.
452
452
  * Does not support vector-Jacobian products.
453
453
  """
454
-
455
- config = self._setup_execution_config(execution_config)
454
+ if execution_config is None:
455
+ execution_config = self.setup_execution_config(ExecutionConfig())
456
456
 
457
457
  program = TransformProgram()
458
458
 
459
459
  program.add_transform(validate_measurements, name=self.name)
460
460
  program.add_transform(validate_observables, accepted_observables, name=self.name)
461
- program.add_transform(validate_device_wires, self._wires, name=self.name)
462
461
  program.add_transform(
463
462
  decompose,
464
463
  stopping_condition=stopping_condition,
465
- stopping_condition_shots=stopping_condition,
466
464
  skip_initial_state_prep=True,
467
465
  name=self.name,
466
+ device_wires=self.wires,
467
+ target_gates=self.operations,
468
468
  )
469
- return program, config
469
+ program.add_transform(device_resolve_dynamic_wires, wires=self.wires, allow_resets=False)
470
+ program.add_transform(validate_device_wires, self._wires, name=self.name)
471
+ return program
470
472
 
471
473
  # pylint: disable=unused-argument
472
474
  def execute(
473
475
  self,
474
476
  circuits: QuantumTape_or_Batch,
475
- execution_config: ExecutionConfig = DefaultExecutionConfig,
477
+ execution_config: ExecutionConfig | None = None,
476
478
  ) -> Result_or_ResultBatch:
477
479
  """Execute a circuit or a batch of circuits and turn it into results.
478
480
 
@@ -503,7 +505,7 @@ class LightningTensor(Device):
503
505
  # pylint: disable=unused-argument
504
506
  def supports_derivatives(
505
507
  self,
506
- execution_config: Optional[ExecutionConfig] = None,
508
+ execution_config: ExecutionConfig | None = None,
507
509
  circuit: Optional[qml.tape.QuantumTape] = None,
508
510
  ) -> bool:
509
511
  """Check whether or not derivatives are available for a given configuration and circuit.
@@ -521,7 +523,7 @@ class LightningTensor(Device):
521
523
  def compute_derivatives(
522
524
  self,
523
525
  circuits: QuantumTape_or_Batch,
524
- execution_config: ExecutionConfig = DefaultExecutionConfig,
526
+ execution_config: ExecutionConfig | None = None,
525
527
  ):
526
528
  """Calculate the Jacobian of either a single or a batch of circuits on the device.
527
529
 
@@ -539,7 +541,7 @@ class LightningTensor(Device):
539
541
  def execute_and_compute_derivatives(
540
542
  self,
541
543
  circuits: QuantumTape_or_Batch,
542
- execution_config: ExecutionConfig = DefaultExecutionConfig,
544
+ execution_config: ExecutionConfig | None = None,
543
545
  ):
544
546
  """Compute the results and Jacobians of circuits at the same time.
545
547
 
@@ -557,7 +559,7 @@ class LightningTensor(Device):
557
559
  # pylint: disable=unused-argument
558
560
  def supports_vjp(
559
561
  self,
560
- execution_config: Optional[ExecutionConfig] = None,
562
+ execution_config: ExecutionConfig | None = None,
561
563
  circuit: Optional[QuantumTape] = None,
562
564
  ) -> bool:
563
565
  """Whether or not this device defines a custom vector-Jacobian product.
@@ -575,7 +577,7 @@ class LightningTensor(Device):
575
577
  self,
576
578
  circuits: QuantumTape_or_Batch,
577
579
  cotangents: Tuple[Number],
578
- execution_config: ExecutionConfig = DefaultExecutionConfig,
580
+ execution_config: ExecutionConfig | None = None,
579
581
  ):
580
582
  r"""The vector-Jacobian product used in reverse-mode differentiation.
581
583
 
@@ -597,7 +599,7 @@ class LightningTensor(Device):
597
599
  self,
598
600
  circuits: QuantumTape_or_Batch,
599
601
  cotangents: Tuple[Number],
600
- execution_config: ExecutionConfig = DefaultExecutionConfig,
602
+ execution_config: ExecutionConfig | None = None,
601
603
  ):
602
604
  """Calculate both the results and the vector-Jacobian product used in reverse-mode differentiation.
603
605
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pennylane_lightning_tensor
3
- Version: 0.42.0
3
+ Version: 0.43.0
4
4
  Summary: PennyLane-Lightning plugin
5
5
  Maintainer-email: "Xanadu Quantum Technologies Inc." <software@xanadu.ai>
6
6
  License-Expression: Apache-2.0
@@ -15,12 +15,11 @@ Classifier: Operating System :: POSIX :: Linux
15
15
  Classifier: Programming Language :: Python
16
16
  Classifier: Programming Language :: Python :: 3
17
17
  Classifier: Programming Language :: Python :: 3 :: Only
18
- Classifier: Programming Language :: Python :: 3.10
19
18
  Classifier: Programming Language :: Python :: 3.11
20
19
  Classifier: Programming Language :: Python :: 3.12
21
20
  Classifier: Programming Language :: Python :: 3.13
22
21
  Classifier: Topic :: Scientific/Engineering :: Physics
23
- Requires-Python: >=3.10
22
+ Requires-Python: >=3.11
24
23
  Description-Content-Type: text/markdown
25
24
  License-File: LICENSE
26
25
  Requires-Dist: pennylane>=0.41
@@ -31,7 +30,7 @@ Requires-Dist: nvidia-nvjitlink-cu12
31
30
  Requires-Dist: nvidia-cusparse-cu12
32
31
  Requires-Dist: nvidia-cublas-cu12
33
32
  Requires-Dist: nvidia-cuda-runtime-cu12
34
- Requires-Dist: pennylane_lightning==0.42.0
33
+ Requires-Dist: pennylane_lightning==0.43.0
35
34
  Provides-Extra: gpu
36
35
  Requires-Dist: pennylane-lightning-gpu; extra == "gpu"
37
36
  Provides-Extra: kokkos
@@ -100,7 +99,7 @@ The Lightning plugin ecosystem provides fast state-vector and tensor-network sim
100
99
 
101
100
  [PennyLane](https://docs.pennylane.ai) is a cross-platform Python library for quantum machine
102
101
  learning, automatic differentiation, and optimization of hybrid quantum-classical computations.
103
- PennyLane supports Python 3.10 and above.
102
+ PennyLane supports Python 3.11 and above.
104
103
 
105
104
  ## Backends
106
105
 
@@ -213,7 +212,7 @@ enable the device bindings to PennyLane, which are held to their own respective
213
212
 
214
213
  PennyLane Lightning makes use of the following libraries and tools, which are under their own respective licenses:
215
214
 
216
- - **pybind11:** https://github.com/pybind/pybind11
215
+ - **nanobind:** https://github.com/wjakob/nanobind
217
216
  - **Kokkos Core:** https://github.com/kokkos/kokkos
218
217
  - **NVIDIA cuQuantum:** https://developer.nvidia.com/cuquantum-sdk
219
218
  - **scipy-openblas32:** https://pypi.org/project/scipy-openblas32/
@@ -0,0 +1,12 @@
1
+ pennylane_lightning_tensor.libs/libgomp-947d5fa1.so.1.0.0,sha256=3DIx-P1MrcRthlnDuN2BGuMxdHSehoB_FvYerW7lm_0,343345
2
+ pennylane_lightning_tensor-0.43.0.dist-info/WHEEL,sha256=8jTxASeLvPr09PZ22DGSMQlRkrmgeqGaotjla49xWxo,114
3
+ pennylane_lightning_tensor-0.43.0.dist-info/entry_points.txt,sha256=2IpSy50QiwMzPv1qWJeCtp_oEEHsOvaQbRV8G5ExdrM,92
4
+ pennylane_lightning_tensor-0.43.0.dist-info/METADATA,sha256=o7yrYVBdM6HMaR3VPpq_1kjt6SLR0_H51VvVUTdAfaU,11419
5
+ pennylane_lightning_tensor-0.43.0.dist-info/RECORD,,
6
+ pennylane_lightning_tensor-0.43.0.dist-info/top_level.txt,sha256=G8tVqgen55ojHMLJr9_CDbxbX-_frQCZWMCqUvvGIZI,41
7
+ pennylane_lightning_tensor-0.43.0.dist-info/licenses/LICENSE,sha256=_zKpiTfJGLmlVz4pw88ztD4wTe2QkkUNBGSaac54sjM,11720
8
+ pennylane_lightning/lightning_tensor_ops.cpython-311-aarch64-linux-gnu.so,sha256=Hvdqc7earRex_UtbnxQOSVehuAjnzMbSy7RxP0HObAo,1086345
9
+ pennylane_lightning/lightning_tensor/__init__.py,sha256=y2DrEuU_gP2lV2jKVoR7qcpcGO_1LXTqYF6cIS7ULTU,737
10
+ pennylane_lightning/lightning_tensor/lightning_tensor.py,sha256=vpnrYQhXwU-xbmrY2wDqqQduHGSsM3FX5rG2KxOhAt8,22405
11
+ pennylane_lightning/lightning_tensor/_tensornet.py,sha256=q5XL18hItw6xG3y8RhrArCiAEg9M1PJTDJM_DBRxTMU,31546
12
+ pennylane_lightning/lightning_tensor/_measurements.py,sha256=zo3_KPfms_oj-zmeye5j-_i0G7wFuG7boXFS1UxDwZk,16123
@@ -1,12 +0,0 @@
1
- pennylane_lightning_tensor.libs/libgomp-98df74fd.so.1.0.0,sha256=c92itWhSYBOIWRdkLAttSVj5yIr-O0pzI8LXUO4jbGo,343345
2
- pennylane_lightning_tensor-0.42.0.dist-info/WHEEL,sha256=8jTxASeLvPr09PZ22DGSMQlRkrmgeqGaotjla49xWxo,114
3
- pennylane_lightning_tensor-0.42.0.dist-info/entry_points.txt,sha256=2IpSy50QiwMzPv1qWJeCtp_oEEHsOvaQbRV8G5ExdrM,92
4
- pennylane_lightning_tensor-0.42.0.dist-info/METADATA,sha256=6Ztixir6yVNnFy0yYwI7PE-s1N1MALQ60qI9rO-YyQg,11470
5
- pennylane_lightning_tensor-0.42.0.dist-info/RECORD,,
6
- pennylane_lightning_tensor-0.42.0.dist-info/top_level.txt,sha256=G8tVqgen55ojHMLJr9_CDbxbX-_frQCZWMCqUvvGIZI,41
7
- pennylane_lightning_tensor-0.42.0.dist-info/licenses/LICENSE,sha256=_zKpiTfJGLmlVz4pw88ztD4wTe2QkkUNBGSaac54sjM,11720
8
- pennylane_lightning/lightning_tensor_ops.cpython-311-aarch64-linux-gnu.so,sha256=rdJ2K6LpNrIS2ltvj2YvdJkezmioLOENJHnfMiMruE4,1200145
9
- pennylane_lightning/lightning_tensor/__init__.py,sha256=y2DrEuU_gP2lV2jKVoR7qcpcGO_1LXTqYF6cIS7ULTU,737
10
- pennylane_lightning/lightning_tensor/lightning_tensor.py,sha256=ox2YZnFkKz19A0x2lxTOnAUqtHwWDufkpEEvU-_j-Ac,22018
11
- pennylane_lightning/lightning_tensor/_tensornet.py,sha256=eMc2MdXqqvY1gy0I4qAm1Zizjq7j0ujSBDcNXCb94S0,30520
12
- pennylane_lightning/lightning_tensor/_measurements.py,sha256=jUsPQq7igJzt9IDlyoMuSo2yMT2QfqGdM3Hos2G4WFQ,16346