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

Remove _t_complexity_ of CSwapApprox #994

Merged
merged 2 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 0 additions & 9 deletions qualtran/bloqs/swap_network/cswap_approx.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from qualtran.bloqs.basic_gates import TGate
from qualtran.bloqs.mcmt.multi_control_multi_target_pauli import MultiTargetCNOT
from qualtran.bloqs.util_bloqs import ArbitraryClifford
from qualtran.cirq_interop.t_complexity_protocol import TComplexity
from qualtran.resource_counting.generalizers import (
cirq_to_bloqs,
generalize_rotation_angle,
Expand Down Expand Up @@ -97,14 +96,6 @@ def on_classical_vals(
def pretty_name(self) -> str:
return '~swap'

def _t_complexity_(self) -> TComplexity:
"""TComplexity as explained in Appendix B.2.c of https://arxiv.org/abs/1812.00954"""
n = self.bitsize
# 4 * n: G gates, each wth 1 T and 4 single qubit cliffords
# 4 * n: CNOTs
# 2 * n - 1: CNOTs from 1 MultiTargetCNOT
return TComplexity(t=4 * n, clifford=22 * n - 1)

def _circuit_diagram_info_(self, args: cirq.CircuitDiagramInfoArgs) -> cirq.CircuitDiagramInfo:
if not args.use_unicode_characters:
return cirq.CircuitDiagramInfo(
Expand Down
4 changes: 3 additions & 1 deletion qualtran/bloqs/swap_network/cswap_approx_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
CSwapApprox,
)
from qualtran.bloqs.util_bloqs import ArbitraryClifford
from qualtran.cirq_interop.t_complexity_protocol import t_complexity, TComplexity
from qualtran.testing import assert_valid_bloq_decomposition, execute_notebook

random.seed(12345)
Expand Down Expand Up @@ -62,7 +63,8 @@ def test_t_complexity_cswap(n):

@pytest.mark.parametrize("n", [*range(1, 6)])
def test_t_complexity_cswap_approx(n):
cq_testing.assert_decompose_is_consistent_with_t_complexity(CSwapApprox(n))
actual = t_complexity(CSwapApprox(n))
assert actual == TComplexity(t=4 * n, clifford=22 * n - 1)


@pytest.mark.parametrize("n", [*range(2, 6)])
Expand Down
Loading