Commit 9d2f577
Han Wang
test(cc): regression test for atomic_virial fail-fast guard
Closes the coverage gap left by commit c80db58: the
'atomic && !do_atomic_virial' throw branch in DeepPotPTExpt::compute
was not exercised by any existing test.
Approach:
* gen_sea.py: after exporting deeppot_sea.pt2 with do_atomic_virial=
True, copy the archive to deeppot_sea_no_atomic_virial.pt2 and
patch its metadata.json so do_atomic_virial=False. Cheap (ZIP
rewrite, no AOTInductor recompile — adds <1s to gen time). Use
ZIP_STORED to match the format expected by the C++ read_zip_entry
in commonPTExpt.h.
* test_deeppot_ptexpt.cc: new TYPED_TEST cpu_atomic_throws_when_
disabled — load the patched .pt2, call compute() with atomic=true,
expect deepmd_exception. Also verify atomic=false on the same
model still works (sanity check that the guard fires only when
actually requested).
Covers the most-impactful gap from PR #5407's review: the change in
.pt2 default (do_atomic_virial off) made this code path the typical
failure mode for users who'd previously been getting per-atom virial
"for free". Without this test, regressions in the throw or in the
metadata round-trip would slip through.1 parent e30206d commit 9d2f577
2 files changed
Lines changed: 88 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
581 | 581 | | |
582 | 582 | | |
583 | 583 | | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
584 | 630 | | |
585 | 631 | | |
586 | 632 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
62 | 74 | | |
63 | 75 | | |
64 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
65 | 107 | | |
66 | 108 | | |
0 commit comments