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

Improve additive models #427

Open
wants to merge 169 commits into
base: main
Choose a base branch
from
Open

Improve additive models #427

wants to merge 169 commits into from

Conversation

frostedoyster
Copy link
Collaborator

@frostedoyster frostedoyster commented Dec 14, 2024

Improves the additive models and closes #355. In particular:

  • Fixes some device issues for ZBL
  • Makes sure that all architectures fit compositions after ZBL is removed
  • Makes sure everything works with distributed training
  • Fixes the interaction between additive models and LLPR ensembles

Contributor (creator of pull-request) checklist

  • Tests updated (for new features and bugfixes)?
  • Documentation updated (for new features)?
  • Issue referenced (for PRs that solve an issue)?

📚 Documentation preview 📚: https://metatrain--427.org.readthedocs.build/en/427/

@frostedoyster frostedoyster marked this pull request as ready for review December 15, 2024 07:30
Base automatically changed from scaler to main December 16, 2024 14:16
@@ -122,7 +122,7 @@ def test_regression_train():
)

# if you need to change the hardcoded values:
torch.set_printoptions(precision=12)
print(output["mtt::U0"].block().values)
# torch.set_printoptions(precision=12)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a leftover I suppose?

fixed_weights: Optional[Dict[str, Dict[int, str]]] = None,
) -> None:
"""Train/fit the composition weights for the datasets.

:param datasets: Dataset(s) to calculate the composition weights for.
:param fixed_weights: Optional fixed weights to use for the composition model,
for one or more target quantities.
:param additive_models: Additive models to be removed from the targets
Copy link
Contributor

@abmazitov abmazitov Dec 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this removal should happen implicitly in the composition model class? Maybe it is better to have a separate utility function that removes additives?

systems, targets = systems_and_targets_to_device(
systems, targets, device
)
for additive_model in additive_models:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, I would move this for-loop out of the composition model class, it feels like this functionality goes out of the scope of the CompositionModel

f"Composition model does not support target quantity "
f"{target_info.quantity}. This is an architecture bug. "
f"Composition model does not support target "
f"{target_name}. This is an architecture bug. "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the lack of support of the target is an architecture bug? If would not call it a bug, in fact, but maybe it’s just a copy-paste glitch

"ZBL only supports eV units, but a "
f"{target.unit} output was provided."
f"ZBL model does not support target "
f"{target_name}. This is an architecture bug. "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question here

if not self.is_valid_target(target_name, target_info):
raise ValueError(
f"ZBL model does not support target "
f"{target_name}. This is an architecture bug. "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

@@ -261,6 +268,38 @@ def requested_neighbor_lists(self) -> List[NeighborListOptions]:
)
]

@staticmethod
def is_valid_target(target_name: str, target_info: TargetInfo) -> bool:
"""Finds if a ``TargetInfo`` object is compatible with a composition model.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compatible with ZBL model I guess?

@abmazitov
Copy link
Contributor

The rest of the code looks good to me, my main concern is the CompositionModel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ZBL follow-up
2 participants