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

change logic to catch missing outputs #859

Merged
merged 6 commits into from
Sep 19, 2024
Merged
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
10 changes: 6 additions & 4 deletions src/fairchem/core/trainers/ocp_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,8 @@ def _forward(self, batch):
), f"we need to know which property to match the target to, please specify the property field in the task config, current config: {self.output_targets[target_key]}"
prop = self.output_targets[target_key]["property"]
pred = out[target_key][prop]

## TODO: deprecate the following logic?
## Otherwise, assume target property is a derived output of the model. Construct the parent property
else:
# TODO clean up this logic to reconstruct a tensor from its predicted decomposition
elif "decomposition" in self.output_targets[target_key]:
_max_rank = 0
for subtarget_key in self.output_targets[target_key]["decomposition"]:
_max_rank = max(
Expand Down Expand Up @@ -291,6 +289,10 @@ def _forward(self, batch):
cg_change_mat(_max_rank, self.device),
pred_irreps,
)
else:
raise AttributeError(
f"Output target: '{target_key}', not found in model outputs: {list(out.keys())}"
)

### not all models are consistent with the output shape
### reshape accordingly: num_atoms_in_batch, -1 or num_systems_in_batch, -1
Expand Down