Skip to content

Commit

Permalink
Switch BlockEncoding.signal_state to BlackBoxPrepare (#1259)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesyuan314 authored Aug 7, 2024
1 parent 822f8d3 commit 5fbfe53
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions qualtran/bloqs/block_encoding/block_encoding_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import abc

from qualtran import Bloq, BloqDocSpec
from qualtran.bloqs.state_preparation.prepare_base import PrepareOracle
from qualtran.bloqs.state_preparation.black_box_prepare import BlackBoxPrepare
from qualtran.symbolics import SymbolicFloat, SymbolicInt


Expand Down Expand Up @@ -94,7 +94,7 @@ def epsilon(self) -> SymbolicFloat:

@property
@abc.abstractmethod
def signal_state(self) -> PrepareOracle:
def signal_state(self) -> BlackBoxPrepare:
r"""Returns the signal / ancilla flag state $|G\rangle."""


Expand Down
6 changes: 3 additions & 3 deletions qualtran/bloqs/block_encoding/chebyshev_polynomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from qualtran.bloqs.block_encoding import BlockEncoding
from qualtran.bloqs.block_encoding.linear_combination import LinearCombination
from qualtran.bloqs.reflections.reflection_using_prepare import ReflectionUsingPrepare
from qualtran.bloqs.state_preparation.prepare_base import PrepareOracle
from qualtran.bloqs.state_preparation.black_box_prepare import BlackBoxPrepare
from qualtran.symbolics import is_symbolic, SymbolicFloat, SymbolicInt

if TYPE_CHECKING:
Expand Down Expand Up @@ -108,7 +108,7 @@ def epsilon(self) -> SymbolicFloat:
return self.block_encoding.epsilon * self.order

@property
def signal_state(self) -> PrepareOracle:
def signal_state(self) -> BlackBoxPrepare:
# This method will be implemented in the future after PrepareOracle
# is updated for the BlockEncoding interface.
# Github issue: https://github.com/quantumlib/Qualtran/issues/1104
Expand Down Expand Up @@ -242,7 +242,7 @@ def selection_registers(self) -> Tuple[Register, ...]:
return (self.signature.get_right("ancilla"),) if self.ancilla_bitsize > 0 else ()

@property
def signal_state(self) -> PrepareOracle:
def signal_state(self) -> BlackBoxPrepare:
# This method will be implemented in the future after PrepareOracle
# is updated for the BlockEncoding interface.
# Github issue: https://github.com/quantumlib/Qualtran/issues/1104
Expand Down
4 changes: 2 additions & 2 deletions qualtran/bloqs/block_encoding/chebyshev_polynomial_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
ChebyshevPolynomial,
)
from qualtran.bloqs.for_testing.matrix_gate import MatrixGate
from qualtran.bloqs.state_preparation.prepare_base import PrepareOracle
from qualtran.bloqs.state_preparation.black_box_prepare import BlackBoxPrepare
from qualtran.linalg.matrix import random_hermitian_matrix
from qualtran.symbolics import is_symbolic, SymbolicFloat, SymbolicInt
from qualtran.testing import assert_equivalent_bloq_example_counts, execute_notebook
Expand Down Expand Up @@ -189,7 +189,7 @@ def signature(self) -> Signature:
return Signature.build(system=1, ancilla=1, resource=1)

@property
def signal_state(self) -> PrepareOracle:
def signal_state(self) -> BlackBoxPrepare:
raise NotImplementedError

def build_composite_bloq(
Expand Down
4 changes: 2 additions & 2 deletions qualtran/bloqs/block_encoding/linear_combination.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from qualtran.bloqs.block_encoding.phase import Phase
from qualtran.bloqs.bookkeeping.auto_partition import AutoPartition, Unused
from qualtran.bloqs.bookkeeping.partition import Partition
from qualtran.bloqs.state_preparation.prepare_base import PrepareOracle
from qualtran.bloqs.state_preparation.black_box_prepare import BlackBoxPrepare
from qualtran.linalg.lcu_util import preprocess_probabilities_for_reversible_sampling
from qualtran.symbolics import smax, ssum, SymbolicFloat, SymbolicInt
from qualtran.symbolics.types import is_symbolic
Expand Down Expand Up @@ -170,7 +170,7 @@ def epsilon(self) -> SymbolicFloat:
)

