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

Move GateTabulation and friends to cirq-core as requested in #4461 #4602

Merged
merged 57 commits into from
Jan 10, 2022

Conversation

Ashalynd
Copy link
Collaborator

@Ashalynd Ashalynd commented Oct 27, 2021

Fixes #4461

@Ashalynd Ashalynd requested review from cduck, vtomole, wcourtney and a team as code owners October 27, 2021 18:50
@Ashalynd Ashalynd requested a review from tanujkhattar October 27, 2021 18:50
@google-cla google-cla bot added the cla: yes Makes googlebot stop complaining. label Oct 27, 2021
@CirqBot CirqBot added the size: M 50< lines changed <250 label Oct 27, 2021
cirq-google/cirq_google/__init__.py Outdated Show resolved Hide resolved
cirq-core/cirq/optimizers/two_qubit_gate_compilation.py Outdated Show resolved Hide resolved
@tanujkhattar
Copy link
Collaborator

@Ashalynd My work on adding approximate compilation method (described in #4362) is now blocked on getting this PR checked in. Would you be available to continue working on this, so we can get it in soon? Thanks!

@Ashalynd
Copy link
Collaborator Author

Ashalynd commented Nov 17, 2021

@Ashalynd My work on adding approximate compilation method (described in #4362) is now blocked on getting this PR checked in. Would you be available to continue working on this, so we can get it in soon? Thanks!

Yes, looking at finishing that right now.
Heads-up: I checked in what I have atm, mostly works but :

  • there was name clash between deprecated and new versions, so I renamed the new ones
  • not all tests seem to play nicely with deprecated classes.
  • saw some complaints about coverage (not sure if reproduces on github).

@Ashalynd Ashalynd added the Ready for Re-Review For when reviewers take their time. label Nov 18, 2021
Copy link
Collaborator

@tanujkhattar tanujkhattar left a comment

Choose a reason for hiding this comment

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

Looking good. Left a final round of comments and we should be ready to merge after this. Thanks for the iterations!

cirq-core/cirq/transformers/__init__.py Show resolved Hide resolved
@@ -0,0 +1 @@
cirq.TwoQubitGateTabulation(np.array([[(1+0j), 0j, 0j, 0j], [0j, (6.123233995736766e-17+0j), -1j, 0j], [0j, -1j, (6.123233995736766e-17+0j), 0j], [0j, 0j, 0j, (0.8660254037844387-0.49999999999999994j)]], dtype=np.complex128), np.array([[0.7853981633974483, 0.7853981633974483, 0.1308996938995748], [0.5455546451806152, 0.4274250500660468, 1.1102230246251565e-16], [0.482263980185593, 0.15541244226118112, -0.0], [0.08994436657892213, 0.0688663429298958, -0.0], [0.5337019863142523, 0.31800967733278185, -0.2565859360625904], [0.48438278888761155, 0.39121774851710633, 0.28728266960007875]], dtype=np.float64), [[],[(np.array([[(-0.8113361037323902+0.388228151720065j), (0.38855300559639544-0.20009795309891054j)], [(-0.38855300559639544-0.20009795309891054j), (-0.8113361037323902-0.388228151720065j)]], dtype=np.complex128), np.array([[(-0.15500592487333173-0.5209557609876208j), (-0.6259723589563565+0.5592288119996914j)], [(0.6259723589563565+0.5592288119996914j), (-0.15500592487333173+0.5209557609876208j)]], dtype=np.complex128))],[(np.array([[(-0.7591335658137299-0.5262321684934362j), (0.37132129473675946+0.09442685090928131j)], [(-0.37132129473675946+0.09442685090928131j), (-0.7591335658137299+0.5262321684934362j)]], dtype=np.complex128), np.array([[(0.004722472920167423+0.9809944588837683j), (0.18002103957975657+0.07224953423714474j)], [(-0.18002103957975657+0.07224953423714474j), (0.004722472920167423-0.9809944588837683j)]], dtype=np.complex128))],[(np.array([[(-0.0897362442086916+0.02445105905520244j), (-0.8503296766825128-0.5179662084918382j)], [(0.8503296766825128-0.5179662084918382j), (-0.0897362442086916-0.02445105905520244j)]], dtype=np.complex128), np.array([[(0.7441127742234152+0.6642425418602642j), (0.009545063892332065+0.07061810374004159j)], [(-0.009545063892332065+0.07061810374004159j), (0.7441127742234152-0.6642425418602642j)]], dtype=np.complex128))],[(np.array([[(-0.8113361037323902+0.388228151720065j), (0.38855300559639544-0.20009795309891054j)], [(-0.38855300559639544-0.20009795309891054j), (-0.8113361037323902-0.388228151720065j)]], dtype=np.complex128), np.array([[(-0.15500592487333173-0.5209557609876208j), (-0.6259723589563565+0.5592288119996914j)], [(0.6259723589563565+0.5592288119996914j), (-0.15500592487333173+0.5209557609876208j)]], dtype=np.complex128)),(np.array([[(-0.8113361037323902+0.388228151720065j), (0.38855300559639544-0.20009795309891054j)], [(-0.38855300559639544-0.20009795309891054j), (-0.8113361037323902-0.388228151720065j)]], dtype=np.complex128), np.array([[(-0.15500592487333173-0.5209557609876208j), (-0.6259723589563565+0.5592288119996914j)], [(0.6259723589563565+0.5592288119996914j), (-0.15500592487333173+0.5209557609876208j)]], dtype=np.complex128))],[(np.array([[(0.41295648139511504-0.17280776715854063j), (0.5430881450957462-0.7103940362502399j)], [(-0.5430881450957462-0.7103940362502399j), (0.41295648139511504+0.17280776715854063j)]], dtype=np.complex128), np.array([[(0.19013479709876246+0.4941656851052965j), (-0.6469746262664201+0.5487010730480224j)], [(0.6469746262664201+0.5487010730480224j), (0.19013479709876246-0.4941656851052965j)]], dtype=np.complex128)),(np.array([[(0.41295648139511504-0.17280776715854063j), (0.5430881450957462-0.7103940362502399j)], [(-0.5430881450957462-0.7103940362502399j), (0.41295648139511504+0.17280776715854063j)]], dtype=np.complex128), np.array([[(0.19013479709876246+0.4941656851052965j), (-0.6469746262664201+0.5487010730480224j)], [(0.6469746262664201+0.5487010730480224j), (0.19013479709876246-0.4941656851052965j)]], dtype=np.complex128))]], 0.49, 'Fraction of Weyl chamber reached with 2 gates: 0.600\nFraction of Weyl chamber reached with 2 gates and 3 gates(same single qubit): 1.000', ())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are the _inward files needed here? IIUC, Both TwoQubitGateTabulation.repr_inward and TwoQubitGateTabulation.json_inward are not needed here right now and should be removed.

The _inward files would need to be added to cirq-google when we remove the deprecated classes after the deprecation cycle is over so that we can continue to support deserialization of the old GateTabulation type into the newly introduced TwoQubitGateTabulation type.

See https://quantumai.google/cirq/dev/serialization#removing_a_serializable_value for more details.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see, removed the files from the new directory. For some reason, the cirq-google/cirq_google/json_test_data contains identical .repr / .json and .repr_inward / .json_inward for this and many other classes, which is quite confusing. Should it be cleaned up?

@tanujkhattar tanujkhattar removed the Ready for Re-Review For when reviewers take their time. label Jan 5, 2022
@Ashalynd Ashalynd added the Ready for Re-Review For when reviewers take their time. label Jan 5, 2022
@Ashalynd Ashalynd requested a review from tanujkhattar January 5, 2022 23:15
@Ashalynd Ashalynd requested a review from tanujkhattar January 8, 2022 02:11
)


# pylint: enable=missing-raises-doc
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now that we have the copyright in place, this line is not needed. Please delete.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Copy link
Collaborator

@tanujkhattar tanujkhattar left a comment

Choose a reason for hiding this comment

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

LGTM % two final nits. Please fix the nits and we'll merge.

Thanks a lot for all the iterations! The final outcome looks great :)

