Skip to content

Commit

Permalink
fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
anurudhp committed Aug 21, 2024
1 parent 623413d commit f974c3f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions qualtran/resource_counting/t_counts_from_sigma.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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

0 comments on commit f974c3f

Please sign in to comment.