Skip to content

Commit

Permalink
Change of license
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyes319 committed Nov 9, 2022
1 parent 05da423 commit 75d3028
Show file tree
Hide file tree
Showing 22 changed files with 49 additions and 96 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,4 @@ For bugs or feature requests, please use [GitHub Issues](https://github.com/ACEs

## License

MACE is published and distributed under the [Academic Software License v1.0 ](ASL.md).
MACE is published and distributed under the [MIT](MIT.md).
6 changes: 3 additions & 3 deletions mace/calculators/mace.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################################################
# The ASE Calculator for MACE (based on https://github.com/mir-group/nequip)
# Authors: Ilyes Batatia, David Kovacs
# This program is distributed under the ASL License (see ASL.md)
# This program is distributed under the MIT License (see MIT.md)
###########################################################################################


Expand Down Expand Up @@ -87,7 +87,7 @@ def calculate(self, atoms=None, properties=None, system_changes=all_changes):
stress = out["stress"].detach().cpu().numpy()
# stress has units eng / len^3:
self.results["stress"] = (
stress * (self.energy_units_to_eV / self.length_units_to_A**3)
stress * (self.energy_units_to_eV / self.length_units_to_A ** 3)
)[0]
self.results["stress"] = full_3x3_to_voigt_6_stress(self.results["stress"])

Expand Down Expand Up @@ -248,5 +248,5 @@ def calculate(self, atoms=None, properties=None, system_changes=all_changes):
if out["stress"] is not None:
stress = out["stress"].detach().cpu().numpy()
self.results["stress"] = (
stress * (self.energy_units_to_eV / self.length_units_to_A**3)
stress * (self.energy_units_to_eV / self.length_units_to_A ** 3)
)[0]
12 changes: 3 additions & 9 deletions mace/data/atomic_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################################################
# Atomic Data Class for handling molecules as graphs
# Authors: Ilyes Batatia, Gregor Simm
# This program is distributed under the ASL License (see ASL.md)
# This program is distributed under the MIT License (see MIT.md)
###########################################################################################

from typing import Optional, Sequence
Expand Down Expand Up @@ -210,14 +210,8 @@ def from_config(


def get_data_loader(
dataset: Sequence[AtomicData],
batch_size: int,
shuffle=True,
drop_last=False,
dataset: Sequence[AtomicData], batch_size: int, shuffle=True, drop_last=False,
) -> torch.utils.data.DataLoader:
return torch_geometric.dataloader.DataLoader(
dataset=dataset,
batch_size=batch_size,
shuffle=shuffle,
drop_last=drop_last,
dataset=dataset, batch_size=batch_size, shuffle=shuffle, drop_last=drop_last,
)
2 changes: 1 addition & 1 deletion mace/data/neighborhood.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################################################
# Neighborhood construction
# Authors: Ilyes Batatia, Gregor Simm
# This program is distributed under the ASL License (see ASL.md)
# This program is distributed under the MIT License (see MIT.md)
###########################################################################################

from typing import Optional, Tuple
Expand Down
2 changes: 1 addition & 1 deletion mace/data/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################################################
# Data parsing utilities
# Authors: Ilyes Batatia, Gregor Simm and David Kovacs
# This program is distributed under the ASL License (see ASL.md)
# This program is distributed under the MIT License (see MIT.md)
###########################################################################################

import logging
Expand Down
33 changes: 10 additions & 23 deletions mace/modules/blocks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################################################
# Elementary Block for Building O(3) Equivariant Higher Order Message Passing Neural Network
# Authors: Ilyes Batatia, Gregor Simm
# This program is distributed under the ASL License (see ASL.md)
# This program is distributed under the MIT License (see MIT.md)
###########################################################################################

from abc import ABC, abstractmethod
Expand All @@ -28,8 +28,7 @@ def __init__(self, irreps_in: o3.Irreps, irreps_out: o3.Irreps):
self.linear = o3.Linear(irreps_in=irreps_in, irreps_out=irreps_out)

def forward(
self,
node_attrs: torch.Tensor, # [n_nodes, irreps]
self, node_attrs: torch.Tensor, # [n_nodes, irreps]
):
return self.linear(node_attrs)

Expand Down Expand Up @@ -142,8 +141,7 @@ def __init__(self, r_max: float, num_bessel: int, num_polynomial_cutoff: int):
self.out_dim = num_bessel

def forward(
self,
edge_lengths: torch.Tensor, # [n_edges, 1]
self, edge_lengths: torch.Tensor, # [n_edges, 1]
):
bessel = self.bessel_fn(edge_lengths) # [n_edges, n_basis]
cutoff = self.cutoff_fn(edge_lengths) # [n_edges, 1]
Expand Down Expand Up @@ -172,10 +170,7 @@ def __init__(
)
# Update linear
self.linear = o3.Linear(
target_irreps,
target_irreps,
internal_weights=True,
shared_weights=True,
target_irreps, target_irreps, internal_weights=True, shared_weights=True,
)

def forward(
Expand Down Expand Up @@ -342,8 +337,7 @@ def _setup(self) -> None:
# Convolution weights
input_dim = self.edge_feats_irreps.num_irreps
self.conv_tp_weights = nn.FullyConnectedNet(
[input_dim] + 3 * [64] + [self.conv_tp.weight_numel],
torch.nn.SiLU(),
[input_dim] + 3 * [64] + [self.conv_tp.weight_numel], torch.nn.SiLU(),
)

# Linear
Expand Down Expand Up @@ -407,8 +401,7 @@ def _setup(self) -> None:
# Convolution weights
input_dim = self.edge_feats_irreps.num_irreps
self.conv_tp_weights = nn.FullyConnectedNet(
[input_dim] + 3 * [64] + [self.conv_tp.weight_numel],
torch.nn.SiLU(),
[input_dim] + 3 * [64] + [self.conv_tp.weight_numel], torch.nn.SiLU(),
)

# Linear
Expand Down Expand Up @@ -459,9 +452,7 @@ def _setup(self) -> None:
)
# TensorProduct
irreps_mid, instructions = tp_out_irreps_with_instructions(
self.node_feats_irreps,
self.edge_attrs_irreps,
self.target_irreps,
self.node_feats_irreps, self.edge_attrs_irreps, self.target_irreps,
)
self.conv_tp = o3.TensorProduct(
self.node_feats_irreps,
Expand All @@ -475,8 +466,7 @@ def _setup(self) -> None:
# Convolution weights
input_dim = self.edge_feats_irreps.num_irreps
self.conv_tp_weights = nn.FullyConnectedNet(
[input_dim] + 3 * [64] + [self.conv_tp.weight_numel],
torch.nn.SiLU(),
[input_dim] + 3 * [64] + [self.conv_tp.weight_numel], torch.nn.SiLU(),
)

# Linear
Expand Down Expand Up @@ -531,9 +521,7 @@ def _setup(self) -> None:
)
# TensorProduct
irreps_mid, instructions = tp_out_irreps_with_instructions(
self.node_feats_irreps,
self.edge_attrs_irreps,
self.target_irreps,
self.node_feats_irreps, self.edge_attrs_irreps, self.target_irreps,
)
self.conv_tp = o3.TensorProduct(
self.node_feats_irreps,
Expand All @@ -547,8 +535,7 @@ def _setup(self) -> None:
# Convolution weights
input_dim = self.edge_feats_irreps.num_irreps
self.conv_tp_weights = nn.FullyConnectedNet(
[input_dim] + 3 * [64] + [self.conv_tp.weight_numel],
torch.nn.SiLU(),
[input_dim] + 3 * [64] + [self.conv_tp.weight_numel], torch.nn.SiLU(),
)

# Linear
Expand Down
2 changes: 1 addition & 1 deletion mace/modules/irreps_tools.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################################################
# Elementary tools for handling irreducible representations
# Authors: Ilyes Batatia, Gregor Simm
# This program is distributed under the ASL License (see ASL.md)
# This program is distributed under the MIT License (see MIT.md)
###########################################################################################

from typing import List, Tuple
Expand Down
2 changes: 1 addition & 1 deletion mace/modules/loss.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################################################
# Implementation of different loss functions
# Authors: Ilyes Batatia, Gregor Simm
# This program is distributed under the ASL License (see ASL.md)
# This program is distributed under the MIT License (see MIT.md)
###########################################################################################

import torch
Expand Down
12 changes: 3 additions & 9 deletions mace/modules/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################################################
# Implementation of MACE models and other models based E(3)-Equivariant MPNNs
# Authors: Ilyes Batatia, Gregor Simm
# This program is distributed under the ASL License (see ASL.md)
# This program is distributed under the MIT License (see MIT.md)
###########################################################################################

from typing import Any, Callable, Dict, List, Optional, Type
Expand Down Expand Up @@ -224,10 +224,7 @@ def forward(

class ScaleShiftMACE(MACE):
def __init__(
self,
atomic_inter_scale: float,
atomic_inter_shift: float,
**kwargs,
self, atomic_inter_scale: float, atomic_inter_shift: float, **kwargs,
):
super().__init__(**kwargs)
self.scale_shift = ScaleShiftBlock(
Expand Down Expand Up @@ -445,10 +442,7 @@ def forward(self, data: AtomicData, training=False) -> Dict[str, Any]:

class ScaleShiftBOTNet(BOTNet):
def __init__(
self,
atomic_inter_scale: float,
atomic_inter_shift: float,
**kwargs,
self, atomic_inter_scale: float, atomic_inter_shift: float, **kwargs,
):
super().__init__(**kwargs)
self.scale_shift = ScaleShiftBlock(
Expand Down
7 changes: 2 additions & 5 deletions mace/modules/radial.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################################################
# Radial basis and cutoff
# Authors: Ilyes Batatia, Gregor Simm
# This program is distributed under the ASL License (see ASL.md)
# This program is distributed under the MIT License (see MIT.md)
###########################################################################################

import numpy as np
Expand Down Expand Up @@ -40,10 +40,7 @@ def __init__(self, r_max: float, num_basis=8, trainable=False):
torch.tensor(np.sqrt(2.0 / r_max), dtype=torch.get_default_dtype()),
)

def forward(
self,
x: torch.Tensor,
) -> torch.Tensor: # [..., 1]
def forward(self, x: torch.Tensor,) -> torch.Tensor: # [..., 1]
numerator = torch.sin(self.bessel_weights * x) # [..., num_basis]
return self.prefactor * (numerator / x)

Expand Down
2 changes: 1 addition & 1 deletion mace/modules/symmetric_contraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Implementation of the symmetric contraction algorithm presented in the MACE paper
# (Batatia et al, MACE: Higher Order Equivariant Message Passing Neural Networks for Fast and Accurate Force Fields , Eq.10 and 11)
# Authors: Ilyes Batatia
# This program is distributed under the ASL License (see ASL.md)
# This program is distributed under the MIT License (see MIT.md)
###########################################################################################

from typing import Dict, Optional, Union
Expand Down
23 changes: 6 additions & 17 deletions mace/modules/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################################################
# Utilities
# Authors: Ilyes Batatia, Gregor Simm and David Kovacs
# This program is distributed under the ASL License (see ASL.md)
# This program is distributed under the MIT License (see MIT.md)
###########################################################################################

import logging
Expand Down Expand Up @@ -60,9 +60,7 @@ def compute_forces_virials(
if compute_stress and virials is not None:
cell = cell.view(-1, 3, 3)
volume = torch.einsum(
"zi,zi->z",
cell[:, 0, :],
torch.cross(cell[:, 1, :], cell[:, 2, :], dim=1),
"zi,zi->z", cell[:, 0, :], torch.cross(cell[:, 1, :], cell[:, 2, :], dim=1),
).unsqueeze(-1)
stress = virials / volume.view(-1, 1, 1)
if forces is None:
Expand All @@ -86,10 +84,7 @@ def get_symmetric_displacement(
if cell is None:
logging.info("Virial required but no cell provided")
cell = torch.zeros(
num_graphs * 3,
3,
dtype=positions.dtype,
device=positions.device,
num_graphs * 3, 3, dtype=positions.dtype, device=positions.device,
)
sender = edge_index[0]
displacement = torch.zeros(
Expand All @@ -106,11 +101,7 @@ def get_symmetric_displacement(
)
cell = cell.view(-1, 3, 3)
cell = cell + torch.matmul(cell, symmetric_displacement)
shifts = torch.einsum(
"be,bec->bc",
unit_shifts,
cell[batch[sender]],
)
shifts = torch.einsum("be,bec->bc", unit_shifts, cell[batch[sender]],)
return positions, shifts, displacement


Expand Down Expand Up @@ -166,8 +157,7 @@ def get_edge_vectors_and_lengths(


def compute_mean_std_atomic_inter_energy(
data_loader: torch.utils.data.DataLoader,
atomic_energies: np.ndarray,
data_loader: torch.utils.data.DataLoader, atomic_energies: np.ndarray,
) -> Tuple[float, float]:
atomic_energies_fn = AtomicEnergiesBlock(atomic_energies=atomic_energies)

Expand All @@ -191,8 +181,7 @@ def compute_mean_std_atomic_inter_energy(


def compute_mean_rms_energy_forces(
data_loader: torch.utils.data.DataLoader,
atomic_energies: np.ndarray,
data_loader: torch.utils.data.DataLoader, atomic_energies: np.ndarray,
) -> Tuple[float, float]:
atomic_energies_fn = AtomicEnergiesBlock(atomic_energies=atomic_energies)

Expand Down
6 changes: 2 additions & 4 deletions mace/tools/arg_parser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################################################
# Parsing functionalities
# Authors: Ilyes Batatia, Gregor Simm, David Kovacs
# This program is distributed under the ASL License (see ASL.md)
# This program is distributed under the MIT License (see MIT.md)
###########################################################################################

import argparse
Expand Down Expand Up @@ -197,9 +197,7 @@ def build_default_arg_parser() -> argparse.ArgumentParser:
required=False,
)
parser.add_argument(
"--test_file",
help="Test set xyz file",
type=str,
"--test_file", help="Test set xyz file", type=str,
)
parser.add_argument(
"--E0s",
Expand Down
6 changes: 3 additions & 3 deletions mace/tools/cg.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################################################
# Higher Order Real Clebsch Gordan (based on e3nn by Mario Geiger)
# Authors: Ilyes Batatia
# This program is distributed under the ASL License (see ASL.md)
# This program is distributed under the MIT License (see MIT.md)
###########################################################################################

import collections
Expand Down Expand Up @@ -54,9 +54,9 @@ def _wigner_nj(

C = o3.wigner_3j(ir_out.l, ir_left.l, ir.l, dtype=dtype)
if normalization == "component":
C *= ir_out.dim**0.5
C *= ir_out.dim ** 0.5
if normalization == "norm":
C *= ir_left.dim**0.5 * ir.dim**0.5
C *= ir_left.dim ** 0.5 * ir.dim ** 0.5

C = torch.einsum("jk,ijl->ikl", C_left.flatten(1), C)
C = C.reshape(
Expand Down
6 changes: 2 additions & 4 deletions mace/tools/checkpoint.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################################################
# Checkpointing
# Authors: Gregor Simm
# This program is distributed under the ASL License (see ASL.md)
# This program is distributed under the MIT License (see MIT.md)
###########################################################################################

import dataclasses
Expand Down Expand Up @@ -86,9 +86,7 @@ def _parse_checkpoint_path(self, path: str) -> Optional[CheckpointPathInfo]:
return None

return CheckpointPathInfo(
path=path,
tag=match.group("tag"),
epochs=int(match.group("epochs")),
path=path, tag=match.group("tag"), epochs=int(match.group("epochs")),
)

def _get_latest_checkpoint_path(self) -> Optional[str]:
Expand Down
2 changes: 1 addition & 1 deletion mace/tools/scripts_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################################################
# Training utils
# Authors: David Kovacs, Ilyes Batatia
# This program is distributed under the ASL License (see ASL.md)
# This program is distributed under the MIT License (see MIT.md)
###########################################################################################

import dataclasses
Expand Down
Loading

0 comments on commit 75d3028

Please sign in to comment.