pyqrack-cuda 1.33.2__tar.gz → 1.34.0__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.
Files changed (26) hide show
  1. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/Makefile +1 -1
  2. {pyqrack_cuda-1.33.2/pyqrack_cuda.egg-info → pyqrack_cuda-1.34.0}/PKG-INFO +1 -1
  3. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/pyqrack/qrack_simulator.py +66 -54
  4. pyqrack_cuda-1.34.0/pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.so +0 -0
  5. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0/pyqrack_cuda.egg-info}/PKG-INFO +1 -1
  6. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/pyqrack_cuda.egg-info/SOURCES.txt +1 -0
  7. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/setup.py +4 -4
  8. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/LICENSE +0 -0
  9. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/MANIFEST.in +0 -0
  10. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/README.md +0 -0
  11. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/pyproject.toml +0 -0
  12. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/pyqrack/__init__.py +0 -0
  13. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/pyqrack/neuron_activation_fn.py +0 -0
  14. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/pyqrack/pauli.py +0 -0
  15. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/pyqrack/qrack_circuit.py +0 -0
  16. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/pyqrack/qrack_neuron.py +0 -0
  17. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/pyqrack/qrack_system/__init__.py +0 -0
  18. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/pyqrack/qrack_system/qrack_system.py +0 -0
  19. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/pyqrack/quimb_circuit_type.py +0 -0
  20. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/pyqrack/util/__init__.py +0 -0
  21. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/pyqrack/util/convert_qiskit_circuit_to_qasm_experiment.py +0 -0
  22. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/pyqrack_cuda.egg-info/dependency_links.txt +0 -0
  23. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/pyqrack_cuda.egg-info/not-zip-safe +0 -0
  24. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/pyqrack_cuda.egg-info/requires.txt +0 -0
  25. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/pyqrack_cuda.egg-info/top_level.txt +0 -0
  26. {pyqrack_cuda-1.33.2 → pyqrack_cuda-1.34.0}/setup.cfg +0 -0
@@ -18,7 +18,7 @@ help:
18
18
  build-deps:
19
19
  ifneq ($(OS),Windows_NT)
20
20
  ifeq ($(QRACK_PRESENT),)
21
- git clone https://github.com/unitaryfund/qrack.git; cd qrack; git checkout 7bdd878a99cc5f5fb6e3a387d4a3f0b119612194; cd ..
21
+ git clone https://github.com/unitaryfund/qrack.git; cd qrack; git checkout d102dd0b166452c47027698eb25ef1430ff50bed; cd ..
22
22
  endif
23
23
  mkdir -p qrack/build
24
24
  ifeq ($(UNAME_S),Linux)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyqrack-cuda
3
- Version: 1.33.2
3
+ Version: 1.34.0
4
4
  Summary: pyqrack - Pure Python vm6502q/qrack Wrapper
5
5
  Home-page: https://github.com/vm6502q/pyqrack
6
6
  Author: Daniel Strano
@@ -21,6 +21,11 @@ try:
21
21
  except ImportError:
22
22
  _IS_QISKIT_AVAILABLE = False
23
23
 
24
+ try:
25
+ from qiskit import qasm3
26
+ except ImportError:
27
+ pass
28
+
24
29
  _IS_NUMPY_AVAILABLE = True
25
30
  try:
26
31
  import numpy as np
@@ -3187,9 +3192,7 @@ class QrackSimulator:
3187
3192
 
3188
3193
  stabilizer_count = int(lines[2])
3189
3194
 
3190
- reg = QuantumRegister(stabilizer_qubits, name="q")
3191
- circ_qubits = [Qubit(reg, i) for i in range(stabilizer_qubits)]
3192
- clifford_circ = QuantumCircuit(reg)
3195
+ clifford_circ = None
3193
3196
  line_number = 3
3194
3197
  for i in range(stabilizer_count):
3195
3198
  shard_map_size = int(lines[line_number])
@@ -3201,10 +3204,6 @@ class QrackSimulator:
3201
3204
  line_number += 1
3202
3205
  shard_map[int(line[0])] = int(line[1])
3203
3206
 
3204
- sub_reg = []
3205
- for index, _ in sorted(shard_map.items(), key=lambda x: x[1]):
3206
- sub_reg.append(circ_qubits[index])
3207
-
3208
3207
  line_number += 1
3209
3208
  tableau = []
3210
3209
  row_count = shard_map_size << 1
@@ -3221,16 +3220,8 @@ class QrackSimulator:
3221
3220
  tableau = np.array(tableau, bool)
3222
3221
 
3223
3222
  clifford = Clifford(tableau, validate=False, copy=False)
