Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ repos:
exclude: ^source/3rdparty
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.14.14
rev: v0.15.0
hooks:
- id: ruff
args: ["--fix"]
Expand Down
26 changes: 14 additions & 12 deletions deepmd/dpmodel/utils/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ def save_dp_model(filename: str, model_dict: dict) -> None:
with h5py.File(filename, "w") as f:
model_dict = traverse_model_dict(
model_dict,
lambda x: f.create_dataset(
f"variable_{variable_counter():04d}", data=x
).name,
lambda x: (
f.create_dataset(f"variable_{variable_counter():04d}", data=x).name
),
)
save_dict = {
**extra_dict,
Expand All @@ -118,15 +118,17 @@ def save_dp_model(filename: str, model_dict: dict) -> None:
elif filename_extension in {".yaml", ".yml"}:
model_dict = traverse_model_dict(
model_dict,
lambda x: {
"@class": "np.ndarray",
"@is_variable": True,
"@version": 1,
"dtype": x.dtype.name,
"value": x.tolist(),
}
if isinstance(x, np.ndarray)
else x,
lambda x: (
{
"@class": "np.ndarray",
"@is_variable": True,
"@version": 1,
"dtype": x.dtype.name,
"value": x.tolist(),
}
if isinstance(x, np.ndarray)
else x
),
)
with open(filename, "w") as f:
yaml.safe_dump(
Expand Down
6 changes: 4 additions & 2 deletions deepmd/pd/utils/multi_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ def replace_one_item(
for shared_key in shared_links:
shared_links[shared_key]["links"] = sorted(
shared_links[shared_key]["links"],
key=lambda x: x["shared_level"]
- ("spin" in model_config["model_dict"][x["model_key"]]) * 100,
key=lambda x: (
x["shared_level"]
- ("spin" in model_config["model_dict"][x["model_key"]]) * 100
),
)
# little trick to make spin models in the front to be the base models,
# because its type embeddings are more general.
Expand Down
6 changes: 4 additions & 2 deletions deepmd/pt/utils/multi_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ def replace_one_item(
for shared_key in shared_links:
shared_links[shared_key]["links"] = sorted(
shared_links[shared_key]["links"],
key=lambda x: x["shared_level"]
- ("spin" in model_config["model_dict"][x["model_key"]]) * 100,
key=lambda x: (
x["shared_level"]
- ("spin" in model_config["model_dict"][x["model_key"]]) * 100
),
)
# little trick to make spin models in the front to be the base models,
# because its type embeddings are more general.
Expand Down