Error running qiskit circuit on Azure quantum
Ben Corbett
20
Reputation points
I'm trying to run a qiskit program on Azure's quantum backends, but I'm running into a strange error. This occurs with all of the azure.quantum.qiskit backends.
pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
isa_circuit = pm.run(myCircuit)
mapped_observables = [mySparsePauli.apply_layout(isa_circuit.layout)]
estimator = EstimatorV2(mode=backend)
estimator.options.default_shots = shots
estimator_job = estimator.run([(isa_circuit, mapped_observables)])
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[24], line 1
----> 1 estimator_job_result, estimator_pub_result = estimate_T(ansatz.assign_parameters(params), backend, 10000, draw=True)
2 T_expectation = estimator_pub_result.data.evs[0]
3 print(f"<T> = {T_expectation}")
Cell In[2], line 48, in estimate_T(qc, backend, shots, draw)
46 estimator = EstimatorV2(mode=backend)
47 estimator.options.default_shots = shots
---> 48 estimator_job = estimator.run([(isa_circuit, mapped_observables)])
50 print(f">>> Job ID: {estimator_job.job_id()}")
52 estimator_job_result = estimator_job.result()
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/qiskit_ibm_runtime/estimator.py:149, in EstimatorV2.run(self, pubs, precision)
147 coerced_pubs = [EstimatorPub.coerce(pub, precision) for pub in pubs]
148 validate_estimator_pubs(coerced_pubs)
--> 149 return self._run(coerced_pubs)
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/qiskit_ibm_runtime/base_primitive.py:190, in BasePrimitiveV2._run(self, pubs)
181 if isinstance(self._service, QiskitRuntimeService):
182 return self._service._run(
183 program_id=self._program_id(),
184 options=runtime_options,
(...)
187 result_decoder=DEFAULT_DECODERS.get(self._program_id()),
188 )
--> 190 return self._service._run(
191 program_id=self._program_id(), # type: ignore[arg-type]
192 options=runtime_options,
193 inputs=primitive_inputs,
194 )
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/qiskit_ibm_runtime/fake_provider/local_service.py:169, in QiskitRuntimeLocalService._run(self, program_id, inputs, options)
153 """Execute the runtime program.
154
155 Args:
(...)
166 NotImplementedError: If using V2 primitives.
167 """
168 if isinstance(options, Dict):
--> 169 qrt_options = copy.deepcopy(options)
170 else:
171 qrt_options = asdict(options)
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py:136, in deepcopy(x, memo, _nil)
134 copier = _deepcopy_dispatch.get(cls)
135 if copier is not None:
--> 136 y = copier(x, memo)
137 else:
138 if issubclass(cls, type):
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py:221, in _deepcopy_dict(x, memo, deepcopy)
219 memo[id(x)] = y
220 for key, value in x.items():
--> 221 y[deepcopy(key, memo)] = deepcopy(value, memo)
222 return y
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py:162, in deepcopy(x, memo, _nil)
160 y = x
161 else:
--> 162 y = _reconstruct(x, memo, *rv)
164 # If is its own copy, don't memoize.
165 if y is not x:
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py:259, in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy)
257 if state is not None:
258 if deep:
--> 259 state = deepcopy(state, memo)
260 if hasattr(y, '__setstate__'):
261 y.__setstate__(state)
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py:136, in deepcopy(x, memo, _nil)
134 copier = _deepcopy_dispatch.get(cls)
135 if copier is not None:
--> 136 y = copier(x, memo)
137 else:
138 if issubclass(cls, type):
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py:221, in _deepcopy_dict(x, memo, deepcopy)
219 memo[id(x)] = y
220 for key, value in x.items():
--> 221 y[deepcopy(key, memo)] = deepcopy(value, memo)
222 return y
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py:162, in deepcopy(x, memo, _nil)
160 y = x
161 else:
--> 162 y = _reconstruct(x, memo, *rv)
164 # If is its own copy, don't memoize.
165 if y is not x:
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py:259, in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy)
257 if state is not None:
258 if deep:
--> 259 state = deepcopy(state, memo)
260 if hasattr(y, '__setstate__'):
261 y.__setstate__(state)
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py:136, in deepcopy(x, memo, _nil)
134 copier = _deepcopy_dispatch.get(cls)
135 if copier is not None:
--> 136 y = copier(x, memo)
137 else:
138 if issubclass(cls, type):
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py:201, in _deepcopy_tuple(x, memo, deepcopy)
200 def _deepcopy_tuple(x, memo, deepcopy=deepcopy):
--> 201 y = [deepcopy(a, memo) for a in x]
202 # We're not going to put the tuple in the memo, but it's still important we
203 # check for it, in case the tuple contains recursive mutable structures.
204 try:
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py:136, in deepcopy(x, memo, _nil)
134 copier = _deepcopy_dispatch.get(cls)
135 if copier is not None:
--> 136 y = copier(x, memo)
137 else:
138 if issubclass(cls, type):
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py:221, in _deepcopy_dict(x, memo, deepcopy)
219 memo[id(x)] = y
220 for key, value in x.items():
--> 221 y[deepcopy(key, memo)] = deepcopy(value, memo)
222 return y
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py:151, in deepcopy(x, memo, _nil)
149 reductor = getattr(x, "__reduce_ex__", None)
150 if reductor is not None:
--> 151 rv = reductor(4)
152 else:
153 reductor = getattr(x, "__reduce__", None)
TypeError: cannot pickle 'builtins.TargetProfile' object
Sign in to answer