Skip to content

Commit

Permalink
Remove _t_complexity_ of CSwapApprox (#994)
Browse files Browse the repository at this point in the history
- Part of #905.
- Removed _t_complexity_ calculation and moved to assert
since this has a call_graph, the T count can be inferred.
  • Loading branch information
dstrain115 authored May 28, 2024
1 parent a12c685 commit f11b711
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
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

0 comments on commit f11b711

Please sign in to comment.