Skip to content

Support ActOnStabilizerCHFormArgs in the common gates and testing #3203

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

Merged
merged 24 commits into from
Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e951c87
Add ActOnStabilizerCHFormArgs and related logic
smitsanghavi Aug 10, 2020
d830c9f
Merge branch 'master' into actch
smitsanghavi Aug 10, 2020
871860b
Some comment updates
smitsanghavi Aug 10, 2020
b01cb53
Fix _update_sum call
smitsanghavi Aug 10, 2020
6428bec
Update parameterized condition
smitsanghavi Aug 11, 2020
eba031d
Merge branch 'master' into actch
smitsanghavi Aug 21, 2020
50dab1f
Undo already split out change to stabilizerstatechfrom
smitsanghavi Sep 11, 2020
e49ec00
Merge branch 'master' into actch
smitsanghavi Sep 11, 2020
0ff6fd3
revert split out change
smitsanghavi Sep 11, 2020
2ce0ac5
Merge branch 'master' into actch
smitsanghavi Sep 22, 2020
df6cda3
Merge and clean
smitsanghavi Sep 22, 2020
ef8e70d
Improve error handling and documentation
smitsanghavi Sep 28, 2020
2afb08f
Merge branch 'master' into actch
smitsanghavi Sep 28, 2020
d3578de
Add comments with reference to the relevant sections of the paper
smitsanghavi Oct 13, 2020
e01317f
Merge branch 'master' into actch
smitsanghavi Oct 13, 2020
9e452d6
Fix the year in copyright
smitsanghavi Oct 21, 2020
c676f20
Use H instead of HPowGate()
smitsanghavi Oct 21, 2020
f6a93d3
Merge branch 'master' into actch
smitsanghavi Oct 21, 2020
02a08a5
Merge branch 'actch' of https://github.com/smitsanghavi/Cirq-1 into a…
smitsanghavi Oct 21, 2020
e4c49a0
Address comments
smitsanghavi Oct 26, 2020
e421f1b
Merge branch 'master' into actch
smitsanghavi Oct 26, 2020
790ec29
Merge branch 'master' into actch
CirqBot Oct 27, 2020
d54bcc8
Hide traceback and correct copyright year
smitsanghavi Oct 28, 2020
e612071
Merge branch 'actch' of https://github.com/smitsanghavi/Cirq-1 into a…
smitsanghavi Oct 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions cirq/ops/common_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ def _act_on_(self, args: Any):
assert all(
gate._act_on_(args) for gate in # type: ignore
[H, ZPowGate(exponent=self._exponent), H])
# Adjust the global phase based on the global_shift parameter.
args.state.omega *= np.exp(1j * np.pi * self.global_shift *
self.exponent)
return True

return NotImplemented
Expand Down Expand Up @@ -350,8 +353,10 @@ def _act_on_(self, args: Any):
gate._act_on_(args) # type: ignore
for gate in [H, ZPowGate()])
state.omega *= (1 - 1j) / (2**0.5) # type: ignore
# Adjust the global phase based on the global_shift parameter.
args.state.omega *= np.exp(1j * np.pi * self.global_shift *
self.exponent)
return True

return NotImplemented

def in_su2(self) -> 'YPowGate':
Expand Down Expand Up @@ -531,6 +536,9 @@ def _act_on_(self, args: Any):
# Reference: https://arxiv.org/abs/1808.00128 Proposition 4 end
state.M[q, :] ^= state.G[q, :]
state.gamma[q] = (state.gamma[q] - 1) % 4
# Adjust the global phase based on the global_shift parameter.
args.state.omega *= np.exp(1j * np.pi * self.global_shift *
self.exponent)
return True

return NotImplemented
Expand Down Expand Up @@ -831,6 +839,9 @@ def _act_on_(self, args: Any):
delta = (state.gamma[q] + 2 * (alpha + beta)) % 4

state.update_sum(t, u, delta=delta, alpha=alpha)
# Adjust the global phase based on the global_shift parameter.
args.state.omega *= np.exp(1j * np.pi * self.global_shift *
self.exponent)
return True

return NotImplemented
Expand Down Expand Up @@ -976,6 +987,9 @@ def _act_on_(self, args: Any):
# Reference: https://arxiv.org/abs/1808.00128 Proposition 4 end
state.M[q1, :] ^= state.G[q2, :]
state.M[q2, :] ^= state.G[q1, :]
# Adjust the global phase based on the global_shift parameter.
args.state.omega *= np.exp(1j * np.pi * self.global_shift *
self.exponent)
return True

return NotImplemented
Expand Down Expand Up @@ -1183,14 +1197,17 @@ def _act_on_(self, args: Any):
q2 = args.axes[1]
state = args.state
if self._exponent % 2 == 1:
# Prescription for CZ left multiplication.
# Prescription for CX left multiplication.
# Reference: https://arxiv.org/abs/1808.00128 Proposition 4 end
state.gamma[q1] = (
state.gamma[q1] + state.gamma[q2] + 2 *
(sum(state.M[q1, :] & state.F[q2, :]) % 2)) % 4
state.G[q2, :] ^= state.G[q1, :]
state.F[q1, :] ^= state.F[q2, :]
state.M[q1, :] ^= state.M[q2, :]
# Adjust the global phase based on the global_shift parameter.
args.state.omega *= np.exp(1j * np.pi * self.global_shift *
self.exponent)
return True

return NotImplemented
Expand Down
Loading