Add support for the Matsumoto-Amano normal form.#1801
Add support for the Matsumoto-Amano normal form.#1801NoureldinYosri merged 9 commits intoquantumlib:mainfrom
Conversation
|
@NoureldinYosri please have a look when you have time! |
There was a problem hiding this comment.
overall looks good, but
|
Thank you a lot for your review, Noureldine! Do you mean set For me it wasn't obvious that T can be scaled to be a member of |
|
yes, there is no need to define a TSqrt2, the normal T becomes Tz in SU2. Given any 1Q unitary gate Tx and Ty are the X and Y axis version of the T gate ( |
|
Actually now I realize that if I set |
|
good point, @mpharrigan what do you think? should we create a separate |
|
I don't have the full context, but if the issue is just how the same logical object gets formatted as a string, I'd recommend putting that logic with the string formatting |
|
Thank you for the comments! I removed the
|
NoureldinYosri
left a comment
There was a problem hiding this comment.
thanks @codrut3 this looks really nice, just a few nits
| Allowable format strings are | ||
| - 'xyz' uses Tx, Ty, Tz gates. | ||
| - 'xz' uses $Tx, Tz, Tx^\dagger, Tz^\dagger$ | ||
| - 't' uses T gates, and returns the Matsumoto-Amano normal form. |
There was a problem hiding this comment.
| - 't' uses T gates, and returns the Matsumoto-Amano normal form. | |
| - 't' uses only Tz gates, and returns the Matsumoto-Amano normal form. |
| break | ||
| gates: tuple[str, ...] = () | ||
| new: Union[_su2_ct.SU2CliffordT, None] | ||
| if np.array_equal(parity, np.array([[1, 1, 0], [1, 1, 0], [0, 0, 0]])): |
There was a problem hiding this comment.
can you move this if/else block into a separate method and turn _matsumoto_amano_sequence into an iterative procedure rather than recursive?
| Args: | ||
| matrix: The matrix to represent. | ||
| fmt: A string from the set {'xz', 'xyz'} representing the allowed T gates described above. | ||
| fmt: A string from the set {'xz', 'xyz', t'} representing the allowed T gates described above. |
There was a problem hiding this comment.
typo:
| fmt: A string from the set {'xz', 'xyz', t'} representing the allowed T gates described above. | |
| fmt: A string from the set {'xz', 'xyz', 't'} representing the allowed T gates described above. |
| @pytest.mark.parametrize("g", _make_random_su(50, 5, random_cliffords=True, seed=0)) | ||
| def test_to_cirq(g): | ||
| circuit = cirq.Circuit(ctr.to_cirq(g, 'xyz')) | ||
| @pytest.mark.parametrize("fmt", ('xyz', 't')) |
There was a problem hiding this comment.
lets add xz as well
| @pytest.mark.parametrize("fmt", ('xyz', 't')) | |
| @pytest.mark.parametrize("fmt", ('xyz', 'xz', 't')) |
Head branch was pushed to by a user without write access
|
I saw there was a pylint error and I fixed it. |
|
@NoureldinYosri is there anything else I need to do here? |
Fixes #1762