3224
- circ = clifford.to_circuit()
3225
-
3226
- for instr in circ.data:
3227
- qubits = instr.qubits
3228
- n_qubits = []
3229
- for qubit in qubits:
3230
- n_qubits.append(sub_reg[circ.find_bit(qubit)[0]])
3231
- instr.qubits = tuple(n_qubits)
3232
- clifford_circ.data.append(instr)
3233
- del circ
3223
+ clifford_circ = clifford.to_circuit()
3224
+ clifford_circ = QrackSimulator._reorder_qubits(clifford_circ, shard_map)
3234
3225
 
3235
3226
  non_clifford_gates = []
3236
3227
  g = 0
@@ -3291,6 +3282,35 @@ class QrackSimulator:
3291
3282
 
3292
3283
  return circ
3293
3284
 
3285
+ def _reorder_qubits(circuit, mapping):
3286
+ """
3287
+ Reorders qubits in the circuit according to the given mapping using SWAP gates.
3288
+ (Thanks to "Elara," an OpenAI GPT, for this implementation)
3289
+
3290
+ Parameters:
3291
+ - circuit (QuantumCircuit): The circuit to modify.
3292
+ - mapping (dict): Dictionary mapping internal qubit indices to logical qubit indices.
3293
+
3294
+ Returns:
3295
+ - QuantumCircuit: The modified circuit with qubits reordered.
3296
+ """
3297
+ swaps = []
3298
+
3299
+ # Determine swaps to fix the order
3300
+ for logical_index in sorted(mapping):
3301
+ internal_index = mapping[logical_index]
3302
+ if logical_index != internal_index:
3303
+ swaps.append((logical_index, internal_index))
3304
+ # Update the reverse mapping for subsequent swaps
3305
+ mapping[logical_index] = logical_index
3306
+ mapping[internal_index] = internal_index
3307
+
3308
+ # Apply the swaps to the circuit
3309
+ for qubit1, qubit2 in swaps:
3310
+ circuit.swap(qubit1, qubit2)
3311
+
3312
+ return circuit
3313
+
3294
3314
  def file_to_optimized_qiskit_circuit(filename):
