-
Notifications
You must be signed in to change notification settings - Fork 983
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add PhysicalZTag - Simple class in cirq.google.ops that can denote physical Z gates. - Just includes the class definition so far, no functionality.
- Loading branch information
1 parent
ce13a73
commit 89653aa
Showing
10 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,6 @@ | |
SycamoreGate, | ||
SYC, | ||
) | ||
|
||
from cirq.google.ops.physical_z_tag import ( | ||
PhysicalZTag,) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright 2020 The Cirq Developers | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""A class that can be used to denote a physical Z gate.""" | ||
from cirq import protocols | ||
|
||
|
||
class PhysicalZTag: | ||
"""Class to add as a tag onto an Operation to denote a Physical Z operation. | ||
By default, all Z rotations on Google devices are considered to be virtual. | ||
When performing the Z operation, the device will update its internal phase | ||
tracking mechanisms, essentially commuting it forwards through the circuit | ||
until it hits a non-commuting operation (Such as a sqrt(iSwap)). | ||
When applied to a Z rotation operation, this tag indicates to the hardware | ||
that an actual physical operation should be done instead. This class can | ||
only be applied to instances of `cirq.ZPowGate`. If applied to other gates | ||
(such as PhasedXZGate), this class will have no effect. | ||
""" | ||
|
||
def __str__(self): | ||
return 'PhysicalZTag()' | ||
|
||
def __repr__(self): | ||
return 'cirq.google.PhysicalZTag()' | ||
|
||
def _json_dict_(self): | ||
return protocols.obj_to_dict_helper(self, []) | ||
|
||
def __eq__(self, other): | ||
return isinstance(other, PhysicalZTag) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2020 The Cirq Developers | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
import cirq | ||
|
||
|
||
def test_equality(): | ||
assert cirq.google.PhysicalZTag() == cirq.google.PhysicalZTag() | ||
|
||
|
||
def test_syc_str_repr(): | ||
assert str(cirq.google.PhysicalZTag()) == 'PhysicalZTag()' | ||
assert repr(cirq.google.PhysicalZTag()) == 'cirq.google.PhysicalZTag()' | ||
cirq.testing.assert_equivalent_repr(cirq.google.PhysicalZTag(), | ||
setup_code=('import cirq\n')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"cirq_type": "PhysicalZTag" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cirq.google.PhysicalZTag() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
"tags": | ||
[ | ||
"tag1", | ||
"tag2" | ||
{ | ||
"cirq_type": "PhysicalZTag" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
cirq.TaggedOperation(cirq.X.on(cirq.NamedQubit('q1')), 'tag1', 'tag2') | ||
cirq.TaggedOperation(cirq.X.on(cirq.NamedQubit('q1')), 'tag1', cirq.google.PhysicalZTag()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters