I was studying VQLS in https://qiskit.org/textbook/ch-paper-implementations/vqls.html and since I could not understand the circuit created by the new Hadamard test (special_had_test
in the code), since it has great difference with the structure mentioned in the paper Variational Quantum Linear Solver, I followed the paper and created the Hadamard test circuit myself to calculate the local cost functions.The circuit is just as the fig. 9(c) in the paper.
Though my code behaved perfectly under AersSimulator
since it has no noise, when I change the backend to fake_provider
using GenericBackendV2()
, the performance of my code is far from satisfactory. I test the cost function circuit with the correct parameters calculated by the Aer
backend for 10 times. I got 10 different costs varied from -0.03679894195193811 to 0.35655842924812864. I tried the code in the qiskit VQLS tutorial, it also has this problem. If I choose fake_provider
, it will give out a poor result. I have two questions as follows:
- How is the
special_had_test
circuit constructed in the qiskit VQLS tutorial? How can thecontrol_fixed_ansatz
calculate $|\langle b|\psi\rangle|^2$ with a Hadamard test? - If I use the real quantum computer as the backend, will I still have this problem? how can I solve this problem? If I change the optimizer (I still use COBYLA as the method in
scipy.minimize
), like using the circuit to calculate the gradient, will the result be better?