@tanujkhattar tanujkhattar removed the Ready for Re-Review For when reviewers take their time. label Jan 10, 2022
@tanujkhattar
Copy link
Collaborator

@Ashalynd Please fix the lint checks

@Ashalynd
Copy link
Collaborator Author

@Ashalynd Please fix the lint checks

done

@tanujkhattar tanujkhattar merged commit 778d317 into quantumlib:master Jan 10, 2022
MichaelBroughton pushed a commit to MichaelBroughton/Cirq that referenced this pull request Jan 22, 2022
…ib#4461 (quantumlib#4602)

- Adds `cirq. TwoQubitGateTabulation`, `cirq.TwoQubitGateTabulationResult`, and `cirq.two_qubit_gate_product_tabulation` public top level objects to Cirq. 
- TwoQubitGateTabulation is heuristic compilation technique for decomposing any 2q unitary to a given target 2q gate + single qubit rotations.
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
…ib#4461 (quantumlib#4602)

- Adds `cirq. TwoQubitGateTabulation`, `cirq.TwoQubitGateTabulationResult`, and `cirq.two_qubit_gate_product_tabulation` public top level objects to Cirq. 
- TwoQubitGateTabulation is heuristic compilation technique for decomposing any 2q unitary to a given target 2q gate + single qubit rotations.
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
…ib#4461 (quantumlib#4602)

- Adds `cirq. TwoQubitGateTabulation`, `cirq.TwoQubitGateTabulationResult`, and `cirq.two_qubit_gate_product_tabulation` public top level objects to Cirq. 
- TwoQubitGateTabulation is heuristic compilation technique for decomposing any 2q unitary to a given target 2q gate + single qubit rotations.
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. size: M 50< lines changed <250
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bring GateTabulation out of cirq-google to cirq-core
3 participants