pyqrack-cpu 1.34.5__tar.gz → 1.38.1__tar.gz

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 pyqrack-cpu might be problematic. Click here for more details.

Files changed (24) hide show
  1. {pyqrack_cpu-1.34.5/pyqrack_cpu.egg-info → pyqrack_cpu-1.38.1}/PKG-INFO +20 -7
  2. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/README.md +7 -5
  3. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/pyqrack/__init__.py +0 -1
  4. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/pyqrack/qrack_circuit.py +10 -5
  5. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/pyqrack/qrack_simulator.py +62 -65
  6. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/pyqrack/qrack_system/qrack_system.py +2 -2
  7. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1/pyqrack_cpu.egg-info}/PKG-INFO +20 -7
  8. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/pyqrack_cpu.egg-info/SOURCES.txt +0 -2
  9. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/setup.py +2 -2
  10. pyqrack_cpu-1.34.5/pyqrack/util/__init__.py +0 -8
  11. pyqrack_cpu-1.34.5/pyqrack/util/convert_qiskit_circuit_to_qasm_experiment.py +0 -61
  12. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/LICENSE +0 -0
  13. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/MANIFEST.in +0 -0
  14. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/pyproject.toml +0 -0
  15. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/pyqrack/neuron_activation_fn.py +0 -0
  16. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/pyqrack/pauli.py +0 -0
  17. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/pyqrack/qrack_neuron.py +0 -0
  18. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/pyqrack/qrack_system/__init__.py +0 -0
  19. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/pyqrack/quimb_circuit_type.py +0 -0
  20. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/pyqrack_cpu.egg-info/dependency_links.txt +0 -0
  21. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/pyqrack_cpu.egg-info/not-zip-safe +0 -0
  22. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/pyqrack_cpu.egg-info/requires.txt +0 -0
  23. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/pyqrack_cpu.egg-info/top_level.txt +0 -0
  24. {pyqrack_cpu-1.34.5 → pyqrack_cpu-1.38.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: pyqrack-cpu
3
- Version: 1.34.5
3
+ Version: 1.38.1
4
4
  Summary: pyqrack - Pure Python vm6502q/qrack Wrapper
5
5
  Home-page: https://github.com/vm6502q/pyqrack
6
6
  Author: Daniel Strano
@@ -39,6 +39,17 @@ Description-Content-Type: text/markdown
39
39
  License-File: LICENSE
40
40
  Provides-Extra: dev
41
41
  Requires-Dist: pytest>=7.3.1; extra == "dev"
42
+ Dynamic: author
43
+ Dynamic: author-email
44
+ Dynamic: classifier
45
+ Dynamic: description
46
+ Dynamic: description-content-type
47
+ Dynamic: home-page
48
+ Dynamic: keywords
49
+ Dynamic: license
50
+ Dynamic: license-file
51
+ Dynamic: provides-extra
52
+ Dynamic: summary
42
53
 
43
54
  # pyqrack
44
55
  [![Downloads](https://pepy.tech/badge/pyqrack-cpu)](https://pepy.tech/project/pyqrack-cpu) [![Downloads](https://pepy.tech/badge/pyqrack-cpu/month)](https://pepy.tech/project/pyqrack-cpu) [![Downloads](https://static.pepy.tech/badge/pyqrack-cpu/week)](https://pepy.tech/project/pyqrack-cpu)
@@ -47,13 +58,15 @@ Pure Python bindings for the pure C++11 Qrack quantum computer simulator library
47
58
 
48
59
  (**PyQrack** is just pure Qrack.)
49
60
 
50
- <<<<<<< HEAD
51
- This is the **purely CPU-based** variant of PyQrack (with module name `pyqrack-cpu`). This alternate build of PyQrack is provided so that systems that won't use OpenCL anyway (such as because they lack any GPUs or other accelerators like the Intel HD) do not need to install the OpenCL library in order to use PyQrack. In this form, both the PyQrack module and the underlying C++ Qrack library are entirely external **dependency-free.**
61
+ This is the **purely CPU-based** variant of PyQrack (with module name `pyqrack-cpu`). This alternate build of PyQrack is provided so that systems that won't use OpenCL or CUDA anyway (such as because they lack any GPUs or other accelerators like the Intel HD) do not need to install the OpenCL library in order to use PyQrack. In this form, both the PyQrack module and the underlying C++ Qrack library are entirely external **dependency-free.**
62
+
63
+ **If you're looking for Mac ARM support, use the package `pyqrack`, not `pyqrack-cpu`.** Mac officially "deprecated" OpenCL years ago. Hence, accelerator support is not included in ARM-based Mac wheels, and OpenCL installation is **not** required on these systems, but, if you have a CUDA accelerator on ARM-based Mac, you could try the package `pyqrack-cuda` instead.
52
64
 
53
65
  (**If you installing from source,** it doesn't matter whether you use `pyqrack` or `pyqrack-cpu`, because the build version of C++ Qrack you intend to use must already be installed locally.)
54
- =======
55
- **Note, if building from source**: You must build and install [unitaryfund/qrack](https://github.com/unitaryfund/qrack) to build the `main` branch from source. CI/CD builds wheels that contain pre-compiled Qrack binaries, and that is the form published on PyPi. **You must also install OpenCL.**
56
- >>>>>>> main
66
+
67
+ **If you're looking for Mac ARM support, use the package `pyqrack`, not `pyqrack-cpu`.** Mac officially "deprecated" OpenCL years ago. Hence, accelerator support is not included in ARM-based Mac wheels, and OpenCL installation is **not** required on these systems, but, if you have a CUDA accelerator on ARM-based Mac, you could try the package `pyqrack-cuda` instead.
68
+
69
+ **Performance can benefit greatly from following the [Qrack repository "Quick Start" and "Power user considerations."](https://github.com/unitaryfund/qrack/blob/main/README.md#quick-start)**
57
70
 
58
71
  Import and instantiate [`QrackSimulator`](https://github.com/unitaryfund/pyqrack/blob/main/pyqrack/qrack_simulator.py) instances. This simulator can perform arbitrary single qubit and controlled-single-qubit gates, as well as other specific gates like `SWAP`.
59
72
 
@@ -5,13 +5,15 @@ Pure Python bindings for the pure C++11 Qrack quantum computer simulator library
5
5
 
6
6
  (**PyQrack** is just pure Qrack.)
7
7
 
8
- <<<<<<< HEAD
9
- This is the **purely CPU-based** variant of PyQrack (with module name `pyqrack-cpu`). This alternate build of PyQrack is provided so that systems that won't use OpenCL anyway (such as because they lack any GPUs or other accelerators like the Intel HD) do not need to install the OpenCL library in order to use PyQrack. In this form, both the PyQrack module and the underlying C++ Qrack library are entirely external **dependency-free.**
8
+ This is the **purely CPU-based** variant of PyQrack (with module name `pyqrack-cpu`). This alternate build of PyQrack is provided so that systems that won't use OpenCL or CUDA anyway (such as because they lack any GPUs or other accelerators like the Intel HD) do not need to install the OpenCL library in order to use PyQrack. In this form, both the PyQrack module and the underlying C++ Qrack library are entirely external **dependency-free.**
9
+
10
+ **If you're looking for Mac ARM support, use the package `pyqrack`, not `pyqrack-cpu`.** Mac officially "deprecated" OpenCL years ago. Hence, accelerator support is not included in ARM-based Mac wheels, and OpenCL installation is **not** required on these systems, but, if you have a CUDA accelerator on ARM-based Mac, you could try the package `pyqrack-cuda` instead.
10
11
 
11
12
  (**If you installing from source,** it doesn't matter whether you use `pyqrack` or `pyqrack-cpu`, because the build version of C++ Qrack you intend to use must already be installed locally.)
12
- =======
13
- **Note, if building from source**: You must build and install [unitaryfund/qrack](https://github.com/unitaryfund/qrack) to build the `main` branch from source. CI/CD builds wheels that contain pre-compiled Qrack binaries, and that is the form published on PyPi. **You must also install OpenCL.**
14
- >>>>>>> main
13
+
14
+ **If you're looking for Mac ARM support, use the package `pyqrack`, not `pyqrack-cpu`.** Mac officially "deprecated" OpenCL years ago. Hence, accelerator support is not included in ARM-based Mac wheels, and OpenCL installation is **not** required on these systems, but, if you have a CUDA accelerator on ARM-based Mac, you could try the package `pyqrack-cuda` instead.
15
+
16
+ **Performance can benefit greatly from following the [Qrack repository "Quick Start" and "Power user considerations."](https://github.com/unitaryfund/qrack/blob/main/README.md#quick-start)**
15
17
 
16
18
  Import and instantiate [`QrackSimulator`](https://github.com/unitaryfund/pyqrack/blob/main/pyqrack/qrack_simulator.py) instances. This simulator can perform arbitrary single qubit and controlled-single-qubit gates, as well as other specific gates like `SWAP`.
17
19
 
@@ -10,4 +10,3 @@ from .qrack_circuit import QrackCircuit
10
10
  from .pauli import Pauli
11
11
  from .neuron_activation_fn import NeuronActivationFn
12
12
  from .quimb_circuit_type import QuimbCircuitType
13
- from .util import convert_qiskit_circuit_to_qasm_experiment
@@ -74,12 +74,12 @@ class QrackCircuit:
74
74
  nrm = abs(m[0])
75
75
  if (nrm * nrm) < sys.float_info.epsilon:
76
76
  phase = 1.0 + 0.0j
77
- th = math.pi / 2;
77
+ th = math.pi;
78
78
  else:
79
79
  phase = m[0] / nrm
80
80
  if nrm > 1.0:
81
81
  nrm = 1.0
82
- th = math.acos(nrm)
82
+ th = 2 * math.acos(nrm)
83
83
 
84
84
  nrm1 = abs(m[1])
85
85
  nrm2 = abs(m[2])
@@ -107,13 +107,16 @@ class QrackCircuit:
107
107
  return [c + 0j, -el * s, ep * s, ep * el * c]
108
108
 
109
109
  def _u4_to_mtrx(params):
110
- m = _u3_to_mtrx(params)
110
+ m = QrackCircuit._u3_to_mtrx(params)
111
111
  g = np.exp(1j * float(params[3]))
112
112
  for i in range(4):
113
113
  m[i] *= g
114
114
 
115
115
  return m
116
116
 
117
+ def _make_mtrx_unitary(m):
118
+ return QrackCircuit._u4_to_mtrx(QrackCircuit._mtrx_to_u4(m))
119
+
117
120
  def clone(self):
118
121
  """Make a new circuit that is an exact clone of this circuit
119
122
 
@@ -337,6 +340,7 @@ class QrackCircuit:
337
340
  num_gates = int(tokens[i])
338
341
  i += 1
339
342
 
343
+ identity = np.eye(2, dtype=complex)
340
344
  for g in range(num_gates):
341
345
  target = int(tokens[i])
342
346
  i += 1
@@ -361,6 +365,8 @@ class QrackCircuit:
361
365
  mtrx.append(float(amp[0]) + float(amp[1])*1j)
362
366
  i += 1
363
367
 
368
+ mtrx = QrackCircuit._make_mtrx_unitary(mtrx)
369
+
364
370
  op = np.eye(2, dtype=complex)
365
371
  op[0][0] = mtrx[0]
366
372
  op[0][1] = mtrx[1]
@@ -369,14 +375,13 @@ class QrackCircuit:
369
375
 
370
376
  payloads[key] = op
371
377
 
372
- identity = np.eye(2, dtype=complex)
373
378
  gate_list=[]
374
379
  for j in range(1 << control_count):
375
380
  if j in payloads:
376
381
  gate_list.append(payloads[j])
377
382
  else:
378
383
  gate_list.append(identity)
379
- circ.append(UCGate(gate_list), controls + [target])
384
+ circ.append(UCGate(gate_list), [target] + controls)
380
385
 
381
386
  return circ
382
387
 
@@ -6,18 +6,16 @@
6
6
  import copy
7
7
  import ctypes
8
8
  import math
9
+ import os
9
10
  import re
10
11
  from .qrack_system import Qrack
11
12
  from .pauli import Pauli
12
13
 
13
14
  _IS_QISKIT_AVAILABLE = True
14
15
  try:
15
- from qiskit.circuit import QuantumRegister, Qubit
16
16
  from qiskit.circuit.quantumcircuit import QuantumCircuit
17
17
  from qiskit.compiler import transpile
18
- from qiskit.qobj.qasm_qobj import QasmQobjExperiment
19
18
  from qiskit.quantum_info.operators.symplectic.clifford import Clifford
20
- from .util import convert_qiskit_circuit_to_qasm_experiment
21
19
  except ImportError:
22
20
  _IS_QISKIT_AVAILABLE = False
23
21
 
@@ -60,7 +58,7 @@ class QrackSimulator:
60
58
  isPaged=True,
61
59
  isCpuGpuHybrid=True,
62
60
  isOpenCL=True,
63
- isHostPointer=False,
61
+ isHostPointer=True if os.environ.get('PYQRACK_HOST_POINTER_DEFAULT_ON') else False,
64
62
  noise=0,
65
63
  pyzxCircuit=None,
66
64
  qiskitCircuit=None,
@@ -184,6 +182,9 @@ class QrackSimulator:
184
182
  Qrack.qrack_lib.set_concurrency(self.sid, p)
185
183
  self._throw_if_error()
186
184
 
185
+ def clone(self):
186
+ return QrackSimulator(cloneSid=self.sid)
187
+
187
188
  # standard gates
188
189
 
189
190
  ## single-qubits gates
@@ -3265,7 +3266,7 @@ class QrackSimulator:
3265
3266
  non_clifford_gates.append(op)
3266
3267
  g = g + 1
3267
3268
 
3268
- basis_gates = ["rz", "h", "x", "y", "z", "sx", "sxdg", "sy", "sydg", "s", "sdg", "t", "tdg", "cx", "cy", "cz", "swap"]
3269
+ basis_gates = ["rz", "h", "x", "y", "z", "sx", "sxdg", "s", "sdg", "t", "tdg", "cx", "cy", "cz", "swap"]
3269
3270
  try:
3270
3271
  circ = transpile(clifford_circ, basis_gates=basis_gates, optimization_level=2)
3271
3272
  except:
@@ -3337,7 +3338,7 @@ class QrackSimulator:
3337
3338
  sqrt_ni = np.sqrt(-1j)
3338
3339
  sqrt1_2 = 1 / math.sqrt(2)
3339
3340
  ident = np.eye(2, dtype=np.complex128)
3340
- # passable_gates = ["unitary", "rz", "h", "x", "y", "z", "sx", "sxdg", "sy", "sydg", "s", "sdg", "t", "tdg"]
3341
+ # passable_gates = ["unitary", "rz", "h", "x", "y", "z", "sx", "sxdg", "s", "sdg", "t", "tdg"]
3341
3342
 
3342
3343
  passed_swaps = []
3343
3344
  for i in range(0, circ.width()):
@@ -3565,7 +3566,7 @@ class QrackSimulator:
3565
3566
  circ.data.insert(j, copy.deepcopy(c.data[0]))
3566
3567
  j -= 1
3567
3568
 
3568
- basis_gates=["u", "rz", "h", "x", "y", "z", "sx", "sxdg", "sy", "sydg", "s", "sdg", "t", "tdg", "cx", "cy", "cz", "swap"]
3569
+ basis_gates=["u", "rz", "h", "x", "y", "z", "sx", "sxdg", "s", "sdg", "t", "tdg", "cx", "cy", "cz", "swap"]
3569
3570
  circ = transpile(circ, basis_gates=basis_gates, optimization_level=2)
3570
3571
 
3571
3572
  #Eliminate unused ancillae
@@ -3662,150 +3663,150 @@ class QrackSimulator:
3662
3663
  return
3663
3664
 
3664
3665
  if (name == 'u1') or (name == 'p'):
3665
- self._sim.u(operation.qubits[0], 0, 0, float(operation.params[0]))
3666
+ self._sim.u(operation.qubits[0]._index, 0, 0, float(operation.params[0]))
3666
3667
  elif name == 'u2':
3667
3668
  self._sim.u(
3668
- operation.qubits[0],
3669
+ operation.qubits[0]._index,
3669
3670
  math.pi / 2,
3670
3671
  float(operation.params[0]),
3671
3672
  float(operation.params[1]),
3672
3673
  )
3673
3674
  elif (name == 'u3') or (name == 'u'):
3674
3675
  self._sim.u(
3675
- operation.qubits[0],
3676
+ operation.qubits[0]._index,
3676
3677
  float(operation.params[0]),
3677
3678
  float(operation.params[1]),
3678
3679
  float(operation.params[2]),
3679
3680
  )
3680
3681
  elif (name == 'unitary') and (len(operation.qubits) == 1):
3681
- self._sim.mtrx(operation.params[0].flatten(), operation.qubits[0])
3682
+ self._sim.mtrx(operation.params[0].flatten(), operation.qubits[0]._index)
3682
3683
  elif name == 'r':
3683
3684
  self._sim.u(
3684
- operation.qubits[0],
3685
+ operation.qubits[0]._index,
3685
3686
  float(operation.params[0]),
3686
3687
  float(operation.params[1]) - math.pi / 2,
3687
3688
  (-1 * float(operation.params[1])) + math.pi / 2,
3688
3689
  )
3689
3690
  elif name == 'rx':
3690
- self._sim.r(Pauli.PauliX, float(operation.params[0]), operation.qubits[0])
3691
+ self._sim.r(Pauli.PauliX, float(operation.params[0]), operation.qubits[0]._index)
3691
3692
  elif name == 'ry':
3692
- self._sim.r(Pauli.PauliY, float(operation.params[0]), operation.qubits[0])
3693
+ self._sim.r(Pauli.PauliY, float(operation.params[0]), operation.qubits[0]._index)
3693
3694
  elif name == 'rz':
3694
- self._sim.r(Pauli.PauliZ, float(operation.params[0]), operation.qubits[0])
3695
+ self._sim.r(Pauli.PauliZ, float(operation.params[0]), operation.qubits[0]._index)
3695
3696
  elif name == 'h':
3696
- self._sim.h(operation.qubits[0])
3697
+ self._sim.h(operation.qubits[0]._index)
3697
3698
  elif name == 'x':
3698
- self._sim.x(operation.qubits[0])
3699
+ self._sim.x(operation.qubits[0]._index)
3699
3700
  elif name == 'y':
3700
- self._sim.y(operation.qubits[0])
3701
+ self._sim.y(operation.qubits[0]._index)
3701
3702
  elif name == 'z':
3702
- self._sim.z(operation.qubits[0])
3703
+ self._sim.z(operation.qubits[0]._index)
3703
3704
  elif name == 's':
3704
- self._sim.s(operation.qubits[0])
3705
+ self._sim.s(operation.qubits[0]._index)
3705
3706
  elif name == 'sdg':
3706
- self._sim.adjs(operation.qubits[0])
3707
+ self._sim.adjs(operation.qubits[0]._index)
3707
3708
  elif name == 'sx':
3708
3709
  self._sim.mtrx(
3709
3710
  [(1 + 1j) / 2, (1 - 1j) / 2, (1 - 1j) / 2, (1 + 1j) / 2],
3710
- operation.qubits[0],
3711
+ operation.qubits[0]._index,
3711
3712
  )
3712
3713
  elif name == 'sxdg':
3713
3714
  self._sim.mtrx(
3714
3715
  [(1 - 1j) / 2, (1 + 1j) / 2, (1 + 1j) / 2, (1 - 1j) / 2],
3715
- operation.qubits[0],
3716
+ operation.qubits[0]._index,
3716
3717
  )
3717
3718
  elif name == 't':
3718
- self._sim.t(operation.qubits[0])
3719
+ self._sim.t(operation.qubits[0]._index)
3719
3720
  elif name == 'tdg':
3720
- self._sim.adjt(operation.qubits[0])
3721
+ self._sim.adjt(operation.qubits[0]._index)
3721
3722
  elif name == 'cu1':
3722
3723
  self._sim.mcu(
3723
- operation.qubits[0:1], operation.qubits[1], 0, 0, float(operation.params[0])
3724
+ [q._index for q in operation.qubits[0:1]], operation.qubits[1]._index, 0, 0, float(operation.params[0])
3724
3725
  )
3725
3726
  elif name == 'cu2':
3726
3727
  self._sim.mcu(
3727
- operation.qubits[0:1],
3728
- operation.qubits[1],
3728
+ [q._index for q in operation.qubits[0:1]],
3729
+ operation.qubits[1]._index,
3729
3730
  math.pi / 2,
3730
3731
  float(operation.params[0]),
3731
3732
  float(operation.params[1]),
3732
3733
  )
3733
3734
  elif (name == 'cu3') or (name == 'cu'):
3734
3735
  self._sim.mcu(
3735
- operation.qubits[0:1],
3736
- operation.qubits[1],
3736
+ [q._index for q in operation.qubits[0:1]],
3737
+ operation.qubits[1]._index,
3737
3738
  float(operation.params[0]),
3738
3739
  float(operation.params[1]),
3739
3740
  float(operation.params[2]),
3740
3741
  )
3741
3742
  elif name == 'cx':
3742
- self._sim.mcx(operation.qubits[0:1], operation.qubits[1])
3743
+ self._sim.mcx([q._index for q in operation.qubits[0:1]], operation.qubits[1]._index)
3743
3744
  elif name == 'cy':
3744
- self._sim.mcy(operation.qubits[0:1], operation.qubits[1])
3745
+ self._sim.mcy([q._index for q in operation.qubits[0:1]], operation.qubits[1]._index)
3745
3746
  elif name == 'cz':
3746
- self._sim.mcz(operation.qubits[0:1], operation.qubits[1])
3747
+ self._sim.mcz([q._index for q in operation.qubits[0:1]], operation.qubits[1]._index)
3747
3748
  elif name == 'ch':
3748
- self._sim.mch(operation.qubits[0:1], operation.qubits[1])
3749
+ self._sim.mch([q._index for q in operation.qubits[0:1]], operation.qubits[1]._index)
3749
3750
  elif name == 'cp':
3750
3751
  self._sim.mcmtrx(
3751
- operation.qubits[0:1],
3752
+ [q._index for q in operation.qubits[0:1]],
3752
3753
  [
3753
3754
  1,
3754
3755
  0,
3755
3756
  0,
3756
3757
  math.cos(float(operation.params[0])) + 1j * math.sin(float(operation.params[0])),
3757
3758
  ],
3758
- operation.qubits[1],
3759
+ operation.qubits[1]._index,
3759
3760
  )
3760
3761
  elif name == 'csx':
3761
3762
  self._sim.mcmtrx(
3762
- operation.qubits[0:1],
3763
+ [q._index for q in operation.qubits[0:1]],
3763
3764
  [(1 + 1j) / 2, (1 - 1j) / 2, (1 - 1j) / 2, (1 + 1j) / 2],
3764
- operation.qubits[1],
3765
+ operation.qubits[1]._index,
3765
3766
  )
3766
3767
  elif name == 'csxdg':
3767
3768
  self._sim.mcmtrx(
3768
- operation.qubits[0:1],
3769
+ [q._index for q in operation.qubits[0:1]],
3769
3770
  [(1 - 1j) / 2, (1 + 1j) / 2, (1 + 1j) / 2, (1 - 1j) / 2],
3770
- operation.qubits[1],
3771
+ operation.qubits[1]._index,
3771
3772
  )
3772
3773
  elif name == 'dcx':
3773
- self._sim.mcx(operation.qubits[0:1], operation.qubits[1])
3774
- self._sim.mcx(operation.qubits[1:2], operation.qubits[0])
3774
+ self._sim.mcx([q._index for q in operation.qubits[0:1]], operation.qubits[1]._index)
3775
+ self._sim.mcx(operation.qubits[1:2]._index, operation.qubits[0]._index)
3775
3776
  elif name == 'ccx':
3776
- self._sim.mcx(operation.qubits[0:2], operation.qubits[2])
3777
+ self._sim.mcx([q._index for q in operation.qubits[0:2]], operation.qubits[2]._index)
3777
3778
  elif name == 'ccy':
3778
- self._sim.mcy(operation.qubits[0:2], operation.qubits[2])
3779
+ self._sim.mcy([q._index for q in operation.qubits[0:2]], operation.qubits[2]._index)
3779
3780
  elif name == 'ccz':
3780
- self._sim.mcz(operation.qubits[0:2], operation.qubits[2])
3781
+ self._sim.mcz([q._index for q in operation.qubits[0:2]], operation.qubits[2]._index)
3781
3782
  elif name == 'mcx':
3782
- self._sim.mcx(operation.qubits[0:-1], operation.qubits[-1])
3783
+ self._sim.mcx([q._index for q in operation.qubits[0:-1]], operation.qubits[-1]._index)
3783
3784
  elif name == 'mcy':
3784
- self._sim.mcy(operation.qubits[0:-1], operation.qubits[-1])
3785
+ self._sim.mcy([q._index for q in operation.qubits[0:-1]], operation.qubits[-1]._index)
3785
3786
  elif name == 'mcz':
3786
- self._sim.mcz(operation.qubits[0:-1], operation.qubits[-1])
3787
+ self._sim.mcz([q._index for q in operation.qubits[0:-1]], operation.qubits[-1]._index)
3787
3788
  elif name == 'swap':
3788
- self._sim.swap(operation.qubits[0], operation.qubits[1])
3789
+ self._sim.swap(operation.qubits[0]._index, operation.qubits[1]._index)
3789
3790
  elif name == 'iswap':
3790
- self._sim.iswap(operation.qubits[0], operation.qubits[1])
3791
+ self._sim.iswap(operation.qubits[0]._index, operation.qubits[1]._index)
3791
3792
  elif name == 'iswap_dg':
3792
- self._sim.adjiswap(operation.qubits[0], operation.qubits[1])
3793
+ self._sim.adjiswap(operation.qubits[0]._index, operation.qubits[1]._index)
3793
3794
  elif name == 'cswap':
3794
3795
  self._sim.cswap(
3795
- operation.qubits[0:1], operation.qubits[1], operation.qubits[2]
3796
+ [q._index for q in operation.qubits[0:1]], operation.qubits[1]._index, operation.qubits[2]._index
3796
3797
  )
3797
3798
  elif name == 'mcswap':
3798
3799
  self._sim.cswap(
3799
- operation.qubits[:-2], operation.qubits[-2], operation.qubits[-1]
3800
+ [q._index for q in operation.qubits[:-2]], operation.qubits[-2]._index, operation.qubits[-1]._index
3800
3801
  )
3801
3802
  elif name == 'reset':
3802
3803
  qubits = operation.qubits
3803
3804
  for qubit in qubits:
3804
- if self._sim.m(qubit):
3805
- self._sim.x(qubit)
3805
+ if self._sim.m(qubit._index):
3806
+ self._sim.x(qubit._index)
3806
3807
  elif name == 'measure':
3807
3808
  qubits = operation.qubits
3808
- clbits = operation.memory
3809
+ clbits = operation.clbits
3809
3810
  cregbits = (
3810
3811
  operation.register
3811
3812
  if hasattr(operation, 'register')
@@ -3892,7 +3893,6 @@ class QrackSimulator:
3892
3893
  measure_clbit = [clbit for clbit in sample_clbits]
3893
3894
 
3894
3895
  # Sample and convert to bit-strings
3895
- data = []
3896
3896
  if num_samples == 1:
3897
3897
  sample = self._sim.m_all()
3898
3898
  result = 0
@@ -3902,12 +3902,13 @@ class QrackSimulator:
3902
3902
  result |= qubit_outcome << index
3903
3903
  measure_results = [result]
3904
3904
  else:
3905
- measure_results = self._sim.measure_shots(measure_qubit, num_samples)
3905
+ measure_results = self._sim.measure_shots([q._index for q in measure_qubit], num_samples)
3906
3906
 
3907
+ data = []
3907
3908
  for sample in measure_results:
3908
3909
  for index in range(len(measure_qubit)):
3909
3910
  qubit_outcome = (sample >> index) & 1
3910
- clbit = measure_clbit[index]
3911
+ clbit = measure_clbit[index]._index
3911
3912
  clmask = 1 << clbit
3912
3913
  self._classical_memory = (self._classical_memory & (~clmask)) | (
3913
3914
  qubit_outcome << clbit
@@ -3923,12 +3924,9 @@ class QrackSimulator:
3923
3924
  "Before trying to run_qiskit_circuit() with QrackSimulator, you must install Qiskit!"
3924
3925
  )
3925
3926
 
3926
- if isinstance(experiment, QuantumCircuit):
3927
- experiment = convert_qiskit_circuit_to_qasm_experiment(experiment)
3928
-
3929
3927
  instructions = []
3930
- if isinstance(experiment, QasmQobjExperiment):
3931
- instructions = experiment.instructions
3928
+ if isinstance(experiment, QuantumCircuit):
3929
+ instructions = experiment.data
3932
3930
  else:
3933
3931
  raise RuntimeError('Unrecognized "run_input" argument specified for run().')
3934
3932
 
@@ -3938,7 +3936,6 @@ class QrackSimulator:
3938
3936
  self._sample_cregbits = []
3939
3937
  self._sample_measure = True
3940
3938
  _data = []
3941
- shotsPerLoop = self._shots
3942
3939
  shotLoopMax = 1
3943
3940
 
3944
3941
  is_initializing = True
@@ -36,7 +36,7 @@ class QrackSystem:
36
36
  self.qrack_lib = CDLL(shared_lib_path)
37
37
  except Exception as e:
38
38
  if _platform == "win32":
39
- shared_lib_path = "C:/Program Files/libqrack*/lib/qrack_pinvoke.lib"
39
+ shared_lib_path = "C:/Program Files (x86)/Qrack/bin/qrack_pinvoke.dll"
40
40
  elif _platform == "darwin":
41
41
  shared_lib_path = "/usr/local/lib/qrack/libqrack_pinvoke.dylib"
42
42
  else:
@@ -46,7 +46,7 @@ class QrackSystem:
46
46
  self.qrack_lib = CDLL(shared_lib_path)
47
47
  except Exception as e:
48
48
  if _platform == "win32":
49
- shared_lib_path = "C:/Program Files (x86)/libqrack*/lib/qrack_pinvoke.lib"
49
+ shared_lib_path = "C:/Program Files (x86)/Qrack/bin/qrack_pinvoke.dll"
50
50
  elif _platform == "darwin":
51
51
  shared_lib_path = "/usr/lib/qrack/libqrack_pinvoke.dylib"
52
52
  else:
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: pyqrack-cpu
3
- Version: 1.34.5
3
+ Version: 1.38.1
4
4
  Summary: pyqrack - Pure Python vm6502q/qrack Wrapper
5
5
  Home-page: https://github.com/vm6502q/pyqrack
6
6
  Author: Daniel Strano
@@ -39,6 +39,17 @@ Description-Content-Type: text/markdown
39
39
  License-File: LICENSE
40
40
  Provides-Extra: dev
41
41
  Requires-Dist: pytest>=7.3.1; extra == "dev"
42
+ Dynamic: author
43
+ Dynamic: author-email
44
+ Dynamic: classifier
45
+ Dynamic: description
46
+ Dynamic: description-content-type
47
+ Dynamic: home-page
48
+ Dynamic: keywords
49
+ Dynamic: license
50
+ Dynamic: license-file
51
+ Dynamic: provides-extra
52
+ Dynamic: summary
42
53
 
43
54
  # pyqrack
44
55
  [![Downloads](https://pepy.tech/badge/pyqrack-cpu)](https://pepy.tech/project/pyqrack-cpu) [![Downloads](https://pepy.tech/badge/pyqrack-cpu/month)](https://pepy.tech/project/pyqrack-cpu) [![Downloads](https://static.pepy.tech/badge/pyqrack-cpu/week)](https://pepy.tech/project/pyqrack-cpu)
@@ -47,13 +58,15 @@ Pure Python bindings for the pure C++11 Qrack quantum computer simulator library
47
58
 
48
59
  (**PyQrack** is just pure Qrack.)
49
60
 
50
- <<<<<<< HEAD
51
- This is the **purely CPU-based** variant of PyQrack (with module name `pyqrack-cpu`). This alternate build of PyQrack is provided so that systems that won't use OpenCL anyway (such as because they lack any GPUs or other accelerators like the Intel HD) do not need to install the OpenCL library in order to use PyQrack. In this form, both the PyQrack module and the underlying C++ Qrack library are entirely external **dependency-free.**
61
+ This is the **purely CPU-based** variant of PyQrack (with module name `pyqrack-cpu`). This alternate build of PyQrack is provided so that systems that won't use OpenCL or CUDA anyway (such as because they lack any GPUs or other accelerators like the Intel HD) do not need to install the OpenCL library in order to use PyQrack. In this form, both the PyQrack module and the underlying C++ Qrack library are entirely external **dependency-free.**
62
+
63
+ **If you're looking for Mac ARM support, use the package `pyqrack`, not `pyqrack-cpu`.** Mac officially "deprecated" OpenCL years ago. Hence, accelerator support is not included in ARM-based Mac wheels, and OpenCL installation is **not** required on these systems, but, if you have a CUDA accelerator on ARM-based Mac, you could try the package `pyqrack-cuda` instead.
52
64
 
53
65
  (**If you installing from source,** it doesn't matter whether you use `pyqrack` or `pyqrack-cpu`, because the build version of C++ Qrack you intend to use must already be installed locally.)
54
- =======
55
- **Note, if building from source**: You must build and install [unitaryfund/qrack](https://github.com/unitaryfund/qrack) to build the `main` branch from source. CI/CD builds wheels that contain pre-compiled Qrack binaries, and that is the form published on PyPi. **You must also install OpenCL.**
56
- >>>>>>> main
66
+
67
+ **If you're looking for Mac ARM support, use the package `pyqrack`, not `pyqrack-cpu`.** Mac officially "deprecated" OpenCL years ago. Hence, accelerator support is not included in ARM-based Mac wheels, and OpenCL installation is **not** required on these systems, but, if you have a CUDA accelerator on ARM-based Mac, you could try the package `pyqrack-cuda` instead.
68
+
69
+ **Performance can benefit greatly from following the [Qrack repository "Quick Start" and "Power user considerations."](https://github.com/unitaryfund/qrack/blob/main/README.md#quick-start)**
57
70
 
58
71
  Import and instantiate [`QrackSimulator`](https://github.com/unitaryfund/pyqrack/blob/main/pyqrack/qrack_simulator.py) instances. This simulator can perform arbitrary single qubit and controlled-single-qubit gates, as well as other specific gates like `SWAP`.
59
72
 
@@ -12,8 +12,6 @@ pyqrack/qrack_simulator.py
12
12
  pyqrack/quimb_circuit_type.py
13
13
  pyqrack/qrack_system/__init__.py
14
14
  pyqrack/qrack_system/qrack_system.py
15
- pyqrack/util/__init__.py
16
- pyqrack/util/convert_qiskit_circuit_to_qasm_experiment.py
17
15
  pyqrack_cpu.egg-info/PKG-INFO
18
16
  pyqrack_cpu.egg-info/SOURCES.txt
19
17
  pyqrack_cpu.egg-info/dependency_links.txt
@@ -4,7 +4,7 @@ import os
4
4
  from setuptools import setup
5
5
 
6
6
 
7
- VERSION = "1.34.5"
7
+ VERSION = "1.38.1"
8
8
 
9
9
  # Read long description from README.
10
10
  README_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'README.md')
@@ -14,7 +14,7 @@ with open(README_PATH) as readme_file:
14
14
  setup(
15
15
  name='pyqrack-cpu',
16
16
  version=VERSION,
17
- packages=['pyqrack', 'pyqrack.qrack_system', 'pyqrack.util'],
17
+ packages=['pyqrack', 'pyqrack.qrack_system'],
18
18
  description="pyqrack - Pure Python vm6502q/qrack Wrapper",
19
19
  long_description=README,
20
20
  long_description_content_type='text/markdown',
@@ -1,8 +0,0 @@
1
- # (C) Daniel Strano and the Qrack contributors 2017-2021. All rights reserved.
2
- #
3
- # Use of this source code is governed by an MIT-style license that can be
4
- # found in the LICENSE file or at https://opensource.org/licenses/MIT.
5
-
6
- from .convert_qiskit_circuit_to_qasm_experiment import (
7
- convert_qiskit_circuit_to_qasm_experiment,
8
- )
@@ -1,61 +0,0 @@
1
- _IS_QISKIT_AVAILABLE = True
2
- try:
3
- from qiskit.circuit.quantumcircuit import QuantumCircuit
4
- from qiskit.qobj.qasm_qobj import QasmQobjExperiment, QasmQobjInstruction
5
- except ImportError:
6
- _IS_QISKIT_AVAILABLE = False
7
-
8
-
9
- class QrackQasmQobjInstructionConditional:
10
- def __init__(self, mask, val):
11
- self.mask = mask
12
- self.val = val
13
-
14
-
15
- def convert_qiskit_circuit_to_qasm_experiment(experiment, config=None, header=None):
16
- if not _IS_QISKIT_AVAILABLE:
17
- raise RuntimeError(
18
- "Before trying to convert_circuit_to_qasm_experiment() with QrackSimulator, you must install Qiskit!"
19
- )
20
-
21
- instructions = []
22
- for datum in experiment._data:
23
- qubits = []
24
- for qubit in datum[1]:
25
- qubits.append(experiment.qubits.index(qubit))
26
-
27
- clbits = []
28
- for clbit in datum[2]:
29
- clbits.append(experiment.clbits.index(clbit))
30
-
31
- conditional = None
32
- condition = datum[0].condition
33
- if condition is not None:
34
- if isinstance(condition[0], Clbit):
35
- conditional = experiment.clbits.index(condition[0])
36
- else:
37
- creg_index = experiment.cregs.index(condition[0])
38
- size = experiment.cregs[creg_index].size
39
- offset = 0
40
- for i in range(creg_index):
41
- offset += len(experiment.cregs[i])
42
- mask = ((1 << offset) - 1) ^ ((1 << (offset + size)) - 1)
43
- val = condition[1]
44
- conditional = (
45
- offset
46
- if (size == 1)
47
- else QrackQasmQobjInstructionConditional(mask, val)
48
- )
49
-
50
- instructions.append(
51
- QasmQobjInstruction(
52
- datum[0].name,
53
- qubits=qubits,
54
- memory=clbits,
55
- condition=condition,
56
- conditional=conditional,
57
- params=datum[0].params,
58
- )
59
- )
60
-
61
- return QasmQobjExperiment(config=config, header=header, instructions=instructions)
File without changes
File without changes
File without changes