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 KakDecomposition._decompose_ by fixing factor of 2 error in exp(PauliString) #3125

Merged
merged 5 commits into from
Jul 8, 2020

Conversation

Strilanc
Copy link
Contributor

@Strilanc Strilanc commented Jul 7, 2020

  • I compared against results from WolframAlpha to make sure the modified tests are now correct

…auliString)

- I compared against results from WolframAlpha to make sure the modified tests are now correct
@Strilanc Strilanc requested a review from dabacon July 7, 2020 22:57
@googlebot googlebot added the cla: yes Makes googlebot stop complaining. label Jul 7, 2020
@Strilanc Strilanc requested a review from balopat July 8, 2020 00:48
Copy link
Collaborator

@viathor viathor left a comment

Choose a reason for hiding this comment

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

LGTM with two comments (one optional).

u = cirq.unitary(np.exp(-1j * np.pi / 4 * cirq.Z(a) * cirq.Z(b)))
cirq.testing.assert_allclose_up_to_global_phase(u,
np.diag([1, 1j, 1j, 1]),
atol=1e-8)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Stronger assertion:

cirq.testing. assert_allclose(u, np.diag(np.sqrt(-1j), np.sqrt(1j), np.sqrt(1j), np.sqrt(-1j)), atol=1e-8)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I intentionally only did it up to global phase to make the test simpler to write, to make sure the complications weren't hiding a mistake.



@pytest.mark.parametrize('unitary', [
cirq.testing.random_unitary(4),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Optional: I wonder what distribution we get here on the elements of KAK (e.g. on the three interaction coefficients). A good addition to the random unitary test would be one synthesized from known coefficients, e.g.

u = np.exp(1j*np.pi*(0.2*cirq.unitary(cirq.XX) + 0.3*cirq.unitary(cirq.YY) + 0.4*cirq.unitary(cirq.ZZ)))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a couple more cases. The "arbitrary fixed coefficients" case is very well covered by the random unitary; the corner cases have to do with interaction coefficients being zero or maxed.

@Strilanc Strilanc added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jul 8, 2020
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jul 8, 2020
@CirqBot CirqBot merged commit df52d1c into master Jul 8, 2020
@CirqBot CirqBot removed the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jul 8, 2020
@CirqBot CirqBot deleted the pauliphasemult branch July 8, 2020 03:07
@CirqBot CirqBot removed the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jul 8, 2020
tonybruguier pushed a commit to tonybruguier/Cirq that referenced this pull request Aug 23, 2020
…auliString) (quantumlib#3125)

- I compared against results from WolframAlpha to make sure the modified tests are now correct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants