Hi,
I have a couple questions on QSVT algorithm and Pennylane’s implementation. Referring to Theorem 26 from the paper Quantum singular value transformation and beyond: exponential improvements for quantum matrix arithmetics by Gilyén et al.
What I understood is that QSVT creates a matrix which is a close approximation of the singular value decomposition, i.e \tilde \Pi U \Pi \approx W {\cdot} P(\Sigma) {\cdot} V^\dagger where P(\Sigma) is the singular values after the polynomial function is applied to them. So, I created a short code to experiment as below. The polynomial function that I’m applying is P(x)=x.
import numpy as np
import pennylane as qml
import scipy
gen = np.random.default_rng(42)
A = gen.uniform(-1, 1, (4, 4)) # random 4x4 matrix
# target poly: P(x) = x
target_poly = [0,1]
wire_order = list(range(5))
U, S, Vh = scipy.linalg.svd(A)
classical_output = U @ np.diag([np.polyval(target_poly[::-1], s) for s in S]) @ Vh
print("Classical output:\n", classical_output)
norm = scipy.linalg.norm(A, ord=2)
if norm > 1:
A_normalized = A / norm
print("\nnorm of A:", norm)
quantum_output = qml.matrix(qml.qsvt, wire_order=wire_order)(
A_normalized, target_poly, encoding_wires=wire_order, block_encoding="embedding"
) # block-encoded in 5-qubit system
print("\nQuantum_output:\n", quantum_output[:4, :4].real*norm)
However, the output differs between the classical and quantum computation.
-
Is this the expected output? My expectation is that the quantum output will be a close approximation of W {\cdot} P(\Sigma) {\cdot} V^\dagger. I’m not sure whether my understanding is correct or whether my code is wrong.
-
When I tried with a polynomial with an imaginary coefficient, e.g.
target_poly = [0,1j], I get an errorAssertionError: Array must not have an imaginary part. Is this by design of the implementation in Pennylane or is this because QSVT algorithm only works with real coefficients?
Looking forward to your kind reply. Thank you.

