From f974c3fbaff348d00c1c81562bd7cd8070ee821a Mon Sep 17 00:00:00 2001 From: Anurudh Peduri Date: Tue, 20 Aug 2024 23:16:56 -0700 Subject: [PATCH] fix error --- qualtran/resource_counting/t_counts_from_sigma.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/qualtran/resource_counting/t_counts_from_sigma.py b/qualtran/resource_counting/t_counts_from_sigma.py index 85906ce10..2d04b75b7 100644 --- a/qualtran/resource_counting/t_counts_from_sigma.py +++ b/qualtran/resource_counting/t_counts_from_sigma.py @@ -11,15 +11,13 @@ # 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. -from typing import Mapping, TYPE_CHECKING +from typing import Mapping import cirq +from qualtran import Bloq, Controlled from qualtran.symbolics import ceil, SymbolicInt -if TYPE_CHECKING: - from qualtran import Bloq - def t_counts_from_sigma(sigma: Mapping['Bloq', SymbolicInt]) -> SymbolicInt: """Aggregates T-counts from a sigma dictionary by summing T-costs for all rotation bloqs.""" @@ -30,6 +28,9 @@ def t_counts_from_sigma(sigma: Mapping['Bloq', SymbolicInt]) -> SymbolicInt: ret = sigma.get(TGate(), 0) + sigma.get(TGate().adjoint(), 0) for bloq, counts in sigma.items(): if bloq_is_rotation(bloq) and not cirq.has_stabilizer_effect(bloq): + if isinstance(bloq, Controlled): + # TODO native controlled rotation bloqs missing (CRz, CRy etc.) + bloq = bloq.subbloq assert hasattr(bloq, 'eps') ret += ceil(TComplexity.rotation_cost(bloq.eps)) * counts return ret