Skip to content
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

pt: ban torch.testing.assert_allclose #3395

Merged
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
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ select = [
"C4", # flake8-comprehensions
"RUF", # ruff
"NPY", # numpy
"TID251", # banned-api
"TID253", # banned-module-level-imports
]

Expand Down Expand Up @@ -272,6 +273,9 @@ banned-module-level-imports = [
"torch",
]

[tool.ruff.lint.flake8-tidy-imports.banned-api]
"torch.testing.assert_allclose".msg = "Use `torch.testing.assert_close()` instead, see https://github.com/pytorch/pytorch/issues/61844."

[tool.ruff.lint.extend-per-file-ignores]
# Also ignore `E402` in all `__init__.py` files.
"deepmd/tf/**" = ["TID253"]
Expand Down
2 changes: 1 addition & 1 deletion source/tests/pt/test_multitask.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_multitask_train(self):
if "model_2" in state_key:
self.assertIn(state_key.replace("model_2", "model_1"), multi_state_dict)
if "model_1.descriptor" in state_key:
torch.testing.assert_allclose(
torch.testing.assert_close(
multi_state_dict[state_key],
multi_state_dict[state_key.replace("model_1", "model_2")],
)
Expand Down
2 changes: 1 addition & 1 deletion source/tests/pt/test_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_trainable(self):
trainer_fix.run()
model_dict_after_training = deepcopy(trainer_fix.model.state_dict())
for key in model_dict_before_training:
torch.testing.assert_allclose(
torch.testing.assert_close(
model_dict_before_training[key], model_dict_after_training[key]
)
self.tearDown()
Expand Down
Loading