fix(pt_expt): preserve numb_dos for exported DOS models #6041
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.37) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 223 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.324
Real PR Conversation Timeline
1 comments
"Review active on #6041"
general
weight: 0.35
Arthur031221
Fixes #5949.
A user with a pt_expt DOS model configured with
numb_dos: 2, exported to.pteor.pt2, getsValueError: cannot reshape array of size 2 into shape (1,0)fromDeepDOS.eval, because the exported model reports a DOS width of 0.Two gaps caused it:
deepmd/pt_expt/model/dos_model.py::DOSModelhad noget_numb_dos, so it fell back to the base default of 0. It now returns the fitting net'sdim_out, as the dpmodel and pt DOS models do.deepmd/pt_expt/infer/deep_eval.py::get_numb_dosreturned 0 unconditionally. It now asks the reconstructed dpmodel, and for metadata-only archives (noextra/model.json) it reads a newnumb_doskey. That key is written tometadata.jsononly for models with adosoutput, and archives without it read as 0 as before.Test:
source/tests/pt_expt/infer/test_deep_eval_dos.pyexports anumb_dos=2se_e2_a DOS model to.pteand.pt2, in full and metadata-only form, and checksget_numb_dos()and the shapes returned byDeepDOS.eval. It also checks that an energy archive gets nonumb_doskey. With the three source files reverted to the base commit, pytest reports 9 failures (0 != 2and the reshape error above); with the fix, 4 tests and 8 subtests pass. Reverting only the serialization change fails the four metadata-only subtests.<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
New Features
DeepDOS inference now reports the number of DOS outputs for full and metadata-only model archives.
DOS evaluation returns total and atomic density-of-states arrays with the model’s output width.
Energy models without a DOS output report a DOS count of zero.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->