Commit 5f848ad
test(pt_expt): tolerance for test_default_fallback (CUDA scatter nondeterminism) (deepmodeling#5508)
## Summary
`test_default_fallback` (added in deepmodeling#5491) compared `neighbor_list=None`
against an explicit `DefaultNeighborList()` with **exact** equality
(`assert_array_equal`). The two are the identical builder —
`call_common` does `builder = nl if nl is not None else
DefaultNeighborList()` — so on CPU the two forward passes are
bit-identical. But the test runs **two independent forward passes**, and
on **CUDA** the dpa3 GNN message-passing scatter (atomic adds) is not
bit-reproducible run-to-run. The virial differed by ~1 ULP (abs
`3.46e-18`, rel `5.64e-16`), failing the exact comparison
intermittently:
```
FAILED test_default_fallback[dpa3] - AssertionError: Arrays are not equal
dpa3 virial — Mismatched elements: 1 / 9 (11.1%)
Max absolute difference: 3.47e-18 ; Max relative difference: 5.64e-16
```
## Fix
Switch the comparison to `assert_allclose(rtol=1e-10, atol=1e-12)` — far
above the fp noise floor (~`1e-16` rel) but orders of magnitude tighter
than any real dispatch divergence (e.g. accidentally using a different
builder) would produce. Verified on CPU that `None` and
`DefaultNeighborList()` are bit-identical (max|Δ| = 0), confirming the
residual is CUDA atomic nondeterminism, not a dispatch bug.
## Known limitations
- Validated on CPU (8/8 `test_default_fallback` pass). The failing
**CUDA** path could not be re-validated locally (no GPU available this
session); the CI CUDA job is the confirmation. The tolerance is ~6
orders of magnitude above the observed noise, so it is robust.
- Relaxes the previously-exact comparison; this is the intended change.
The sibling `test_pt_expt_equivalence` tests already use a `1e-9`
tolerance.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
## Release Notes
* **Tests**
* Enhanced test robustness by implementing floating-point tolerance
comparisons instead of strict equality checks, ensuring reliable testing
across different hardware configurations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: Han Wang <wang_han@iapcm.ac.cn>1 parent e05af21 commit 5f848ad
1 file changed
Lines changed: 14 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
479 | | - | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
480 | 490 | | |
481 | 491 | | |
482 | 492 | | |
| |||
492 | 502 | | |
493 | 503 | | |
494 | 504 | | |
495 | | - | |
| 505 | + | |
496 | 506 | | |
497 | 507 | | |
| 508 | + | |
| 509 | + | |
498 | 510 | | |
499 | 511 | | |
0 commit comments