@property
def signal_state(self) -> PrepareOracle:
def signal_state(self) -> BlackBoxPrepare:
# This method will be implemented in the future after PrepareOracle
# is updated for the BlockEncoding interface.
# GitHub issue: https://github.com/quantumlib/Qualtran/issues/1104
Expand Down
4 changes: 2 additions & 2 deletions qualtran/bloqs/block_encoding/phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from qualtran import bloq_example, BloqBuilder, BloqDocSpec, QAny, Signature, SoquetT
from qualtran.bloqs.basic_gates import GlobalPhase
from qualtran.bloqs.block_encoding import BlockEncoding
from qualtran.bloqs.state_preparation.prepare_base import PrepareOracle
from qualtran.bloqs.state_preparation.black_box_prepare import BlackBoxPrepare
from qualtran.resource_counting import BloqCountT, SympySymbolAllocator
from qualtran.symbolics import SymbolicFloat, SymbolicInt

Expand Down Expand Up @@ -79,7 +79,7 @@ def pretty_name(self) -> str:
return f"B[exp({self.phi}i){self.block_encoding.pretty_name()[2:-1]}]"

@property
def signal_state(self) -> PrepareOracle:
def signal_state(self) -> BlackBoxPrepare:
# This method will be implemented in the future after PrepareOracle
# is updated for the BlockEncoding interface.
# GitHub issue: https://github.com/quantumlib/Qualtran/issues/1104
Expand Down
4 changes: 2 additions & 2 deletions qualtran/bloqs/block_encoding/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from qualtran.bloqs.bookkeeping.auto_partition import AutoPartition, Unused
from qualtran.bloqs.bookkeeping.partition import Partition
from qualtran.bloqs.mcmt.multi_control_multi_target_pauli import MultiControlPauli
from qualtran.bloqs.state_preparation.prepare_base import PrepareOracle
from qualtran.bloqs.state_preparation.black_box_prepare import BlackBoxPrepare
from qualtran.symbolics import is_symbolic, prod, smax, ssum, SymbolicFloat, SymbolicInt


Expand Down Expand Up @@ -125,7 +125,7 @@ def epsilon(self) -> SymbolicFloat:
return ssum(u.alpha * u.epsilon for u in self.block_encodings)

@property
def signal_state(self) -> PrepareOracle:
def signal_state(self) -> BlackBoxPrepare:
# This method will be implemented in the future after PrepareOracle
# is updated for the BlockEncoding interface.
# Github issue: https://github.com/quantumlib/Qualtran/issues/1104
Expand Down
4 changes: 2 additions & 2 deletions qualtran/bloqs/block_encoding/sparse_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from qualtran.bloqs.block_encoding import BlockEncoding
from qualtran.bloqs.bookkeeping.auto_partition import AutoPartition, Unused
from qualtran.bloqs.data_loading import QROM
from qualtran.bloqs.state_preparation.prepare_base import PrepareOracle
from qualtran.bloqs.state_preparation.black_box_prepare import BlackBoxPrepare
from qualtran.bloqs.state_preparation.prepare_uniform_superposition import (
PrepareUniformSuperposition,
)
Expand Down Expand Up @@ -209,7 +209,7 @@ def epsilon(self) -> SymbolicFloat:
return self.eps

@property
def signal_state(self) -> PrepareOracle:
def signal_state(self) -> BlackBoxPrepare:
# This method will be implemented in the future after PrepareOracle
# is updated for the BlockEncoding interface.
# Github issue: https://github.com/quantumlib/Qualtran/issues/1104
Expand Down
4 changes: 2 additions & 2 deletions qualtran/bloqs/block_encoding/tensor_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
)
from qualtran.bloqs.block_encoding import BlockEncoding
from qualtran.bloqs.bookkeeping import Partition
from qualtran.bloqs.state_preparation.prepare_base import PrepareOracle
from qualtran.bloqs.state_preparation.black_box_prepare import BlackBoxPrepare
from qualtran.resource_counting import BloqCountT, SympySymbolAllocator
from qualtran.symbolics import is_symbolic, prod, ssum, SymbolicFloat, SymbolicInt

Expand Down Expand Up @@ -101,7 +101,7 @@ def epsilon(self) -> SymbolicFloat:
return ssum(u.alpha * u.epsilon for u in self.block_encodings)

