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

tk1_to_rzsx on TK1(0, 1.5, 0) outputs 3 sx in tket 1.32 but only 1 sx in tket 1.7 #1631

Closed
jacofeld opened this issue Oct 22, 2024 · 4 comments
Assignees

Comments

@jacofeld
Copy link

jacofeld commented Oct 22, 2024

I recently upgraded my tket version from 1.7 to 1.32 (I know, it's been a while), and I noticed that TK1(0, 1.5, 0), when run through auto_rebase_pass({OpType.SX, OpType.ECR, OpType.Rz}) in tket 1.32, was decomposed to three SX commands where there was only 1 SX command output in tket 1.7.

From what I can tell, this is because the tk1_to_rzsx decompositions changed:

1.32 version

1.7 version

The two are equivalent up to a global phase.

Was this intentional? the new version (3 SXs) is less optimal on hardware, right?

@CalMacCQ
Copy link
Contributor

CalMacCQ commented Oct 25, 2024

Hi, thanks for making an issue. I don't know what the reason for the change was (if there was a reason)

@sjdilkes any ideas on this?

I use AutoRebase rather than auto_rebase_pass as the latter is deprecated now. Although this shouldn't matter for the issue you raise.

@sjdilkes
Copy link
Contributor

sjdilkes commented Oct 25, 2024

Looking at the commit history, I suspect what's happening is TK1(0, 1.5, 0) is now using a decomposition introduced in this commit:

// a = 2k, b = 2m-0.5, c = 2n
// Rz(2k)Rx(2m - 0.5)Rz(2n) = (-1)^{k+m+n}e^{i \pi /4} X.SX

I guess the logic is that for non-zero a and c angles that arbitrary Rz is potentially more expensive than an SX gate - but in this case (with Rx(1) as well) it looks like it could be cheaper to just do the arbitrary Rx rotation. Though my understanding is that Rx(theta) = Rz(0.5).SX.Rz(0.5).Rz(theta).Rz(0.5).SX.Rz(0.5) so maybe the three SX gates is cheaper?

@yitchen-tim
Copy link

@sjdilkes In hardware implementation, Rz usually doesn't requires a pulse. For example, in superconducting QC, Rz is implemented virtually as phases of the adjacent Rx gates. Similarly, in ion trap QC, Rz gate can be absorbed into the adjacent Rx-like gates. So, in terms of pulse length, Rz is less costly than Rx gate (Rz is often referred as "free"). So I think 2 RZ + 1 Sx should be generally cheaper (i.e., shorter pulse length) than 3 Sx.

@sjdilkes
Copy link
Contributor

Thanks @yitchen-tim and @jacofeld , this makes sense. I've removed the alternative 3 SX gate construction which seems to be more inefficient on hardware in expected cases here -> #1643.

@CalMacCQ CalMacCQ assigned sjdilkes and unassigned cqc-alec Nov 1, 2024
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

No branches or pull requests

5 participants