Open dhamotharnaf opened 6 months ago
Please could you:
If those still don't help, please can you provide any error message in text - screenshots are very hard to read and can't be searched.
@jakelishman, thank you for your suggestions, and I apologize for the delay. After following your advice, I experimented with two different approaches while creating virtual environments. I am utilizing a GPU EC2 Machine, so instead of qiskit-aer, I am using qiskit-aer-gpu.
Approach 1 (Virtual Environment 1)
Approach 2 (Virtual Environment 2)
Note: I cannot use qiskit 1.0.0 due to a conflict between qiskit-terra and qiskit>=1.0.
I hope this clarifies the steps I took, and I appreciate your ongoing support in resolving this issue.
Error Message
Traceback (most recent call last):
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/QTestMain.py", line 76, in <module>
qx = solver.Solve()
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/QTest.py", line 376, in Solve
w = opt.minimize(fun=self.cost_fn,x0=weights,jac=num_parameters,bounds=[(0, 2 * np.pi) for i in range(num_parameters)])
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/qiskit_gpu_v3/lib/python3.10/site-packages/qiskit/algorithms/optimizers/scipy_optimizer.py", line 154, in minimize
raw_result = minimize(
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/qiskit_gpu_v3/lib/python3.10/site-packages/scipy/optimize/_minimize.py", line 719, in minimize
res = _minimize_cobyla(fun, x0, args, constraints, callback=callback,
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/qiskit_gpu_v3/lib/python3.10/site-packages/scipy/optimize/_cobyla_py.py", line 35, in wrapper
return func(*args, **kwargs)
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/qiskit_gpu_v3/lib/python3.10/site-packages/scipy/optimize/_cobyla_py.py", line 278, in _minimize_cobyla
sf = _prepare_scalar_function(fun, x0, args=args, jac=_jac)
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/qiskit_gpu_v3/lib/python3.10/site-packages/scipy/optimize/_optimize.py", line 402, in _prepare_scalar_function
sf = ScalarFunction(fun, x0, args, grad, hess,
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/qiskit_gpu_v3/lib/python3.10/site-packages/scipy/optimize/_differentiable_functions.py", line 166, in __init__
self._update_fun()
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/qiskit_gpu_v3/lib/python3.10/site-packages/scipy/optimize/_differentiable_functions.py", line 262, in _update_fun
self._update_fun_impl()
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/qiskit_gpu_v3/lib/python3.10/site-packages/scipy/optimize/_differentiable_functions.py", line 163, in update_fun
self.f = fun_wrapped(self.x)
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/qiskit_gpu_v3/lib/python3.10/site-packages/scipy/optimize/_differentiable_functions.py", line 145, in fun_wrapped
fx = fun(np.copy(x), *args)
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/QTest.py", line 260, in cost_fn
p_gg = self.global_ground(weights)
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/QTest.py", line 218, in global_ground
circuit.append(self.full_circuit(parameters), [
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/QTest.py", line 172, in full_circuit
FC.append(self.var_circuit(parameters), tot_qubits_list)
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/QTest.py", line 156, in var_circuit
mcry = MCMT(q.to_gate(), len(control_bits), 1)
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/qiskit_gpu_v3/lib/python3.10/site-packages/qiskit/circuit/library/generalized_gates/mcmt.py", line 85, in __init__
self._build()
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/qiskit_gpu_v3/lib/python3.10/site-packages/qiskit/circuit/library/generalized_gates/mcmt.py", line 98, in _build
mcmt_gate = broadcasted_gate.control(self.num_ctrl_qubits)
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/qiskit_gpu_v3/lib/python3.10/site-packages/qiskit/circuit/gate.py", line 129, in control
return add_control(self, num_ctrl_qubits, label, ctrl_state)
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/qiskit_gpu_v3/lib/python3.10/site-packages/qiskit/circuit/add_control.py", line 61, in add_control
cgate = control(operation, num_ctrl_qubits=num_ctrl_qubits, label=label, ctrl_state=ctrl_state)
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/qiskit_gpu_v3/lib/python3.10/site-packages/qiskit/circuit/add_control.py", line 143, in control
controlled_circ.mcry(
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/qiskit_gpu_v3/lib/python3.10/site-packages/qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py", line 331, in mcry
RYGate(theta).to_matrix(),
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/qiskit_gpu_v3/lib/python3.10/site-packages/qiskit/circuit/gate.py", line 61, in to_matrix
return self.__array__(dtype=complex)
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/qiskit_gpu_v3/lib/python3.10/site-packages/qiskit/circuit/library/standard_gates/ry.py", line 106, in __array__
cos = math.cos(self.params[0] / 2)
File "/home/aakif.akhtar/CVQLS/CVQLS_Qiskit/qiskit_gpu_v3/lib/python3.10/site-packages/qiskit/circuit/parameterexpression.py", line 493, in __float__
raise TypeError(
TypeError: ParameterExpression with unbound parameters (dict_keys([Parameter(w_112)])) cannot be cast to a float.
Environment
What is happening?
I have a variational circuit, and I'm also employing the MCMT method to construct a generalized circuit. My circuit is dependent on an input Hermitian matrix. However, when I attempt to work with a larger-sized matrix, I encounter a significant increase in the number of variational parameters. Consequently, I face an issue where the parameters cannot be cast to a float. Strangely, this problem is not present for smaller parameter sets. I suspect that the problem might be related to the complex numbers I am using. I've been attempting to resolve this issue for a while. I'll attach a screenshot of the error for reference.
How can we reproduce the issue?