-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Environment
- Qiskit Terra version: 0.20.1
- Python version: 3.9.7
- Operating system: Ubuntu 21
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.
K =
[[ 1.9375 +0.j -0.51041667+0.j -0.02083333+0.j -1.02083333+0.j
-0.51041667+0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j]
[-0.51041667+0.j 0.97916667+0.j -0.51041667+0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j]
[-0.02083333+0.j -0.51041667+0.j 1.9375 +0.j -1.02083333+0.j
0. +0.j -0.51041667+0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j]
[-1.02083333+0.j 0. +0.j -1.02083333+0.j 3.875 +0.j
-0.02083333+0.j -0.02083333+0.j -1.02083333+0.j -1.02083333+0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j]
[-0.51041667+0.j 0. +0.j 0. +0.j -0.02083333+0.j
0.95833333+0.j 0. +0.j -0.51041667+0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j]
[ 0. +0.j 0. +0.j -0.51041667+0.j -0.02083333+0.j
0. +0.j 0.95833333+0.j 0. +0.j -0.51041667+0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j]
[ 0. +0.j 0. +0.j 0. +0.j -1.02083333+0.j
-0.51041667+0.j 0. +0.j 1.9375 +0.j -0.02083333+0.j
-0.51041667+0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j]
[ 0. +0.j 0. +0.j 0. +0.j -1.02083333+0.j
0. +0.j -0.51041667+0.j -0.02083333+0.j 1.9375 +0.j
-0.51041667+0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j]
[ 0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j -0.51041667+0.j -0.51041667+0.j
0.97916667+0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j]
[ 0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 1. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j]
[ 0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 1. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j]
[ 0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 1. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j]
[ 0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
1. +0.j 0. +0.j 0. +0.j 0. +0.j]
[ 0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 1. +0.j 0. +0.j 0. +0.j]
[ 0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 1. +0.j 0. +0.j]
[ 0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 1. +0.j]]
with forcing term:
f_vec = [0.87758256 0.54030231 0.47415988 0.77015115 1. 0.29192658
0.87758256 0.47415988 0.54030231 0. 0. 0.
0. 0. 0. 0. ]
How can we reproduce the issue?
You can reproduce the issue by
import qiskit as qk
from qiskit.algorithms.linear_solvers.hhl import HHL
tol = .1
q_circ = HHL(epsilon=tol).construct_circuit(K, f_vec)
with K
and f_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.