diff --git a/qualtran/bloqs/block_encoding/sparse_matrix_hermitian.py b/qualtran/bloqs/block_encoding/sparse_matrix_hermitian.py index 43ff03547..0097a2bbf 100644 --- a/qualtran/bloqs/block_encoding/sparse_matrix_hermitian.py +++ b/qualtran/bloqs/block_encoding/sparse_matrix_hermitian.py @@ -45,7 +45,8 @@ from qualtran.bloqs.state_preparation.prepare_uniform_superposition import ( PrepareUniformSuperposition, ) -from qualtran.resource_counting import BloqCountT, SympySymbolAllocator +from qualtran.resource_counting import BloqCountDictT, SympySymbolAllocator +from qualtran.resource_counting.generalizers import ignore_split_join from qualtran.symbolics import is_symbolic, SymbolicFloat, SymbolicInt from qualtran.symbolics.math_funcs import bit_length @@ -186,7 +187,7 @@ def diffusion(self): ], ) - def build_call_graph(self, ssa: SympySymbolAllocator) -> set[BloqCountT]: + def build_call_graph(self, ssa: SympySymbolAllocator) -> BloqCountDictT: counts = Counter[Bloq]() counts[self.diffusion] += 1 @@ -202,7 +203,7 @@ def build_call_graph(self, ssa: SympySymbolAllocator) -> set[BloqCountT]: counts[self.col_oracle.adjoint()] += 1 counts[self.diffusion.adjoint()] += 1 - return set(counts.items()) + return counts def build_composite_bloq( self, bb: BloqBuilder, system: SoquetT, ancilla: SoquetT, **soqs @@ -282,7 +283,7 @@ def build_composite_bloq( return soqs -@bloq_example +@bloq_example(generalizer=ignore_split_join) def _sparse_matrix_hermitian_block_encoding() -> SparseMatrixHermitian: from qualtran.bloqs.block_encoding.sparse_matrix import TopLeftRowColumnOracle from qualtran.bloqs.block_encoding.sparse_matrix_hermitian import UniformSqrtEntryOracle diff --git a/qualtran/bloqs/mcmt/multi_control_pauli.py b/qualtran/bloqs/mcmt/multi_control_pauli.py index 79616f971..aceff0c99 100644 --- a/qualtran/bloqs/mcmt/multi_control_pauli.py +++ b/qualtran/bloqs/mcmt/multi_control_pauli.py @@ -190,6 +190,9 @@ def _X(self): def __attrs_post_init__(self): pass + def adjoint(self) -> 'Bloq': + return self + @bloq_example def _ccpauli() -> MultiControlX: @@ -233,3 +236,6 @@ def _Z(self): def __attrs_post_init__(self): pass + + def adjoint(self) -> 'Bloq': + return self diff --git a/qualtran/bloqs/mod_arithmetic/mod_subtraction.py b/qualtran/bloqs/mod_arithmetic/mod_subtraction.py index c4da9e861..e0d0fbf81 100644 --- a/qualtran/bloqs/mod_arithmetic/mod_subtraction.py +++ b/qualtran/bloqs/mod_arithmetic/mod_subtraction.py @@ -190,8 +190,7 @@ def build_call_graph(self, ssa: 'SympySymbolAllocator') -> 'BloqCountDictT': else: cvs = HasLength(self.dtype.bitsize) return { - MultiControlX(cvs): 1, - MultiControlX(cvs).adjoint(): 1, + MultiControlX(cvs): 2, And(self.cv, 1): 1, And(self.cv, 1).adjoint(): 1, MultiTargetCNOT(self.dtype.bitsize): 1,