fix(pt_expt): preserve graph routing for raw checkpoints#5885
Conversation
Select the eager lower ABI from the restored model capability instead of forcing every raw checkpoint through the padded dense neighbor-list path. Graph-eligible energy models now reuse the graph DeepEval contract, keeping energy, force, virial, and atomic outputs aligned with public forward semantics when descriptor statistics are nonzero. Retain the existing dense and spin paths, expose graph builder selection for raw graph checkpoints, and cover both plain and compiled checkpoint layouts with a deterministic DPA1 regression.
📝 WalkthroughWalkthroughPT checkpoint inference now detects graph-lower models, routes them through graph-native execution, records graph metadata, and validates output parity for plain and compiled DPA1 checkpoints. ChangesGraph-lower PT inference
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant DeepPot
participant DeepEval
participant EnergyModel
DeepPot->>DeepEval: load PT checkpoint
DeepEval->>EnergyModel: detect graph-lower capability
DeepEval->>EnergyModel: run graph-native forward
EnergyModel-->>DeepEval: return graph outputs
DeepEval-->>DeepPot: return translated public outputs
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Resolve the graph neighbor backend once when DeepEval loads the model. Prefer the batched nvalchemiops builder on CUDA, fall back to Vesin when available, and retain the dense all-pairs implementation as the dependency-free final fallback. This removes the single-core NumPy O(N²) graph construction bottleneck from the default dp test path while preserving every explicit builder selection. Cover the resolved backend in the raw DPA1 checkpoint regression.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5885 +/- ##
==========================================
- Coverage 78.87% 78.57% -0.30%
==========================================
Files 1054 1054
Lines 121770 121806 +36
Branches 4413 4412 -1
==========================================
- Hits 96046 95715 -331
- Misses 24159 24510 +351
- Partials 1565 1581 +16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
wanghan-iapcm
left a comment
There was a problem hiding this comment.
The routing fix is correct by construction (it keys on the same model_uses_graph_lower flag that drives the model's own forward(), so .pt eval goes graph iff forward() does), and the DPA1 nonzero-stats regression is a genuine test for #5862. One test-coverage note inline.
| f"Unknown nlist_backend '{nlist_backend}'; " | ||
| "expected 'auto', 'vesin', or 'native'." | ||
| ) | ||
| if self.metadata.get("lower_input_kind") in ("graph", "dpa1_canonical"): |
There was a problem hiding this comment.
This new graph-routed branch adds two reachable, user-facing guardrails that no test exercises: (1) the raise ValueError when an explicit neighbor_list is passed for a graph artifact, and (2) the warnings.warn when nlist_backend != "auto" for a graph artifact. Both are cheap to cover — construct DeepEval/DeepPot on the new graph DPA1 checkpoint with neighbor_list=<something> (assertRaises) and with nlist_backend="vesin" (assertWarns). Worth adding so every reachable branch here is tested.
Summary
model_uses_graph_lowercapabilitynvon CUDA, then Vesin, then dense fallback) sodp testdoes not stall in the single-core NumPy O(N²) builderCloses #5862
Test plan
pytest source/tests/pt_expt/infer/test_deep_eval_pt_checkpoint.py source/tests/pt_expt/infer/test_graph_deepeval.py -vnv; CPU auto route resolves to Vesin; both pass the raw checkpoint parity regressionpytest source/tests/pt_expt/model/test_dpa1_graph_lower.py source/tests/pt_expt/model/test_graph_builder_dispatch.py -vSummary by CodeRabbit
New Features
.ptcheckpoint loading and evaluation support.neighbor_graph_methodnow defaults toautoand applies graph-lower routing automatically.Bug Fixes
forward(..., do_atomic_virial=True).Tests
.ptcheckpoints.