3295
3315
  """Convert an output state file to a Qiskit circuit
3296
3316
 
@@ -3397,16 +3417,14 @@ class QrackSimulator:
3397
3417
 
3398
3418
  if (np.isclose(np.abs(non_clifford[0][0]), 0) and np.isclose(np.abs(non_clifford[1][1]), 0)):
3399
3419
  # If we're buffering full negation (plus phase), the control qubit can be dropped.
3400
- c = QuantumCircuit(1)
3420
+ c = QuantumCircuit(circ.qubits)
3401
3421
  if op.name == "cx":
3402
- c.x(0)
3422
+ c.x(qubits[1])
3403
3423
  elif op.name == "cy":
3404
- c.y(0)
3424
+ c.y(qubits[1])
3405
3425
  else:
3406
- c.z(0)
3407
- instr = c.data[0]
3408
- instr.qubits = (qubits[1],)
3409
- circ.data[j] = copy.deepcopy(instr)
3426
+ c.z(qubits[1])
3427
+ circ.data[j] = copy.deepcopy(c.data[0])
3410
3428
 
3411
3429
  j += 1
3412
3430
  continue
@@ -3417,11 +3435,9 @@ class QrackSimulator:
3417
3435
  break
3418
3436
 
3419
3437
  # We're blocked, so we insert our buffer at this place in the circuit definition.
3420
- c = QuantumCircuit(1)
3421
- c.unitary(non_clifford, 0)
3422
- instr = c.data[0]
3423
- instr.qubits = (qubits[0],)
3424
- circ.data.insert(j, copy.deepcopy(instr))
3438
+ c = QuantumCircuit(circ.qubits)
3439
+ c.unitary(non_clifford, qubits[0])
3440
+ circ.data.insert(j, copy.deepcopy(c.data[0]))
3425
3441
 
3426
3442
  non_clifford = np.copy(ident)
3427
3443
  break
@@ -3508,21 +3524,18 @@ class QrackSimulator:
3508
3524
  orig_instr = circ.data[j]
3509
3525
  del circ.data[j]
3510
3526
 
3511
- h = QuantumCircuit(1)
3512
- h.h(0)
3513
- instr = h.data[0]
3514
-
3515
3527
  # We're replacing CNOT with CNOT in the opposite direction plus four H gates
3516
- instr.qubits = (qubits[0],)
3517
- circ.data.insert(j, copy.deepcopy(instr))
3518
- instr.qubits = (qubits[1],)
3519
- circ.data.insert(j, copy.deepcopy(instr))
3520
- orig_instr.qubits = (qubits[1], qubits[0])
3521
- circ.data.insert(j, copy.deepcopy(orig_instr))
3522
- instr.qubits = (qubits[0],)
3523
- circ.data.insert(j, copy.deepcopy(instr))
3524
- instr.qubits = (qubits[1],)
3525
- circ.data.insert(j, copy.deepcopy(instr))
3528
+ rep = QuantumCircuit(circ.qubits)
3529
+ rep.h(qubits[0])
3530
+ circ.data.insert(j, copy.deepcopy(rep.data[0]))
3531
+ rep.h(qubits[1])
3532
+ circ.data.insert(j, copy.deepcopy(rep.data[1]))
3533
+ rep.cx(qubits[1], qubits[0])
3534
+ circ.data.insert(j, copy.deepcopy(rep.data[2]))
3535
+ rep.h(qubits[0])
3536
+ circ.data.insert(j, copy.deepcopy(rep.data[3]))
3537
+ rep.h(qubits[1])
3538
+ circ.data.insert(j, copy.deepcopy(rep.data[4]))
3526
3539
 
3527
3540
  j += 4
3528
3541
  continue
@@ -3533,11 +3546,9 @@ class QrackSimulator:
3533
3546
  break
3534
3547
 
3535
3548
  # We're blocked, so we insert our buffer at this place in the circuit definition.
3536
- c = QuantumCircuit(1)
3537
- c.unitary(non_clifford, 0)
3538
- instr = c.data[0]
3539
- instr.qubits = (qubits[0],)
3540
- circ.data.insert(j + 1, copy.deepcopy(instr))
3549
+ c = QuantumCircuit(circ.qubits)
3550
+ c.unitary(non_clifford, qubits[0])
3551
+ circ.data.insert(j + 1, copy.deepcopy(c.data[0]))
3541
3552
 
3542
3553
  break
3543
3554
 
@@ -3549,18 +3560,19 @@ class QrackSimulator:
3549
3560
  j -= 1
3550
3561
  continue
3551
3562
 
3552
- c = QuantumCircuit(1)
3553
- c.unitary(to_inject, 0)
3554
- instr = c.data[0]
3555
- instr.qubits = (qubits[0],)
3556
- circ.data[j] = copy.deepcopy(instr)
3563
+ c = QuantumCircuit(circ.qubits)
3564
+ c.unitary(to_inject, qubits[0])
3565
+ circ.data.insert(j, copy.deepcopy(c.data[0]))
3557
3566
  j -= 1
3558
3567
 
3559
3568
  basis_gates=["u", "rz", "h", "x", "y", "z", "sx", "sxdg", "sy", "sydg", "s", "sdg", "t", "tdg", "cx", "cy", "cz", "swap"]
3560
3569
  circ = transpile(circ, basis_gates=basis_gates, optimization_level=2)
3561
3570
 
3562
3571
  #Eliminate unused ancillae
3563
- qasm = circ.qasm()
3572
+ try:
3573
+ qasm = qasm3.dumps(circ)
3574
+ except:
3575
+ qasm = circ.qasm()
3564
3576
  qasm = qasm.replace("qreg q[" + str(circ.width()) + "];", "qreg q[" + str(width) + "];")
3565
3577
  highest_index = max([int(x) for x in re.findall(r"\[(.*?)\]", qasm) if x.isdigit()])
3566
3578
  if highest_index != width:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyqrack-cuda
3
- Version: 1.33.2
3
+ Version: 1.34.0
4
4
  Summary: pyqrack - Pure Python vm6502q/qrack Wrapper
5
5
  Home-page: https://github.com/vm6502q/pyqrack
6
6
  Author: Daniel Strano
@@ -13,6 +13,7 @@ pyqrack/qrack_simulator.py
13
13
  pyqrack/quimb_circuit_type.py
14
14
  pyqrack/qrack_system/__init__.py
15
15
  pyqrack/qrack_system/qrack_system.py
16
+ pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.so
16
17
  pyqrack/util/__init__.py
17
18
  pyqrack/util/convert_qiskit_circuit_to_qasm_experiment.py
18
19
  pyqrack_cuda.egg-info/PKG-INFO
@@ -7,7 +7,7 @@ from setuptools import setup
7
7
  from setuptools.command.build_py import build_py
8
8
 
9
9
 
10
- VERSION = "1.33.2"
10
+ VERSION = "1.34.0"
11
11
 
12
12
  # Read long description from README.
13
13
  README_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'README.md')
@@ -64,15 +64,15 @@ setup(
64
64
  "Programming Language :: Python :: 3.10",
65
65
  "Programming Language :: Python :: 3.11",
66
66
  "Programming Language :: Python :: 3.12",
67
- "Topic :: Scientific/Engineering"
67
+ "Topic :: Scientific/Engineering",
68
68
  ],
69
69
  keywords="pyqrack qrack simulator quantum gpu",
70
70
  install_requires=[],
71
71
  setup_requires=['cmake'],
72
72
  extras_require={
73
73
  "dev": [
74
- "pytest>=7.3.1"
75
- ]
74
+ "pytest>=7.3.1",
75
+ ],
76
76
  },
77
77
  include_package_data=True,
78
78
  zip_safe=False
File without changes
File without changes
File without changes
File without changes