Skip to content

Commit fd90af1

Browse files
HowWeiBinabmazitov
andauthored
Update to metatrain v2026.3.1 (#153)
* Update pyproject.toml Try to see if it works with latest metatrain * Update ASE documentation URL in conf.py * Add deprecation warning for torch.jit.interface * Add deprecation warning for torch.jit.set_fusion_strategy * Update pyproject.toml with new deprecation warnings Added deprecation warnings for NumPy and model outputs. * Comment out deprecated warning in pyproject.toml Comment out deprecated warning for thermalize_momenta * Uncomment deprecation warning for thermalize_momenta * Fixed the singular-plural convention in targets * Added a scm versioning and relaxed the nvidia libraries version requirements * Cleaned up the __init__.py --------- Co-authored-by: Arslan Mazitov <arslan.mazitov@phystech.edu>
1 parent c1353f5 commit fd90af1

7 files changed

Lines changed: 34 additions & 37 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ __pycache__/
1515
*.ipynb
1616

1717
# Distribution / packaging
18+
_scm_version.py
1819
.Python
1920
build/
2021
develop-eggs/

docs/src/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"python": ("https://docs.python.org/3", None),
5252
"numpy": ("https://numpy.org/doc/stable/", None),
5353
"torch": ("https://docs.pytorch.org/docs/stable/", None),
54-
"ase": ("https://ase-lib.org/", None),
54+
"ase": ("https://docs.ase-lib.org/", None),
5555
"metatensor": ("https://docs.metatensor.org/latest/", None),
5656
"metatomic": ("https://docs.metatensor.org/metatomic/latest/", None),
5757
"metatrain": ("https://docs.metatensor.org/metatrain/latest/", None),

pyproject.toml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ maintainers = [
2323
]
2424

2525
dependencies = [
26-
"metatrain>=2026.2,<2026.3",
26+
"metatrain>=2026.3.1, <2026.4",
2727
"metatomic-ase",
28-
"nvalchemi-toolkit-ops==0.3.0",
29-
"warp-lang==1.13.0",
28+
"nvalchemi-toolkit-ops",
29+
"warp-lang",
3030
"huggingface_hub",
3131
"hf_xet",
3232
"packaging",
@@ -60,18 +60,23 @@ repository = "https://github.com/lab-cosmo/upet"
6060
[build-system]
6161
requires = [
6262
"setuptools >= 68",
63+
"setuptools_scm>=8",
6364
"wheel",
6465
]
6566
build-backend = "setuptools.build_meta"
6667

6768
[tool.setuptools.packages.find]
6869
where = ["src"]
6970

70-
[tool.setuptools.dynamic]
71-
version = {attr = "upet.__version__"}
71+
[tool.setuptools_scm]
72+
version_file = "src/upet/_scm_version.py"
73+
74+
[tool.check-manifest]
75+
ignore = ["src/upet/_scm_version.py"]
7276

7377
[tool.ruff]
7478
line-length = 88
79+
exclude = ["src/upet/_scm_version.py"]
7580

7681
[tool.ruff.lint]
7782
select = ["E", "F", "B", "I"]
@@ -115,6 +120,8 @@ filterwarnings = [
115120
"ignore: `torch.jit.save` is deprecated.*:DeprecationWarning",
116121
"ignore: `torch.jit.load` is deprecated.*:DeprecationWarning",
117122
"ignore: `torch.jit.script_method` is deprecated. Please switch to `torch.compile` or `torch.export`.",
123+
"ignore: `torch.jit.interface` is deprecated. Please use `torch.compile` instead.",
124+
"ignore: `torch.jit.set_fusion_strategy` is deprecated. Please use `torch.compile` instead.",
118125
# PET-MAD v1.0 deprecation warning
119126
"ignore:.*is deprecated in favor of the newer PET-MAD-1.5.*:DeprecationWarning",
120127
# NVAlchemiOps Deprecation warning
@@ -124,4 +131,11 @@ filterwarnings = [
124131
"ignore:`compute_requested_neighbors_from_options` is deprecated.*:UserWarning",
125132
# HF Xet deprecation warning
126133
"ignore:hf_xet.download_files\\(\\) is deprecated. Use XetSession\\(\\):DeprecationWarning",
134+
# Numpy warning
135+
"ignore: Setting the shape on a NumPy array has been deprecated in NumPy 2.5.",
136+
# MD
137+
"ignore: Use thermalize_momenta",
138+
# New metatomic release warnings
139+
"ignore: the 'features' output name is deprecated:UserWarning",
140+
"ignore: the 'non_conservative_forces' output name is deprecated:UserWarning",
127141
]

src/upet/__init__.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,15 @@
1-
__version__ = "0.2.5"
2-
31
import warnings
42

53
import torch
6-
from warp._src import utils as wp_utils
74

85
from ._models import get_upet, list_upet, save_upet
6+
from ._scm_version import __version__ # noqa: F401
97

108

11-
# hides a harmless warning from nvalchemi's neighbor list implmentation
129
warnings.filterwarnings(
13-
"ignore",
14-
category=UserWarning,
15-
message="The .grad attribute of a Tensor that is not a leaf Tensor",
10+
"ignore", category=DeprecationWarning, message="warp.config.quiet is deprecated"
1611
)
1712

18-
# we want to suppress a further warning from nvalchemi's usage of warp
19-
# warp uses an internal warn() helper: we wrap it.
20-
_orig_warn = wp_utils.warn
21-
22-
23-
def _warn_filtered(message, category=None, stacklevel=1):
24-
if category is DeprecationWarning and "warp.vec" in str(message):
25-
return
26-
return _orig_warn(message, category=category, stacklevel=stacklevel)
27-
28-
29-
wp_utils.warn = _warn_filtered
30-
3113
# Disable static fusion. Besides the fact that atomistic batches have variable
3214
# sizes, statically fused CUDA kernels cannot allocate new tensors at runtime,
3315
# causing "Global alloc not supported yet" errors (cuda 13+) at the time of writing

src/upet/calculator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def __init__(
158158
if non_conservative:
159159
selected_variant = None if variants is None else variants.get("energy")
160160
variant_postfix = f"/{selected_variant}" if selected_variant else ""
161-
nc_forces_key = "non_conservative_forces" + variant_postfix
161+
nc_forces_key = "non_conservative_force" + variant_postfix
162162
nc_stress_key = "non_conservative_stress" + variant_postfix
163163
if nc_forces_key not in model_outputs or nc_stress_key not in model_outputs:
164164
raise NotImplementedError(

src/upet/explore/_explorer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class MADExplorer(torch.nn.Module):
2323
:param output_dim: target low dimensionality for the projected embeddings
2424
:param device: cpu or cuda
2525
:param features_output: key to access the PET-MAD feature output.
26-
mtt::aux::energy_last_layer_features is used by default
26+
mtt::aux::energy_last_layer_feature is used by default
2727
"""
2828

2929
def __init__(
@@ -57,17 +57,17 @@ def forward(
5757
outputs: Dict[str, mta.ModelOutput],
5858
selected_atoms: Optional[mts.Labels],
5959
) -> Dict[str, mts.TensorMap]:
60-
if list(outputs.keys()) != ["features"]:
60+
if list(outputs.keys()) != ["feature"]:
6161
raise ValueError(
6262
f"`outputs` keys ({', '.join(outputs.keys())}) contain unsupported "
63-
"keys. Only 'features' is supported"
63+
"keys. Only 'feature' is supported"
6464
)
6565

6666
systems = [s.to(self.dtype, self.device) for s in systems]
6767

68-
per_atom = outputs["features"].per_atom
68+
sample_kind = outputs["feature"].sample_kind
6969
pet_requested_outputs = {
70-
self.features_output: mta.ModelOutput(per_atom=per_atom)
70+
self.features_output: mta.ModelOutput(sample_kind=sample_kind)
7171
}
7272

7373
if selected_atoms is not None:
@@ -113,7 +113,7 @@ def forward(
113113
blocks=[block],
114114
)
115115

116-
return {"features": tensor_map}
116+
return {"feature": tensor_map}
117117

118118
def _get_features(
119119
self,
@@ -134,7 +134,7 @@ def _get_features(
134134
if selected_atoms is not None:
135135
features = mts.slice(features, "samples", selected_atoms)
136136

137-
if outputs[self.features_output].per_atom:
137+
if outputs[self.features_output].sample_kind == "atom":
138138
mean = mts.mean_over_samples(features, "atom")
139139
mean_vals = torch.cat([block.values for block in mean.blocks()], dim=0)
140140

src/upet/explore/_featurizer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def __init__(
113113
explorer = MADExplorer(petmad.module, device=device)
114114
explorer.load_checkpoint(petmad_explorer_path)
115115

116-
outputs = {"features": mta.ModelOutput(per_atom=True)}
116+
outputs = {"feature": mta.ModelOutput(sample_kind="atom")}
117117
self.dtype = torch.float64
118118

119119
capabilities = mta.ModelCapabilities(
@@ -155,7 +155,7 @@ def __call__(self, frames, environments):
155155

156156
options = mta.ModelEvaluationOptions(
157157
length_unit=self.length_unit,
158-
outputs={"features": mta.ModelOutput(per_atom=True)},
158+
outputs={"feature": mta.ModelOutput(sample_kind="atom")},
159159
selected_atoms=selected_atoms,
160160
)
161161

@@ -169,7 +169,7 @@ def __call__(self, frames, environments):
169169
check_consistency=self.check_consistency,
170170
)
171171
outputs.append(
172-
batch_outputs["features"].block().values.detach().cpu().numpy()
172+
batch_outputs["feature"].block().values.detach().cpu().numpy()
173173
)
174174

175175
return np.concatenate(outputs)

0 commit comments

Comments
 (0)