@property
def signal_state(self) -> PrepareOracle:
def signal_state(self) -> BlackBoxPrepare:
# This method will be implemented in the future after PrepareOracle
# is updated for the BlockEncoding interface.
# Github issue: https://github.com/quantumlib/Qualtran/issues/1104
Expand Down
4 changes: 2 additions & 2 deletions qualtran/bloqs/block_encoding/unitary.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from qualtran import Bloq, bloq_example, BloqBuilder, BloqDocSpec, QAny, Side, Signature, SoquetT
from qualtran.bloqs.block_encoding import BlockEncoding
from qualtran.bloqs.state_preparation.prepare_base import PrepareOracle
from qualtran.bloqs.state_preparation.black_box_prepare import BlackBoxPrepare
from qualtran.resource_counting import BloqCountT, SympySymbolAllocator
from qualtran.symbolics import SymbolicFloat, SymbolicInt

Expand Down Expand Up @@ -73,7 +73,7 @@ def pretty_name(self) -> str:
return f"B[{self.U.pretty_name()}]"

@property
def signal_state(self) -> PrepareOracle:
def signal_state(self) -> BlackBoxPrepare:
# This method will be implemented in the future after PrepareOracle
# is updated for the BlockEncoding interface.
# Github issue: https://github.com/quantumlib/Qualtran/issues/1104
Expand Down
10 changes: 5 additions & 5 deletions qualtran/bloqs/chemistry/df/double_factorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
from qualtran.bloqs.chemistry.df.select_bloq import ProgRotGateArray
from qualtran.bloqs.reflections.prepare_identity import PrepareIdentity
from qualtran.bloqs.reflections.reflection_using_prepare import ReflectionUsingPrepare
from qualtran.bloqs.state_preparation.prepare_base import PrepareOracle
from qualtran.bloqs.state_preparation.black_box_prepare import BlackBoxPrepare

if TYPE_CHECKING:
from qualtran.resource_counting import BloqCountT, SympySymbolAllocator
Expand Down Expand Up @@ -166,8 +166,8 @@ def target_registers(self) -> Iterable[Register]:
return (Register("sys", QAny(bitsize=self.num_spin_orb // 2), shape=(2,)),)

@property
def signal_state(self) -> PrepareOracle:
return PrepareIdentity(self.selection_registers)
def signal_state(self) -> BlackBoxPrepare:
return BlackBoxPrepare(PrepareIdentity(self.selection_registers))

@cached_property
def signature(self) -> Signature:
Expand Down Expand Up @@ -414,8 +414,8 @@ def target_registers(self) -> Iterable[Register]:
return (Register("sys", QAny(bitsize=self.num_spin_orb // 2), shape=(2,)),)

@property
def signal_state(self) -> PrepareOracle:
return PrepareIdentity(self.selection_registers)
def signal_state(self) -> BlackBoxPrepare:
return BlackBoxPrepare(PrepareIdentity(self.selection_registers))

@cached_property
def signature(self) -> Signature:
Expand Down
10 changes: 5 additions & 5 deletions qualtran/bloqs/chemistry/sf/single_factorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
from qualtran.bloqs.chemistry.sf.select_bloq import SelectSingleFactorization
from qualtran.bloqs.reflections.prepare_identity import PrepareIdentity
from qualtran.bloqs.reflections.reflection_using_prepare import ReflectionUsingPrepare
from qualtran.bloqs.state_preparation.prepare_base import PrepareOracle
from qualtran.bloqs.state_preparation.black_box_prepare import BlackBoxPrepare

if TYPE_CHECKING:
from qualtran.resource_counting import BloqCountT, SympySymbolAllocator
Expand Down Expand Up @@ -176,8 +176,8 @@ def junk_registers(self) -> Iterable[Register]:
return ()

@property
def signal_state(self) -> PrepareOracle:
return PrepareIdentity(self.selection_registers)
def signal_state(self) -> BlackBoxPrepare:
return BlackBoxPrepare(PrepareIdentity(self.selection_registers))

@cached_property
def signature(self) -> Signature:
Expand Down Expand Up @@ -381,8 +381,8 @@ def signature(self) -> Signature:
)

@property
def signal_state(self) -> PrepareOracle:
return PrepareIdentity(self.selection_registers)
def signal_state(self) -> BlackBoxPrepare:
return BlackBoxPrepare(PrepareIdentity(self.selection_registers))

def build_composite_bloq(
self,
Expand Down

0 comments on commit 5fbfe53

Please sign in to comment.