Skip to content

Commit

Permalink
Decompose QFT
Browse files Browse the repository at this point in the history
  • Loading branch information
WrathfulSpatula committed May 31, 2024
1 parent 0ea3c80 commit 9b67ca5
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 24 deletions.
2 changes: 1 addition & 1 deletion pennylane_qrack/QrackDeviceConfig.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ U2 = { properties = [ "controllable", "invertible" ] }
U1 = { properties = [ "controllable", "invertible" ] }
MultiControlledX = { properties = [ "controllable", "invertible" ] }
Identity = { properties = [ "controllable", "invertible" ] }
QFT = { properties = [ "invertible" ] }

# Operators that should be decomposed according to the algorithm used
# by PennyLane's device API.
Expand Down Expand Up @@ -79,6 +78,7 @@ QFT = { properties = [ "invertible" ] }
# IsingYY = {}
# IsingZZ = {}
# IsingXY = {}
# QFT = {}

# Gates which should be translated to QubitUnitary
# [operators.gates.matrix]
Expand Down
14 changes: 0 additions & 14 deletions pennylane_qrack/qrack_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,6 @@ struct QrackDevice final : public Catalyst::Runtime::QuantumDevice {
qsim->U(target, Qrack::PI_R1 / 2, params[0U], params[1U]);
}
}
} else if (name == "QFT") {
const size_t maxLcv = wires.size() >> 1U;
const size_t end = wires.size() - 1U;
if (inverse) {
for (size_t i = 0U; i < maxLcv; ++i) {
qsim->Swap(wires[i], wires[end - i]);
}
qsim->IQFTR(wires);
} else {
qsim->QFTR(wires);
for (size_t i = 0U; i < maxLcv; ++i) {
qsim->Swap(wires[i], wires[end - i]);
}
}
} else if (name != "Identity") {
throw std::domain_error("Unrecognized gate name: " + name);
}
Expand Down
9 changes: 0 additions & 9 deletions pennylane_qrack/qrack_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ class QrackDevice(QubitDevice):
"C(CPhase)",
"MultiControlledX",
"C(MultiControlledX)",
"QFT",
}

config = pathlib.Path(
Expand Down Expand Up @@ -598,14 +597,6 @@ def _apply_gate(self, op):
-par[1],
-par[2],
)
elif opname == "QFT":
self._state.qft(device_wires.labels)
for i in range(len(device_wires.labels) >> 1):
self._state.swap(device_wires.labels[i], device_wires.labels[-i])
elif opname == "QFT.inv":
for i in range(len(device_wires.labels) >> 1):
self._state.swap(device_wires.labels[i], device_wires.labels[-i])
self._state.iqft(device_wires.labels)
elif opname not in [
"Identity",
"Identity.inv",
Expand Down

0 comments on commit 9b67ca5

Please sign in to comment.