qflux 0.0.2__py3-none-any.whl → 0.0.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.

Potentially problematic release.


This version of qflux might be problematic. Click here for more details.

@@ -3,15 +3,14 @@ import numpy.typing as npt
3
3
  from typing import List, Optional, Tuple
4
4
 
5
5
  from qiskit import QuantumCircuit
6
- from qiskit.primitives import Estimator
6
+ from qiskit_aer.primitives import EstimatorV2 as Estimator
7
7
  from qiskit.quantum_info import SparsePauliOp
8
- from qiskit.providers.aer.noise import NoiseModel
9
- from qiskit.providers.fake_provider import FakeSherbrooke
10
-
8
+ from qiskit_aer.noise import NoiseModel
9
+ from qiskit_ibm_runtime.fake_provider import FakeSherbrooke
11
10
 
12
11
  # To change the ansatz, apply_param and measure_der must both be modified.
13
12
  def apply_param(
14
- params: npt.NDArray[np.float_], i: int, qc: QuantumCircuit, N: int
13
+ params: npt.NDArray[np.float64], i: int, qc: QuantumCircuit, N: int
15
14
  ) -> None:
16
15
  """Apply parameter i to the quantum circuit currently constructing the ansatz.
17
16
  The ansatz must be built in a peicewise manner to allow for hadamard tests
@@ -24,7 +23,7 @@ def apply_param(
24
23
  qc (QuantumCircuit): The qiskit ansatz quantum circuit currently being constructed.
25
24
  N (int): Number of qubits
26
25
  """
27
- qc.rx(params[i], i % N))
26
+ qc.rx(params[i], i % N)
28
27
  if i % N == N - 1 and i != len(params) - 1:
29
28
  for i in range(N - 1):
30
29
  qc.cz(i, i + 1)
@@ -43,7 +42,7 @@ def measure_der(i: int, qc: QuantumCircuit, N: int) -> None:
43
42
  qc.cx(N, i % N)
44
43
 
45
44
 
46
- def A_Circuit(params: npt.NDArray[np.float_], i: int, j: int, N: int) -> QuantumCircuit:
45
+ def A_Circuit(params: npt.NDArray[np.float64], i: int, j: int, N: int) -> QuantumCircuit:
47
46
  """Constructs the qiskit quantum circuits used to measure each element of the A_ij matrix.
48
47
 
49
48
  Args:
@@ -73,11 +72,11 @@ def A_Circuit(params: npt.NDArray[np.float_], i: int, j: int, N: int) -> Quantum
73
72
 
74
73
  def Measure_A(
75
74
  init_circ: QuantumCircuit,
76
- params: npt.NDArray[np.float_],
75
+ params: npt.NDArray[np.float64],
77
76
  N: int,
78
77
  shots: int = 2**10,
79
78
  noisy: bool = False,
80
- ) -> npt.NDArray[np.float_]:
79
+ ) -> npt.NDArray[np.float64]:
81
80
  """Create the A_ij matrix through measuring quantum circuits corresponding to each element.
82
81
 
83
82
  Args:
