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 support for using physical-Z phase matching on 2-qubit gates #3862

Merged
merged 2 commits into from Feb 26, 2021

Conversation

maffoo
Copy link
Contributor

@maffoo maffoo commented Feb 25, 2021

When run on hardware, two-qubit gates must be "phase-matched" to account for the detuning between the rest frames of the two qubits. By default, this phase matching will use "virtual" Z gates where possible, namely for gates like CZ and iSWAP that commute with single-qubit Z rotations (in the case of iSWAP, the commuted Zs swap to the other qubit). In some cases, however, we may want to use "physical" Z gates for matching, for example to avoid errors due to non-ideal gates (non-zero swap angle in CZ, or incomplete swap in iSWAP).

Here we add support for tagging 2-qubit gates with cirq.google.PhysicalZTag() to indicate that physical Z gates should be used for matching, instead of the default matching scheme. We modify the 2-qubit gate serializers to recognize these tags and pass them through when serializing/deserializing.

Note that for sqrt-iSWAP gates and others that do not commute with Z, the default behavior is already to use physical Z gates for matching. In these cases adding an explicit PhysicalZTag() does not change the behavior, but we allow it for consistency with other 2-qubit gates.

@maffoo maffoo requested review from cduck, vtomole, wcourtney and a team as code owners February 25, 2021 18:20
@google-cla google-cla bot added the cla: yes Makes googlebot stop complaining. label Feb 25, 2021
Copy link
Collaborator

@dstrain115 dstrain115 left a comment

Choose a reason for hiding this comment

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

Perhaps we could add more to PR description and/or the commit message?

@@ -437,7 +459,7 @@ def _convert_physical_z(op: ops.Operation, proto: v2.program_pb2.Operation):
op_serializer.GateOpSerializer(
gate_type=ops.FSimGate,
serialized_gate_id='fsim_pi_4',
args=[],
args=[_phase_match_arg],
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a little confusing, since the default is to match via physical Z for sqrt iswap, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's correct. I think it's nice to have this here for consistency with other gates. I've added a note about this in the PR description.

@maffoo
Copy link
Contributor Author

maffoo commented Feb 26, 2021

Thanks, @dstrain115. I've updated the PR description for posterity, and will include that in the commit message.

@maffoo maffoo merged commit 4ca1c1d into master Feb 26, 2021
@maffoo maffoo deleted the u/maffoo/phys-z branch February 26, 2021 22:47
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

2 participants