-
Notifications
You must be signed in to change notification settings - Fork 615
fix(dpmodel): align NativeLayer bias/idt init with pt MLPLayer #5428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wanghan-iapcm
merged 7 commits into
deepmodeling:master
from
wanghan-iapcm:fix-pt-expt-native-layer-init
May 3, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ff6a931
fix(dpmodel): align NativeLayer bias/idt init with pt MLPLayer
35d5cb2
test: replace hardcoded C++ expected values with sidecar reference files
ba1249a
test(lmp): replace hardcoded expected values in DPA3 LAMMPS tests wit…
27d284b
test(lmp): guard sidecar load against missing file in non-PyTorch CI …
00c45a6
test: address coderabbit review on PR #5428
a444251
test(lmp): inline atom-energy sum to drop unused expected_ae global
d3704b9
test(lmp): reject negative array counts in expected_ref parser
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,3 +73,4 @@ frozen_model.* | |
|
|
||
| # Test system directories | ||
| system/ | ||
| *.expected | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| // SPDX-License-Identifier: LGPL-3.0-or-later | ||
| #pragma once | ||
|
|
||
| #include <fstream> | ||
| #include <map> | ||
| #include <sstream> | ||
| #include <stdexcept> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| namespace deepmd_test { | ||
|
|
||
| // Loader for sidecar reference files written by | ||
| // `gen_common.write_expected_ref`. | ||
| // | ||
| // File format: | ||
| // # auto-generated -- do not edit | ||
| // [case_name_1] | ||
| // array_name_1 N | ||
| // v0 | ||
| // v1 | ||
| // ... | ||
| // array_name_2 M | ||
| // ... | ||
| // | ||
| // [case_name_2] | ||
| // ... | ||
| // | ||
| // Lines beginning with '#' or empty lines are ignored. | ||
| class ExpectedRef { | ||
| public: | ||
| // Parse `path`. Throws std::runtime_error on malformed input. | ||
| void load(const std::string& path) { | ||
| std::ifstream in(path); | ||
| if (!in) { | ||
| throw std::runtime_error("ExpectedRef: cannot open " + path); | ||
| } | ||
| sections_.clear(); | ||
| std::string line; | ||
| std::string current_section; | ||
| while (std::getline(in, line)) { | ||
| if (line.empty() || line[0] == '#') { | ||
| continue; | ||
| } | ||
| if (line.front() == '[' && line.back() == ']') { | ||
| current_section = line.substr(1, line.size() - 2); | ||
| continue; | ||
| } | ||
| // "<key> <count>" header — followed by `count` numeric lines. | ||
| if (current_section.empty()) { | ||
| throw std::runtime_error("ExpectedRef: array '" + line + | ||
| "' before any [section]"); | ||
| } | ||
| std::istringstream iss(line); | ||
| std::string key; | ||
| std::size_t n = 0; | ||
| if (!(iss >> key >> n)) { | ||
| throw std::runtime_error("ExpectedRef: bad header line: " + line); | ||
| } | ||
| std::vector<double> values; | ||
| values.reserve(n); | ||
| for (std::size_t i = 0; i < n; ++i) { | ||
| if (!std::getline(in, line)) { | ||
| throw std::runtime_error("ExpectedRef: unexpected EOF in '" + key + | ||
| "'"); | ||
| } | ||
| values.push_back(std::stod(line)); | ||
| } | ||
| sections_[current_section][key] = std::move(values); | ||
| } | ||
| } | ||
|
|
||
| // Get array of `key` from `case_name`. Throws if missing. | ||
| template <typename T = double> | ||
| std::vector<T> get(const std::string& case_name, | ||
| const std::string& key) const { | ||
| auto sit = sections_.find(case_name); | ||
| if (sit == sections_.end()) { | ||
| throw std::runtime_error("ExpectedRef: missing case '" + case_name + "'"); | ||
| } | ||
| auto kit = sit->second.find(key); | ||
| if (kit == sit->second.end()) { | ||
| throw std::runtime_error("ExpectedRef: missing array '" + key + | ||
| "' in case '" + case_name + "'"); | ||
| } | ||
| return std::vector<T>(kit->second.begin(), kit->second.end()); | ||
| } | ||
|
|
||
| private: | ||
| std::map<std::string, std::map<std::string, std::vector<double>>> sections_; | ||
| }; | ||
|
|
||
| } // namespace deepmd_test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.