pennylane-qrack 0.10.1__py3-none-manylinux_2_39_x86_64.whl → 0.10.3__py3-none-manylinux_2_39_x86_64.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.

Potentially problematic release.


This version of pennylane-qrack might be problematic. Click here for more details.

@@ -249,7 +249,7 @@ CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
249
249
  //Minor version of cmake used to create the current loaded cache
250
250
  CMAKE_CACHE_MINOR_VERSION:INTERNAL=30
251
251
  //Patch version of cmake used to create the current loaded cache
252
- CMAKE_CACHE_PATCH_VERSION:INTERNAL=3
252
+ CMAKE_CACHE_PATCH_VERSION:INTERNAL=5
253
253
  //ADVANCED property for variable: CMAKE_COLOR_MAKEFILE
254
254
  CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1
255
255
  //Path to CMake executable.
@@ -16,4 +16,4 @@
16
16
  Version number (major.minor.patch[-label])
17
17
  """
18
18
 
19
- __version__ = "0.10.1"
19
+ __version__ = "0.10.3"
Binary file
@@ -24,7 +24,7 @@ import itertools as it
24
24
 
25
25
  import numpy as np
26
26
 
27
- from pennylane import QubitDevice, DeviceError
27
+ from pennylane import QubitDevice, DeviceError, QuantumFunctionError
28
28
  from pennylane.ops import (
29
29
  QubitStateVector,
30
30
  BasisState,
@@ -175,31 +175,35 @@ class QrackDevice(QubitDevice):
175
175
 
176
176
  def __init__(self, wires=0, shots=None, **kwargs):
177
177
  options = dict(kwargs)
178
- if 'isStabilizerHybrid' in options:
179
- self.isStabilizerHybrid = options['isStabilizerHybrid']
180
- if 'isTensorNetwork' in options:
181
- self.isTensorNetwork = options['isTensorNetwork']
182
- if 'isSchmidtDecompose' in options:
183
- self.isSchmidtDecompose = options['isSchmidtDecompose']
184
- if 'isBinaryDecisionTree' in options:
185
- self.isBinaryDecisionTree = options['isBinaryDecisionTree']
186
- if 'isOpenCL' in options:
187
- self.isOpenCL = options['isOpenCL']
188
- if 'isHostPointer' in options:
189
- self.isHostPointer = options['isHostPointer']
190
- if 'noise' in options:
191
- self.noise = options['noise']
178
+ if "isStabilizerHybrid" in options:
179
+ self.isStabilizerHybrid = options["isStabilizerHybrid"]
180
+ if "isTensorNetwork" in options:
181
+ self.isTensorNetwork = options["isTensorNetwork"]
182
+ if "isSchmidtDecompose" in options:
183
+ self.isSchmidtDecompose = options["isSchmidtDecompose"]
184
+ if "isBinaryDecisionTree" in options:
185
+ self.isBinaryDecisionTree = options["isBinaryDecisionTree"]
186
+ if "isOpenCL" in options:
187
+ self.isOpenCL = options["isOpenCL"]
188
+ if "isHostPointer" in options:
189
+ self.isHostPointer = options["isHostPointer"]
190
+ if "noise" in options:
191
+ self.noise = options["noise"]
192
+ if (self.noise != 0) and (shots is None):
193
+ raise ValueError("Shots must be finite for noisy simulation (not analytical mode).")
192
194
  super().__init__(wires=wires, shots=shots)
195
+ self.shots = shots
193
196
  self._state = QrackSimulator(
194
197
  self.num_wires,
195
- isStabilizerHybrid = self.isStabilizerHybrid,
198
+ isStabilizerHybrid=self.isStabilizerHybrid,
196
199
  isTensorNetwork=self.isTensorNetwork,
197
200
  isSchmidtDecompose=self.isSchmidtDecompose,
198
201
  isBinaryDecisionTree=self.isBinaryDecisionTree,
199
202
  isOpenCL=self.isOpenCL,
200
203
  isHostPointer=self.isHostPointer,
201
- noise = self.noise
204
+ noise=self.noise,
202
205
  )
206
+ self._circuit = []
203
207
 
204
208
  def _reverse_state(self):
205
209
  end = self.num_wires - 1
@@ -216,7 +220,14 @@ class QrackDevice(QubitDevice):
216
220
  operations (List[pennylane.Operation]): operations to be applied
217
221
  """
