This issue was found by a Codex global repository scan of tracked non-test files at commit 8c93925cb10b401b2b83c738bd9263fd74474468.
Relevant code
|
|
|
efficiency = [] |
|
for i, atoms in enumerate(test_atoms): |
|
# find maximum allowed natoms |
|
max_natoms = binary_search_max_natoms(model, atoms, natoms_upper_limit) |
|
# on-the-fly expand atoms |
|
scaling_factor = np.int32(np.floor(max_natoms / len(atoms))) |
|
a, b, c = find_even_factors(scaling_factor) # a,b,c is in ascending order |
|
|
|
cell_length = atoms.get_cell_lengths_and_angles()[:3] |
|
scaling_index = np.argsort( |
|
cell_length |
|
).tolist() # sort cell length by ascending order |
|
# expand atoms, repeat shorter cell axis with larger scaling factor |
|
a, b, c = ( |
|
[c, b, a][scaling_index[0]], |
|
[c, b, a][scaling_index[1]], |
|
[c, b, a][scaling_index[2]], |
|
) |
|
atoms = atoms.repeat((a, b, c)) |
|
model.calc.reset() # reset calculator to prevent cached results |
|
atoms.calc = model.calc |
|
divisors = set() |
|
for i in range(1, int(math.isqrt(num)) + 1): |
|
if num % i == 0: |
|
divisors.add(i) |
|
divisors.add(num // i) |
|
return sorted(divisors) |
|
|
|
|
|
def find_even_factors(num: int) -> tuple[int, int, int]: |
|
""" |
|
Find three factors of a number that are as evenly distributed as possible. |
|
The function returns a tuple of three factors (a, b, c) such that a * b * c = num. |
|
The factors are sorted in ascending order (a <= b <= c). |
|
""" |
|
divisors = get_divisors(num) |
|
best = None |
|
min_spread = float("inf") |
|
|
|
for a in divisors: |
|
num_div_a = num // a |
|
divisors_b = get_divisors(num_div_a) |
|
|
|
# Since a <= b <= c, no need to consider b < a |
|
for b in divisors_b: |
|
if b < a: |
Impact
When len(atoms) > natoms_upper_limit, scaling_factor = floor(max_natoms / len(atoms)) becomes 0. find_even_factors(0) returns None, so unpacking a, b, c raises before inference can run.
That turns an oversized input structure into a task-level failure instead of benchmarking the original structure or reporting a controlled skip.
Suggested fix
Clamp the expansion factor to at least 1, or explicitly skip expansion and benchmark the original structure when the cap is below the input atom count. Add a regression test with len(atoms) > natoms_upper_limit.
This issue was found by a Codex global repository scan of tracked non-test files at commit
8c93925cb10b401b2b83c738bd9263fd74474468.Relevant code
LAMBench/lambench/tasks/calculator/inference_efficiency/inference_efficiency.py
Lines 70 to 91 in 8c93925
LAMBench/lambench/tasks/calculator/inference_efficiency/efficiency_utils.py
Lines 42 to 66 in 8c93925
Impact
When
len(atoms) > natoms_upper_limit,scaling_factor = floor(max_natoms / len(atoms))becomes0.find_even_factors(0)returnsNone, so unpackinga, b, craises before inference can run.That turns an oversized input structure into a task-level failure instead of benchmarking the original structure or reporting a controlled skip.
Suggested fix
Clamp the expansion factor to at least
1, or explicitly skip expansion and benchmark the original structure when the cap is below the input atom count. Add a regression test withlen(atoms) > natoms_upper_limit.