Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
fdmalone committed Jul 24, 2023
1 parent 9dd1c0d commit 458188d
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,3 @@ def test_momentum_transfer_map():
test = Q - k1 + k2
assert (np.amin(np.abs(test[None, :] - cell.Gv - kpts[0][None, :]))
< 1e-15)

Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
allow_module_level=True)

from .data_types import PBCResources, ResourceEstimates
from .qrom import QR2, QR3, QI2
from .qrom import QR2, QR3, QI2
from .rotation_param import compute_beta_for_resources
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,3 @@ def add_resources(
self.resources.append(resource_estimates)
self.cutoff.append(cutoff)
self.approx_energy.append(approx_energy)

Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,4 @@ def test_pbc_resources():
[0.07630829, 0.97798951, 0.26843898, 0.38094113, 0.21338535],
)
assert (df.toffolis_per_step.values == [919, 366, 895, 787, 949]).all()
assert (df.total_toffolis.values == [615, 554, 391, 444, 112]).all()


def test_qr2():
L = 728
npp = 182
bpp = 21
test_val = QR2(L + 1, npp, bpp)
assert np.isclose(test_val, 3416)

L = 56
npp = 28
bpp = 91
test_val = QR2(L + 1, npp, bpp)
assert np.isclose(test_val, 679)


def test_qi2():
L1 = 728
npp = 182
test_val = QI2(L1 + 1, npp)
assert np.isclose(test_val, 785)

L1 = 56
npp = 28
test_val = QI2(L1 + 1, npp)
assert np.isclose(test_val, 88)
assert (df.total_toffolis.values == [615, 554, 391, 444, 112]).all()
1 change: 1 addition & 0 deletions src/openfermion/resource_estimates/pbc/resources/qrom.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"""
import numpy as np


def QR3(L, M1):
r"""
QR[Ll_, m_] := Ceiling[MinValue[{Ll/2^k + m*(2^k - 1), k >= 0}, k
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"""Function defining beta parameter for controlled rotations in DF and THC"""
import numpy as np

def compute_beta_for_resources(num_spin_orbs: int,
num_kpts: int,

def compute_beta_for_resources(num_spin_orbs: int, num_kpts: int,
de_for_qpe: float):
"""Compute beta (number of bits for controlled rotations).
Expand All @@ -26,4 +26,3 @@ def compute_beta_for_resources(num_spin_orbs: int,
de_for_qpe: epsilon for phase estimation.
"""
return np.ceil(5.652 + np.log2(num_spin_orbs * num_kpts / de_for_qpe))

Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def generate_costing_table(
approx_eris = exact_eris
for cutoff in naux_cutoffs:
sf_helper = SingleFactorization(cholesky_factor=chol,
kmf=pyscf_mf,
naux=cutoff)
kmf=pyscf_mf,
naux=cutoff)
if pyscf_mf.cell.spin == 0:
approx_eris = build_approximate_eris(cc_inst,
sf_helper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
from sympy import factorint
from openfermion.resource_estimates.utils import QI

from openfermion.resource_estimates.pbc.resources import (
ResourceEstimates, QR3)
from openfermion.resource_estimates.pbc.resources import (ResourceEstimates,
QR3)


def compute_cost(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def generate_costing_table(
approx_eris = exact_eris
for thresh in thresholds:
sparse_helper = SparseFactorization(cholesky_factor=chol,
kmf=pyscf_mf,
threshold=thresh)
kmf=pyscf_mf,
threshold=thresh)
if pyscf_mf.cell.spin == 0:
approx_eris = build_approximate_eris(cc_inst,
sparse_helper,
Expand Down

0 comments on commit 458188d

Please sign in to comment.