Skip to content

Commit

Permalink
fix QPE test failure, add non-slow bloq example autotest
Browse files Browse the repository at this point in the history
  • Loading branch information
anurudhp committed Nov 6, 2024
1 parent 2b26082 commit 5d69e1b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
13 changes: 12 additions & 1 deletion qualtran/bloqs/phase_estimation/qubitization_qpe.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def decompose_from_registers(
qpre_reg = quregs['qpe_reg']

yield self.ctrl_state_prep.on(*qpre_reg)
yield walk_controlled.on_registers(**walk_regs, control=qpre_reg[-1])
yield walk_controlled.on_registers(**walk_regs, ctrl=qpre_reg[-1])
walk = self.walk**2
for i in range(self.m_bits - 2, -1, -1):
yield reflect_controlled.on_registers(control=qpre_reg[i], **reflect_regs)
Expand All @@ -143,6 +143,16 @@ def __str__(self) -> str:
return f'QubitizationQPE[{self.m_bits}]'


@bloq_example
def _qubitization_qpe_ising() -> QubitizationQPE:
from qualtran.bloqs.chemistry.ising.walk_operator import get_walk_operator_for_1d_ising_model
from qualtran.bloqs.phase_estimation import RectangularWindowState

walk, _ = get_walk_operator_for_1d_ising_model(4, 0.1)
qubitization_qpe_ising = QubitizationQPE(walk, RectangularWindowState(4))
return qubitization_qpe_ising


@bloq_example
def _qubitization_qpe_hubbard_model_small() -> QubitizationQPE:
import numpy as np
Expand Down Expand Up @@ -252,5 +262,6 @@ def _qubitization_qpe_sparse_chem() -> QubitizationQPE:
_qubitization_qpe_hubbard_model_small,
_qubitization_qpe_sparse_chem,
_qubitization_qpe_chem_thc,
_qubitization_qpe_ising,
),
)
5 changes: 5 additions & 0 deletions qualtran/bloqs/phase_estimation/qubitization_qpe_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from qualtran.bloqs.phase_estimation.qubitization_qpe import (
_qubitization_qpe_chem_thc,
_qubitization_qpe_hubbard_model_small,
_qubitization_qpe_ising,
_qubitization_qpe_sparse_chem,
QubitizationQPE,
)
Expand All @@ -29,6 +30,10 @@
from qualtran.testing import execute_notebook


def test_ising_example(bloq_autotester):
bloq_autotester(_qubitization_qpe_ising)


@pytest.mark.slow
def test_qubitization_qpe_bloq_autotester(bloq_autotester):
bloq_autotester(_qubitization_qpe_hubbard_model_small)
Expand Down
1 change: 1 addition & 0 deletions qualtran/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def assert_bloq_example_serializes_for_pytest(bloq_ex: BloqExample):
'qubitization_qpe_chem_thc', # too slow
'walk_op_chem_sparse',
'qubitization_qpe_sparse_chem', # too slow
'qubitization_qpe_ising',
'trott_unitary',
'symbolic_hamsim_by_gqsp',
'gf16_addition', # cannot serialize QGF
Expand Down

0 comments on commit 5d69e1b

Please sign in to comment.