Hi, everyone. I am confused about QPE here. I am familiar with qiskit but pennylane is a new tool for me. If I want to estimate the phase, whose eigenvalue is 7/8 (three qubits). The results are
array([[1., 0.],
[1., 0.],
[1., 0.],
[1., 0.]])
I don’t know where goes wrong. Maybe the stupid question but I am still trying to figure it out. Hope I can get some suggestion. Thank you!
My code:
import pennylane as qml
from pennylane import numpy as np
from decimal import Decimal
from math import pi
dev2 = qml.device('default.qubit', wires = 4, analytic = True)
@qml.qnode(dev2)
def qpe():
#QFT
qml.Hadamard(wires=0)
qml.CRZ(pi/2,wires=[1,0])
qml.CRZ(pi/4, wires=[2,0])
qml.Hadamard(wires=1)
qml.CRZ(pi/2, wires=[2,1])
qml.Hadamard(wires=2)
qml.SWAP(wires=[0,2])
#CU
#qml.Hadamard(wires=0)
#qml.Hadamard(wires=1)
#qml.Hadamard(wires=2)
qml.CRZ(7*pi,wires=[3,0])
qml.CRZ(3.5*pi,wires=[3,1])
qml.CRZ(1.75*pi,wires=[3,2])
#inverse QFT
qml.SWAP(wires=[0,2])
qml.Hadamard(wires=2)
qml.CRZ(pi/2, wires=[2,1])
qml.Hadamard(wires=1)
qml.CRZ(pi/4, wires=[2,0])
qml.CRZ(pi/2,wires=[1,0])
qml.Hadamard(wires=0)
return qml.probs(0),qml.probs(1),qml.probs(2),qml.probs(3)
Hope someone can help me out (Also, I use the print(.draw()) and the circuit is too messy, not intuitive)