Closed piyush2468 closed 5 years ago
Please post the whole program that's giving this error (the circuit you are trying to sweep), also what version of python are you running this on?
I'm trying normal parameterized circuit to sweep, also I'm running it in a python notebook with latest dependency. Link - https://www.kaggle.com/piyush1912/cirq-quantum Please let me know where I'm getting it wrong .
Try using cirq.Simulator
instead of cirq.google.XmonSimulator
. Double-check that you have resolved all parameters.
I think the issue here is that the sweep you specified didn't resolve all the parameters present in the circuit, and the xmon simulator is giving an extremely confusing error instead of failing sooner. I've opened https://github.com/quantumlib/Cirq/issues/1515 to fix this.
I should probably also open an issue on sympy asking them to intercept numpy ufuncs.
I think there's some issue with sympy, also when I've tried changing Xmon to cirq.Simulator it's giving type error which is different from last time attribute error. ufunc 'multiply' output (typecode 'O') could not be coerced to provided output parameter (typecode 'F') according to the casting rule ''same_kind''
Okay, that makes sense. I think you're forgetting to sweep over a parameter because that error says numpy encountered an object (e.g. Symbol) being added into a float array.
Okay, looking over the web page you linked to, I think the issue is that it is mixing conventions from cirq 0.4 with conventions from cirq 0.5. When I try to run it locally I get new errors about gate set requirements for XmonSimulator.
Try using cirq.Symbol
(which is what is used in 0.4) instead of sympy.Symbol
(0.5).
cirq.symbol has started working on sweeping the circuit but the question remains on the parameter error or casting error which have been caused by Sympy. 0.4 works for now but there's a problem with sympy which needs to be opened. As you can see from the page I've linked now it's working as we have parameterized the circuit using cirq not Sympy.
If you were using the dev version of cirq, the sympy variant would have worked. The only remaining issue is for the error message to be improved (which is in another issue). So I am closing this one.
sweep = (cirq.Linspace(key='alpha', start=0.1, stop=0.9, length=5)
AttributeError: 'Mul' object has no attribute 'cos'
![Uploading Screenshot_20190410-170930__01.jpg…]()