Closed poojithurao closed 11 months ago
@cjao this is a wired bug, still getting this
from qiskit.algorithms import QAOA
from qiskit.algorithms.optimizers import COBYLA
from qiskit import Aer
import covalent as ct
@ct.electron
def get_qaoa():
return QAOA(COBYLA(), quantum_instance=Aer.get_backend('statevector_simulator'))
@ct.lattice
def qaoa_covalent():
qaoa = get_qaoa()
return None
ct.dispatch(qaoa_covalent)()
```python ---> 16 ct.dispatch(qaoa_covalent)() File [/opt/homebrew/Caskroom/miniconda/base/envs/qc/lib/python3.8/site-packages/covalent/_dispatcher_plugins/local.py:127](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniconda/base/envs/qc/lib/python3.8/site-packages/covalent/_dispatcher_plugins/local.py:127), in LocalDispatcher.dispatch..wrapper(*args, **kwargs) 123 nonlocal disable_run 125 lattice = deepcopy(orig_lattice) --> 127 lattice.build_graph(*args, **kwargs) 129 # Serialize the transport graph to JSON 130 json_lattice = lattice.serialize_to_json() File [/opt/homebrew/Caskroom/miniconda/base/envs/qc/lib/python3.8/site-packages/covalent/_workflow/lattice.py:216](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniconda/base/envs/qc/lib/python3.8/site-packages/covalent/_workflow/lattice.py:216), in Lattice.build_graph(self, *args, **kwargs) 212 self.kwargs = {k: TransportableObject.make_transportable(v) for k, v in kwargs.items()} 214 self.transport_graph.reset() --> 216 workflow_function = self.workflow_function.get_deserialized() 218 named_args, named_kwargs = get_named_params(workflow_function, self.args, self.kwargs) 219 self.named_args = named_args File [/opt/homebrew/Caskroom/miniconda/base/envs/qc/lib/python3.8/site-packages/covalent/_workflow/transportable_object.py:255](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniconda/base/envs/qc/lib/python3.8/site-packages/covalent/_workflow/transportable_object.py:255), in TransportableObject.get_deserialized(self) 245 def get_deserialized(self) -> Callable: 246 """ 247 Get the deserialized transportable object. ... --> 130 if not self.aer: 131 try: 132 from qiskit.providers import aer ```
Cloud pickling seems to work
import cloudpickle as pickle
a=pickle.dumps(QAOA(COBYLA(), quantum_instance=Aer.get_backend('statevector_simulator')))
pickle.loads(a)
So not sure where the recursion is happening.
@santoshkumarradha Feel free to assign this to me, but I probably won't be able to dig into it until mid next week at the earliest.
@santoshkumarradha How exactly did you fix it? I would appreciate your help.
It is still not working with the following code:
from qiskit.algorithms import QAOA
from qiskit.algorithms.optimizers import COBYLA
from qiskit import Aer
import covalent as ct
import cloudpickle
@ct.electron
def get_qaoa():
qaoa = QAOA(COBYLA(), quantum_instance=Aer.get_backend('statevector_simulator'))
return cloudpickle.dumps(qaoa)
@ct.lattice
def qaoa_covalent():
qaoa_serialized = get_qaoa()
qaoa = cloudpickle.loads(qaoa_serialized)
return None
ct.dispatch(qaoa_covalent)()
Environment
What is happening?
I am using
QAOA
from theqiskit.algorithms
package.I created an electron function which just returns the QAOA object and called it inside a lattice function. I tried viewing the lattice through the .draw() function, but it is throwing
RecursionError: maximum recursion depth exceeded
error.How can we reproduce the issue?
What should happen?
A proper Workflow graph was expected.
Any suggestions?
No response