218
222
 
219
- for i, op in enumerate(operations):
223
+ self._circuit = self._circuit + operations
224
+ if self.noise == 0:
225
+ self._apply()
226
+ self._circuit = []
227
+ # else: Defer application until shots or expectation values are requested
228
+
229
+ def _apply(self):
230
+ for op in self._circuit:
220
231
  if isinstance(op, QubitStateVector):
221
232
  self._apply_qubit_state_vector(op)
222
233
  elif isinstance(op, BasisState):
@@ -647,20 +658,36 @@ class QrackDevice(QubitDevice):
647
658
  # estimate the ev
648
659
  return np.mean(self.sample(observable))
649
660
 
661
+ def _generate_sample(self):
662
+ rev_sample = self._state.m_all()
663
+ sample = 0
664
+ for i in range(self.num_wires):
665
+ if (rev_sample & (1 << i)) > 0:
666
+ sample |= 1 << (self.num_wires - (i + 1))
667
+ return sample
668
+
650
669
  def generate_samples(self):
651
670
  if self.shots is None:
652
- raise qml.QuantumFunctionError(
671
+ raise QuantumFunctionError(
653
672
  "The number of shots has to be explicitly set on the device "
654
673
  "when using sample-based measurements."
655
674
  )
656
675
 
676
+ if self.noise != 0:
677
+ samples = []
678
+ for _ in range(self.shots):
679
+ self._state.reset_all()
680
+ self._apply()
681
+ samples.append(self._generate_sample())
682
+ self._samples = QubitDevice.states_to_binary(np.array(samples), self.num_wires)
683
+ self._circuit = []
684
+
685
+ return self._samples
686
+
657
687
  if self.shots == 1:
658
- rev_sample = self._state.m_all()
659
- sample = 0
660
- for i in range(self.num_wires):
661
- if (rev_sample & (1 << i)) > 0:
662
- sample |= 1 << (self.num_wires - (i + 1))
663
- self._samples = QubitDevice.states_to_binary(np.array([sample]), self.num_wires)
688
+ self._samples = QubitDevice.states_to_binary(
689
+ np.array([self._generate_sample()]), self.num_wires
690
+ )
664
691
 
665
692
  return self._samples
666
693
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pennylane-qrack
3
- Version: 0.10.1
3
+ Version: 0.10.3
4
4
  Summary: PennyLane plugin for Qrack.
5
5
  Home-page: http://github.com/vm6502q
6
6
  Maintainer: vm6502q
@@ -0,0 +1,15 @@
1
+ pennylane_qrack/CMakeCache.txt,sha256=Y08HWRc1GOcqBUxsNQVhGO64XJNVFc5Fb9kh502-GPE,15001
2
+ pennylane_qrack/Makefile,sha256=S9Y76wF2BB8oc3vDHA8v5RY-cuUM9L1AYRtC0Uu8r60,7584
3
+ pennylane_qrack/QrackDeviceConfig.toml,sha256=t_IQVSFR-GJ3VuqpQqm4M5gA3TVL4-y0qPq-f0FJwac,6219
4
+ pennylane_qrack/__init__.py,sha256=_g4NKu07_pXqxvQaxjdAPe769S5tWwYjqyHi3z7YKHc,673
5
+ pennylane_qrack/_version.py,sha256=Noitb1jPb-iVIDs8IGKqYwQ5c7eiVBUCv8nnrpZp83s,692
6
+ pennylane_qrack/cmake_install.cmake,sha256=kW9d9vjuxI8PW08r6P09h7d6vmG74xsRzq1AuqYchh8,3336
7
+ pennylane_qrack/libqrack_device.so,sha256=rJDkAxIBcGFdPlbrhNXNx4wKLSyaPH-bRlwjfxMduLs,5439616
8
+ pennylane_qrack/qrack_device.cpp,sha256=eRoowI7n9XV63aoZEaDjWmK1NC4JQ1GBeL2uggDttG0,36846
9
+ pennylane_qrack/qrack_device.py,sha256=h479xWH_2c6pzBZ8ZUyXL5Mi_Okb5-4hm6VhmJQYCe4,26914
10
+ pennylane_qrack-0.10.3.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
11
+ pennylane_qrack-0.10.3.dist-info/METADATA,sha256=n--RspcC0tyX-uwjrFeUiX_eFefVCsB5WtXtzcpREds,5525
12
+ pennylane_qrack-0.10.3.dist-info/WHEEL,sha256=C1TWU4zYM0SzHSpeIdtQ9A4Rgh-y4CRhoSeWR54NR78,109
13
+ pennylane_qrack-0.10.3.dist-info/entry_points.txt,sha256=V6f1sN6IZZZaEvxrI47A3K_kksp8fDUWjLWD0Met7Ww,79
14
+ pennylane_qrack-0.10.3.dist-info/top_level.txt,sha256=5NFMNHqCHtVLwNkLg66xz846uUJAlnOJ5VGa6ulW1ow,16
15
+ pennylane_qrack-0.10.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.1.0)
2
+ Generator: setuptools (75.3.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-manylinux_2_39_x86_64
5
5
 
@@ -1,15 +0,0 @@
1
- pennylane_qrack/CMakeCache.txt,sha256=jyPMXf8dQPGSsJ8ZcWt24VwuVitsdgF6rsmBGUaS-jY,15001
2
- pennylane_qrack/Makefile,sha256=S9Y76wF2BB8oc3vDHA8v5RY-cuUM9L1AYRtC0Uu8r60,7584
3
- pennylane_qrack/QrackDeviceConfig.toml,sha256=t_IQVSFR-GJ3VuqpQqm4M5gA3TVL4-y0qPq-f0FJwac,6219
4
- pennylane_qrack/__init__.py,sha256=_g4NKu07_pXqxvQaxjdAPe769S5tWwYjqyHi3z7YKHc,673
5
- pennylane_qrack/_version.py,sha256=wPzzxyCbgXdn3mdSkz3Gkpepi4x5Ik58UXi07BhMazA,692
6
- pennylane_qrack/cmake_install.cmake,sha256=kW9d9vjuxI8PW08r6P09h7d6vmG74xsRzq1AuqYchh8,3336
7
- pennylane_qrack/libqrack_device.so,sha256=9n_D2-aVY9Qu7amvxGPPuKMBNTwEu_Y5D3N0S8x645Y,5547776
8
- pennylane_qrack/qrack_device.cpp,sha256=eRoowI7n9XV63aoZEaDjWmK1NC4JQ1GBeL2uggDttG0,36846
9
- pennylane_qrack/qrack_device.py,sha256=tN_RPJU8m4yr7AMfJQb6apRNxCKyX1XCIxpVwFo-2jw,26001
10
- pennylane_qrack-0.10.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
11
- pennylane_qrack-0.10.1.dist-info/METADATA,sha256=qGF858MmBaqNLGPk68IDYcAPF3bBHtEGL7kpmCBJrOQ,5525
12
- pennylane_qrack-0.10.1.dist-info/WHEEL,sha256=twxSdMhyYu-IomqNfMQyv48m-j8pDzobQgbcpTYeA-Q,109
13
- pennylane_qrack-0.10.1.dist-info/entry_points.txt,sha256=V6f1sN6IZZZaEvxrI47A3K_kksp8fDUWjLWD0Met7Ww,79
14
- pennylane_qrack-0.10.1.dist-info/top_level.txt,sha256=5NFMNHqCHtVLwNkLg66xz846uUJAlnOJ5VGa6ulW1ow,16
15
- pennylane_qrack-0.10.1.dist-info/RECORD,,