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

Add iSWAP and CPhase gates #45

Merged
merged 5 commits into from
Nov 3, 2020
Merged

Add iSWAP and CPhase gates #45

merged 5 commits into from
Nov 3, 2020

Conversation

thisac
Copy link
Contributor

@thisac thisac commented Oct 30, 2020

This PR adds the iSWAP and CPhase gates from Cirq to ops.py.

@thisac thisac requested review from co9olguy and josh146 October 30, 2020 22:06
@codecov
Copy link

codecov bot commented Oct 30, 2020

Codecov Report

Merging #45 into master will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #45      +/-   ##
==========================================
+ Coverage   99.03%   99.07%   +0.03%     
==========================================
  Files           8        8              
  Lines         312      324      +12     
==========================================
+ Hits          309      321      +12     
  Misses          3        3              
Impacted Files Coverage Δ
pennylane_cirq/cirq_device.py 98.75% <ø> (ø)
pennylane_cirq/__init__.py 100.00% <100.00%> (ø)
pennylane_cirq/ops.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c3ec92f...09fd066. Read the comment docs.

Copy link
Member

@josh146 josh146 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from my end Theo 👍

Do we have tests for the plugin custom ops?

Copy link
Member

@co9olguy co9olguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @thisac. I found a few obvious typos and have some questions about the tests.

[[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, e^{i\phi]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[0, 0, 0, e^{i\phi]]
[0, 0, 0, e^{i\phi}]]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the bmatrix need newlines?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're completely right. This is a very ugly mix of Python and Latex. 😆

tests/test_native_ops.py Outdated Show resolved Hide resolved
tests/test_native_ops.py Outdated Show resolved Hide resolved
Comment on lines 192 to 199
@pytest.mark.parametrize("input",
[
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1],
]
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I struggled to understand this. If the device has two wires, then shouldn't the underlying pure state have shape (2,2)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should have shape (4,), right? For the different bitstrings 00, 01, 10 and 11. Which is what this is (each row corresponding to an input). 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, got it! the pytest parametrize format looks exactly like a 2d array 😆

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to test on superposition states as well

@thisac thisac requested a review from co9olguy November 3, 2020 16:03
@thisac
Copy link
Contributor Author

thisac commented Nov 3, 2020

Thanks @co9olguy for the review. Too many 🤦s in this one though, but I fixed the typos and the gate application order, and also tried to make the parametrization less confusing (adding a few more interesting states, and avoiding it looking like the identity).

np.array([0, 0, 1, 0]),
np.array([0, 1, 0, 1]) / np.sqrt(2),
np.array([0, 0, 0, 1]),
np.array([2, 1, 2, 1]) / np.sqrt(10),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@thisac thisac merged commit a401c94 into master Nov 3, 2020
@thisac thisac deleted the new-ops branch November 3, 2020 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants