← Back to Pull requests

fix(pt_expt): preserve numb_dos for exported DOS models #6041

Open
unknown opened this pull request with 223 lines diff across 2 files
View on GitHub
unknown unknown commented on Oct 01, 2026 09:12 UTC
Author

Fixes #5949.

A user with a pt_expt DOS model configured with numb_dos: 2, exported to .pte or .pt2, gets ValueError: cannot reshape array of size 2 into shape (1,0) from DeepDOS.eval, because the exported model reports a DOS width of 0.

Two gaps caused it:

  • deepmd/pt_expt/model/dos_model.py::DOSModel had no get_numb_dos, so it fell back to the base default of 0. It now returns the fitting net's dim_out, as the dpmodel and pt DOS models do.

  • deepmd/pt_expt/infer/deep_eval.py::get_numb_dos returned 0 unconditionally. It now asks the reconstructed dpmodel, and for metadata-only archives (no extra/model.json) it reads a new numb_dos key. That key is written to metadata.json only for models with a dos output, and archives without it read as 0 as before.
  • Test: source/tests/pt_expt/infer/test_deep_eval_dos.py exports a numb_dos=2 se_e2_a DOS model to .pte and .pt2, in full and metadata-only form, and checks get_numb_dos() and the shapes returned by DeepDOS.eval. It also checks that an energy archive gets no numb_dos key. With the three source files reverted to the base commit, pytest reports 9 failures (0 != 2 and 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 -->

    Diff: 223 lines (+167 / -56) across 2 files Reviewer: Arthur031221 Review duration: 27942m
    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
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.8% (MEDIUM) · Higher = larger blast radius
    36.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.6% · Safe to merge
    19.6%