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

pq #304

Closed
wants to merge 3 commits into from
Closed

pq #304

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 torchmdnet/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ def forward(
assert z.dim() == 1 and z.dtype == torch.long
batch = torch.zeros_like(z) if batch is None else batch

# trick to incorporate SPICE pqs
# set charge: true in yaml ((?) currently I do it)
q = extra_args["pq"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would move instead to something like removing "q" and "s" from the forward call of the representation models and instead send everything as extra_args, or atomic_labels:

        atomic_labels = {}
        if q is not None:
             atomic_labels["total_charges"] = q
        if s is not None:
             atomic_labels["spin"] = s 
        # run the potentially wrapped representation model
        x, v, z, pos, batch = self.representation_model(
            z, pos, batch, box=box, atomic_labels=atomic_labels, extra_args=extra_args
        )

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it seems nice


if self.derivative:
pos.requires_grad_(True)
# run the potentially wrapped representation model
Expand Down
3 changes: 2 additions & 1 deletion torchmdnet/models/tensornet.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ def forward(
# Total charge q is a molecule-wise property. We transform it into an atom-wise property, with all atoms belonging to the same molecule being assigned the same charge q
if q is None:
q = torch.zeros_like(z, device=z.device, dtype=z.dtype)
else:
# if not atom-wise, make atom-wise (pq is already atom-wise)
if z.shape != q.shape:
q = q[batch]
zp = z
if self.static_shapes:
Expand Down
Loading