Skip to content

Commit

Permalink
Update to QECGatesCost
Browse files Browse the repository at this point in the history
  • Loading branch information
fdmalone committed Dec 5, 2024
1 parent 1fae515 commit 4dd4911
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

import pytest

from qualtran.bloqs.basic_gates import Toffoli
from qualtran.bloqs.chemistry.pbc.first_quantization.projectile.prepare_t import (
_prep_power_two_proj,
_prep_t_proj,
PreparePowerTwoStateWithProj,
PrepareTFirstQuantizationWithProj,
)
from qualtran.resource_counting import get_cost_value, QECGatesCost


def test_prep_t_proj(bloq_autotester):
Expand All @@ -40,12 +40,15 @@ def test_prepare_kinetic_t_proj_counts():
qual_cost = 0
prep = PrepareTFirstQuantizationWithProj(num_bits_p, num_bits_n, eta, num_bits_rot_aa=b_r)
_, counts = prep.call_graph()
qual_cost += counts[Toffoli()]
counts = get_cost_value(prep, QECGatesCost())
cost_dict = counts.total_t_and_ccz_count()
qual_cost += cost_dict['n_ccz']
prep = PrepareTFirstQuantizationWithProj(
num_bits_p, num_bits_n, eta, num_bits_rot_aa=b_r
).adjoint()
_, counts = prep.call_graph()
qual_cost += counts[Toffoli()]
counts = get_cost_value(prep, QECGatesCost())
cost_dict = counts.total_t_and_ccz_count()
qual_cost += cost_dict['n_ccz']
assert qual_cost == expected_cost


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
# 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 qualtran.bloqs.basic_gates import Toffoli
from qualtran.bloqs.chemistry.pbc.first_quantization.projectile.select_t import (
_sel_t_proj,
SelectTFirstQuantizationWithProj,
)
from qualtran.resource_counting import get_cost_value, QECGatesCost


def test_sel_t_proj(bloq_autotester):
Expand All @@ -25,5 +25,6 @@ def test_sel_t_proj(bloq_autotester):
def test_select_kinetic_t_counts():
num_bits_n = 6
sel = SelectTFirstQuantizationWithProj(num_bits_n, 10)
_, counts = sel.call_graph()
assert counts[Toffoli()] == 5 * (num_bits_n - 1) + 2 + 1
counts = get_cost_value(sel, QECGatesCost())
cost_dict = counts.total_t_and_ccz_count()
assert cost_dict['n_ccz'] == 5 * (num_bits_n - 1) + 2 + 1

0 comments on commit 4dd4911

Please sign in to comment.