I'm following a Qiskit tutorial that appear in the following link: https://learning.quantum.ibm.com/tutorial/krylov-subspace-expansion, where a version of the Quantum Krylov subspace diagonalization is exposed. In order to compute the Krylov matrices a modified version of the Hadmard test is used.
I want to compute the ground state energy of the hydrogen molecule using this Hadamard test, but it seems not to work and I cannot find the problem.
As indicated in the tutorial, the Modified Hadmard test need a contolled reference state, and a time evolution gate. I choose to simply put the controlled HF state together with the Trotter evolution gate from the Hamiltonian operator (using the Jordan-Wigner transformation), the part of the code that performs this is as follows:
'''
qr_mod = QuantumRegister(n_qubits + 1)
qc_kryl = QuantumCircuit(qr_mod)
# Initial H+controlled state
qc_kryl.h(ancilla_index)
qc_kryl.compose(controlled_state, list(range(n_qubits + 1)), inplace=True)
qc_kryl.barrier()
# Time Evolution gates
qc_kryl.compose(time_evol_circ, list(range(1, n_qubits + 1)), inplace=True)
qc_kryl.barrier()
# Inverse controlled state
qc_kryl.x(ancilla_index)
qc_kryl.compose(controlled_state.inverse(), list(range(n_qubits + 1)), inplace=True)
qc_kryl.x(ancilla_index)
return qc_kryl
'''
where the contolled HF state is simply the circuit constructed as:
controlled_state = QuantumCircuit(nqubits+1)
controlled_state.cx(0,1)
controlled_state.cx(0,2)
'''
The time evolution circuit on the other hand is constructed as:
from qiskit.synthesis import LieTrotter
qc_evol.compose(PauliEvolutionGate(H_op, time=dt,
synthesis=LieTrotter(reps=num_trotter_steps)),
list(range(n_qubits)), inplace=True)
'''
However after many, many tests, I didn't get a result that convinces me, since violations to the variational principle seem to appear. Does this implementation correctly follow the Hadamard test procedure for measuring expectation values? Am I handling the controlled state preparation and inverse correctly? Should the time evolution circuit be controlled as well for a correct Hadamard test? Are there any optimizations or alternative approaches that would improve accuracy or efficiency?
Any insights or corrections would be greatly appreciated!