PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
This error can probably be boiled down to the missing GlobalPhase during the decomposition of the TrotterProduct to the lightning.qubit device. Therefore, the controlled evolution of Hamiltonians with some scalar Identities that result in a controlled GlobalPhase is skipped and leads to incorrect results.
Please note, this is a high-priority bug for us!
Source code
import pennylane as qml
import numpy as np
symbols = ["H", "H"]
coordinates = np.array([[0.0, 0.0, -0.6614], [0.0, 0.0, 0.6614]])
H, num_qubits = qml.qchem.molecular_hamiltonian(symbols, coordinates, basis="sto-3g", wires=[1, 2, 3, 4])
for dev_name in ["default.qubit", "lightning.qubit"]:
dev = qml.device(dev_name, wires=num_qubits+1)
@qml.qnode(dev)
def cirucit():
qml.BasisState([1, 1, 0, 0], wires=[1, 2, 3, 4])
qml.Hadamard(0)
if dev_name == "lightning.qubit": # Apply the missing the Global Phase to fix the error
qml.ctrl(qml.GlobalPhase, control=0, control_values=0)(-H.terms()[0][0], wires=[1, 2, 3, 4])
qml.ctrl(qml.TrotterProduct, control=0, control_values=0)(H, 1)
qml.Hadamard(0)
return qml.probs()
print(f"{dev_name} : {cirucit().round(4)}")
Expected behavior
Outputs from both the devices should be equal.
Actual behavior
In reality, we get different results -
Additional information
This error can probably be boiled down to the missing
GlobalPhase
during the decomposition of theTrotterProduct
to thelightning.qubit
device. Therefore, the controlled evolution of Hamiltonians with some scalarIdentities
that result in a controlledGlobalPhase
is skipped and leads to incorrect results.Please note, this is a high-priority bug for us!
Source code
Tracebacks
No response
System information
Existing GitHub issues