Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip over identity ops in "lightning.qubit" #268

Merged
merged 10 commits into from
Mar 22, 2022
Prev Previous commit
Next Next commit
Update apply_lightning
  • Loading branch information
maliasadi committed Mar 22, 2022
commit 61a37fa6081dd461fb80c8857b1069e40f8e2c91
8 changes: 6 additions & 2 deletions pennylane_lightning/lightning_qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,13 @@ def apply_lightning(self, state, operations, dtype=np.complex128):
else:
raise TypeError(f"Unsupported complex Type: {dtype}")

ops_iter = operations if isinstance(operations, Iterable) else [operations]
# Skip over identity operators instead or performing
# matrix multiplication with the identity.
skipped_ops = ["Identity"]
for o in operations:
if op in skipped_ops:

for o in ops_iter:
if o in skipped_ops:
continue
name = o.name.split(".")[0] # The split is because inverse gates have .inv appended
if _is_lightning_gate(name):
Expand Down