-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't compile HHL Circuit for 16x16 matrix #8102
Comments
@anedumla Any comment/thought? |
I also wanted to add some relevant details, the condition number of the above matrix is ~46 and the norm of f_vec ~2. Epsilon, 1e-1. The number of qubits is certainly >4, because of the encoding qubits used to store the values for the controlled rotations. I've been using the log(kappa^2/eps) as a rule of thumb for estimating the number of encoding qubits, so in this case ~4 encoding qubits, 1 ancilla, and 4 qubits for storing the 16 states of the matrix. In all, I'd anticipate about 10 qubits are involved in this computation. Does that volume cause any difficulty? |
Just bumping this thread to see if anyone has any suggestions here. A complete circuit description isn't even that important, if one could just even cost out the number of 2-qubit unitaries that would be useful. |
The problem seems to be QPE with the unitary returned by |
I see. That won't really work for what I'm doing, but thank you for letting me know! |
I started just playing with the ToeplitzTridiagonal for HHL as well. I wanted to compile it to qasm, but get the following error:
Here's the code:
|
I did a line profiling on
However, the most time-consuming part of the
|
I think I can get 280x speedup of that last line by replacing circuit.compose(unitary.power(2**j).control(), qubits=[j] + qr_state[:], inplace=True) with evolved = sp.linalg.expm(1j * unitary.matrix * unitary.evolution_time)
out = evolved.copy()
for i in range(2**j - 1):
out *= evolved
out = control_unitary(out)
circuit.unitary(out, [j] + qr_state[:]) where def control_unitary(u):
identity = np.eye(len(u))
zerozero = [[1.0, 0.0], [0.0, 0.0]]
oneone = [[0.0, 0.0], [0.0, 1.0]]
return np.kron(identity, zerozero) + np.kron(u, oneone) I tested the correctness of the result. For 2 qubits, the first 2 elements of my statevector matches, but for 3 qubits, the elements of my statevector are so small (~1e-16) that even though they are different, it doesn't make sense because they are effectively 0.0. And so, not sure. |
Environment
What is happening?
I am trying to analyze the circuit for HHL for a set of matrix inversion problems. I am currently trying to compile the circuit for solving this 16x16 system, dilated from a 9x9 system. The dilation is performed by padding the off diagonal terms with 0's and putting 1's on the diagonal.
with forcing term:
How can we reproduce the issue?
You can reproduce the issue by
with
K
andf_vec
defined as above. It takes a really long time to just compile the program. This seems to be unreasonable, it shouldn't intend too great an effort to spit out a qasm file, right?What should happen?
I would expect that compiling the circuit shouldn't be a major overhead. Simulation, sure, but compilation ought not to be.
Any suggestions?
You can compile HHL sequentially. The QPE routine is essentially repeated twice, so you should only have to compile that part of the circuit once and then apply the Hermitian conjugate QPE after the controlled rotation step. I'm not sure where the major bottleneck is.
The text was updated successfully, but these errors were encountered: