4
$\begingroup$

How do I optimize HHL algorithm in Qiskit?

I tried to follow this tutorial on HHL in Qiskit. My project requires solving a very specific type of linear equations $Ax=b$ like the one below.

b = np.array( [ 0.   ,  0.   ,  2.25 ,  0.   ,  0.   ,  0.   , -4.285,  0.   ])
A = np.array([[ 1.   ,  0.333,  0.   ,  0.   ,  0.   ,  0.   ,  0.   ,  0.   ],
              [ 0.   ,  1.   ,  0.   ,  0.   ,  0.   ,  0.   ,  0.   ,  0.   ],
              [ 0.   ,  0.   ,  1.   ,  0.   ,  0.   ,  0.   ,  0.   ,  0.   ],
              [ 0.   ,  0.   ,  0.143,  1.   ,  0.   ,  0.   ,  0.   ,  0.   ],
              [-0.333, -1.   ,  0.   ,  0.   ,  1.   ,  0.333,  0.   ,  0.   ],
              [-0.25 , -1.5  , -0.25 ,  0.   ,  0.   ,  1.   ,  0.   ,  0.   ],
              [ 0.   , -0.562, -0.875, -0.562,  0.   ,  0.   ,  1.   ,  0.   ],
              [ 0.   ,  0.   , -1.   , -0.143,  0.   ,  0.   ,  0.143,  1.   ]])

However, I only obtain a fidelity of around 0.7 - 0.8, which is not good enough for what I would like to do.

I notice the tutorial has a function called create_eigs with input parameters num_ancillae, num_time_slices, negative_evals.

def create_eigs(matrix, num_ancillae, num_time_slices, negative_evals):
    ...

What are they really? And what are their appropriate values?

$\endgroup$
1
$\begingroup$

I have a partial answer. The create_eigs function uses the Quantum Phase Estimation (QPE) algorithm to estimate the eigenvalues of your matrix. Here is what I can say about the input paramters:

num_ancilla: The number of ancillary qubits to use in the QPE algorithm. More qubits results in better precision for eigenvalue estimation but also greater depth for your circuit. See section 3 of this tutorial to learn more about how it will increase your precision.

num_time_slices: I actually have no idea what this is and I stumbled across this question because I was looking for an answer.

negative_evals: This is a simple boolean response indicating if you have or expect negative eigenvalues. An input of "True" will increase the number of ancillary qubits by 1 and therefore lead to a circuit of greater depth.

If anyone could elaborate on what num_time_slices is exactly than I would appreciate it.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.