@@ -104,23 +103,19 @@ def Measure_A(
104
103
  coupling_map = device_backend.coupling_map
105
104
  noise_model = NoiseModel.from_backend(device_backend)
106
105
  basis_gates = noise_model.basis_gates
107
- estimator = Estimator(
108
- options={
109
- "shots": shots,
110
- "noise_model": noise_model,
111
- "coupling_map": coupling_map,
112
- "basis_gates": basis_gates,
113
- }
106
+ estimator = Estimator(options={
107
+ "backend_options":{"noise_model": noise_model},
108
+ "run_options":{"shots": shots}}
114
109
  )
115
110
  else:
116
- estimator = Estimator(options={"shots": shots})
117
- result = estimator.run(qc, observable).result()
118
- A[i][i + j] = result.values[0]
111
+ estimator = Estimator(options={"run_options":{"shots": shots}})
112
+ result = estimator.run([(qc, observable)]).result()
113
+ A[i][i + j] = result[0].data.evs
119
114
  return np.array(A)
120
115
 
121
116
 
122
117
  def C_Circuit(
123
- params: npt.NDArray[np.float_],
118
+ params: npt.NDArray[np.float64],
124
119
  i: int,
125
120
  pauli_string: str,
126
121
  N: int,
@@ -162,13 +157,13 @@ def C_Circuit(
162
157
 
163
158
  def Measure_C(
164
159
  init_circ: QuantumCircuit,
165
- params: npt.NDArray[np.float_],
160
+ params: npt.NDArray[np.float64],
166
161
  H: SparsePauliOp,
167
162
  N: int,
168
163
  shots: int = 2**10,
169
164
  evolution_type: str = "real",
170
165
  noisy: bool = False,
171
- ) -> npt.NDArray[np.float_]:
166
+ ) -> npt.NDArray[np.float64]:
172
167
  """Create the C_i vector through measuring quantum circuits corresponding to each element.
173
168
 
174
169
  Args:
@@ -199,19 +194,15 @@ def Measure_C(
199
194
  coupling_map = device_backend.coupling_map
200
195
  noise_model = NoiseModel.from_backend(device_backend)
201
196
  basis_gates = noise_model.basis_gates
202
- estimator = Estimator(
203
- options={
204
- "shots": shots,
205
- "noise_model": noise_model,
206
- "coupling_map": coupling_map,
207
- "basis_gates": basis_gates,
208
- }
209
- )
197
+ estimator = Estimator(options={
198
+ "backend_options":{"noise_model": noise_model},
199
+ "run_options":{"shots": shots}}
200
+ )
210
201
  else:
211
- estimator = Estimator(options={"shots": shots})
212
- result = estimator.run(qc, observable).result()
202
+ estimator = Estimator(options={"run_options":{"shots": shots}})
203
+ result = estimator.run([(qc, observable)]).result()
213
204
 
214
- C[i] -= 1 / 2 * H.coeffs[pauli_string].real * result.values[0]
205
+ C[i] -= 1 / 2 * H.coeffs[pauli_string].real * result[0].data.evs
215
206
  return np.array(C)
216
207
 
217
208
 
@@ -233,7 +224,7 @@ def pauli_measure(qc: QuantumCircuit, pauli_string: str) -> None:
233
224
 
234
225
 
235
226
  def Construct_Ansatz(
236
- init_circ: QuantumCircuit, params: npt.NDArray[np.float_], N: int
227
+ init_circ: QuantumCircuit, params: npt.NDArray[np.float64], N: int
237
228
  ) -> QuantumCircuit:
238
229
  """Construct the full ansatz for use in measuring observables.
239
230
 
@@ -258,7 +249,7 @@ def Construct_Ansatz(
258
249
 
259
250
  def ansatz_energy(
260
251
  init_circ: QuantumCircuit,
261
- params: npt.NDArray[np.float_],
252
+ params: npt.NDArray[np.float64],
262
253
  H: SparsePauliOp,
263
254
  shots: int = 2**14,
264
255
  noisy: bool = False,
@@ -282,19 +273,15 @@ def ansatz_energy(
282
273
  coupling_map = device_backend.coupling_map
283
274
  noise_model = NoiseModel.from_backend(device_backend)
284
275
  basis_gates = noise_model.basis_gates
285
- estimator = Estimator(
286
- options={
287
- "shots": shots,
288
- "noise_model": noise_model,
289
- "coupling_map": coupling_map,
290
- "basis_gates": basis_gates,
291
- }
292
- )
276
+ estimator = Estimator(options={
277
+ "backend_options":{"noise_model": noise_model},
278
+ "run_options":{"shots": shots}}
279
+ )
293
280
  else:
294
- estimator = Estimator(options={"shots": shots})
281
+ estimator = Estimator(options={"run_options":{"shots": shots}})
295
282
  qc = Construct_Ansatz(init_circ, params, N)
296
- result = estimator.run(qc, H).result()
297
- return result.values[0], result.metadata[0]["variance"]
283
+ result = estimator.run([(qc, H)]).result()
284
+ return result[0].data.evs, result[0].data.stds
298
285
 
299
286
 
300
287
  def VarQRTE(
@@ -305,7 +292,7 @@ def VarQRTE(
305
292
  init_circ: Optional[QuantumCircuit] = None,
306
293
  shots: int = 2**10,
307
294
  noisy: bool = False,
308
- ) -> List[npt.NDArray[np.float_]]:
295
+ ) -> List[npt.NDArray[np.float64]]:
309
296
  """The Variational Quantum Real Time Evolution (VarQRTE) algorithm. This uses quantum circuits to measure
310
297
  the elements of two objects, the A_ij matrix and the C_i vector.
311
298
 
@@ -368,7 +355,7 @@ def VarQITE(
368
355
  init_circ: Optional[QuantumCircuit] = None,
369
356
  shots: int = 2**10,
370
357
  noisy: bool = False,
371
- ) -> List[npt.NDArray[np.float_]]:
358
+ ) -> List[npt.NDArray[np.float64]]:
372
359
  """The Variational Quantum Imaginary Time Evolution (VarQITE) algorithm. This uses quantum circuits to measure
373
360
  the elements of two objects, the A_ij matrix and the C_i vector.
374
361
 
@@ -220,7 +220,7 @@ class QubitDynamicsCS(DynamicsCS):
220
220
 
221
221
 
222
222
  def propagate_qmatvec(self, backend=None, n_shots: int = 1024, hamiltonian_matrix=None, initial_state=None):
223
- """
223
+ r"""
224
224
  Function to propagate dynamics object with the qubit matvec method.
225
225
 
226
226
  Args:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qflux
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: qflux is a package for running quantum dynamics calculations on quantum devices.
5
5
  Author-email: Brandon Allen <brandon.allen@yale.edu>, Delmar Cabral <delmar.azevedocabral@yale.edu>, Alexander Soudackov <alexander.soudackov@yale.edu>, Anton Morgunov <anton@ischemist.com>
6
6
  License: MIT
@@ -5,12 +5,12 @@ qflux/GQME/params.py,sha256=u7mHRdbbf88ccTIvw9Hb4AunlfNBrzara0OZTL80vwk,1822
5
5
  qflux/GQME/readwrite.py,sha256=JUUEsDL8Ep705P8iwlQ4YjAm7MswQ-eNpH1wa8_P-_I,3583
6
6
  qflux/GQME/tdvp.py,sha256=32Z_cLJornzM4D63nmqekhwtc-OosrQcZhIeEZAqq9s,7136
7
7
  qflux/GQME/tt_tfd.py,sha256=-RPH9aiCinLzG0VdZo43UBVKWcuoplkFmi77oOtv5zU,15204
8
- qflux/closed_systems/VarQTE.py,sha256=8Znw6R0jBsHnV_e5eGGMumcSG9HlUfRltuqevlBka9A,17956
8
+ qflux/closed_systems/VarQTE.py,sha256=rNDFnRmF_jDv-wSSaBnFp0ZwrgjOJ3NdqyoT4WUlX4E,17840
9
9
  qflux/closed_systems/__init__.py,sha256=CBnnqCBp0MD7jCGq1P0nzwCyR3okp4jkC8tvqWUTBCY,472
10
10
  qflux/closed_systems/classical_methods.py,sha256=Etqjd9OkqCgPzhC2-FgQWlIiTu66V2_7LRftPDwBrb8,15882
11
11
  qflux/closed_systems/custom_execute.py,sha256=Mk24DEvEbQlnu52MqhnSOGBpplHoAMz5__AcBKo1E_4,656
12
12
  qflux/closed_systems/hamiltonians.py,sha256=ArdljgB7ASUq5QIKdN8CRdhf7b_2nFyb8OPacOGGvEs,3156
13
- qflux/closed_systems/qubit_methods.py,sha256=NPC0pLM8Jok4bpkTBcDvDNO3YqsCpw9S6MVMxRHwcuU,10882
13
+ qflux/closed_systems/qubit_methods.py,sha256=2TFeR7lxAqAu3CYUPQqUJtN9bMPpKTukHgGohiJJASk,10883
14
14
  qflux/closed_systems/spin_dynamics_oo.py,sha256=cn4aRM3wYkP6CBbL-LhlUMR4dqQSQK7bpSV-twSzFbU,13925
15
15
  qflux/closed_systems/spin_propagators.py,sha256=pMg4ttThkXw2kzBlY2yDpdomTn-7alRtpKUAxD-vSl8,11496
16
16
  qflux/closed_systems/utils.py,sha256=eiB5V0xvi43-jC35nKl2kMY_vr9r_-2njNn5qPLh494,6975
@@ -32,8 +32,8 @@ qflux/variational_methods/qmad/ansatz.py,sha256=2ttVOrueLYycyXaBy1uxPkaTNEtkctL9
32
32
  qflux/variational_methods/qmad/ansatzVect.py,sha256=OJdRDhKBYou93fwetri5KXFoAj9N4cdjj799Nqu-qmE,2934
33
33
  qflux/variational_methods/qmad/effh.py,sha256=l74femDGDDVCiHerfDDj2k30phyrYIlI_ssn4YU426g,3722
34
34
  qflux/variational_methods/qmad/solver.py,sha256=1B9DpcuT7bpKcIWt1kHkxT3-gwQECdEzKFcBtJlFYDg,12751
35
- qflux-0.0.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
36
- qflux-0.0.2.dist-info/METADATA,sha256=1rRhjqS2949C8qCYtHxjAnemMNy7vEr-N6p_ZQ-B3qg,6871
37
- qflux-0.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
38
- qflux-0.0.2.dist-info/top_level.txt,sha256=GZgw1Z1DZDPg78NCF1dXCHw_f4usRh5HP5yLtgECIpo,6
39
- qflux-0.0.2.dist-info/RECORD,,
35
+ qflux-0.0.3.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
36
+ qflux-0.0.3.dist-info/METADATA,sha256=sZdUGSirgVQ6W6yT5E-jZp4BTVCltcDlme9AJ6ILGx4,6871
37
+ qflux-0.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
38
+ qflux-0.0.3.dist-info/top_level.txt,sha256=GZgw1Z1DZDPg78NCF1dXCHw_f4usRh5HP5yLtgECIpo,6
39
+ qflux-0.0.3.dist-info/RECORD,,
File without changes