Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
212 commits
Select commit Hold shift + click to select a range
86b3d4c
add matbench dataset
Lingyu-Kong Nov 5, 2024
bbcb05c
Bugfix: Add hparams_cls method to JMPBackboneModule
nimashoghi Nov 5, 2024
1b2cebf
Bugfix: Lazy-load MatbenchBenchmark. Prevents errors if matbench not …
nimashoghi Nov 5, 2024
d2b96ad
Feature: Add property_type method to property configs
nimashoghi Nov 5, 2024
4852245
Feature: Add ORB backbone with support for all output heads
nimashoghi Nov 5, 2024
d2b2948
Update config exports
nimashoghi Nov 5, 2024
3223d56
Export configs from root __init__ file. Other configs import fixes
nimashoghi Nov 5, 2024
fb56106
Added db and json dataset
Lingyu-Kong Nov 6, 2024
908b079
Added db and json dataset
Lingyu-Kong Nov 6, 2024
ef0f58b
Add note about ORB fork
nimashoghi Nov 6, 2024
7eaa29f
Refactor: Move JMP activation function logic to separate utility
nimashoghi Nov 6, 2024
bf086ef
Refactor: Improve fixed atom constraint handling
nimashoghi Nov 6, 2024
de22eda
Refactor: Assert conservative forces/stresses unsupported in JMP
nimashoghi Nov 6, 2024
0e820bc
Feature: Add reduction option for graph property output
nimashoghi Nov 6, 2024
646777f
Feature: Add GraphScalarOutputHead for graph-level predictions
nimashoghi Nov 6, 2024
61a94b7
Refactor: Enhance MatterTunePotential predict method
nimashoghi Nov 6, 2024
397a0e8
Docs: Enhance method documentation for prediction functions
nimashoghi Nov 6, 2024
9b31eec
Docs: Add docstring to MatterTunePotential class
nimashoghi Nov 6, 2024
0b49c35
Refactor: Move stress tensor conversion to util module
nimashoghi Nov 6, 2024
c628ab7
Feature: Add eqV2 backbone support to MatterTune
nimashoghi Nov 6, 2024
e54098c
Update config exports (codegen)
nimashoghi Nov 6, 2024
d3c98d4
Merge pull request #2 from nimashoghi/nshv2-eqv2
nimashoghi Nov 6, 2024
10ec205
Feature: Update dependency installation instructions
nimashoghi Nov 6, 2024
3c927ea
Bugfix: Fix stress tensor calculation for eqv2
nimashoghi Nov 7, 2024
da7827e
add mp and mptraj data
Lingyu-Kong Nov 7, 2024
cbb46c6
Merge branch 'nshv2' of github.com:nimashoghi/MatterTune into nshv2
Lingyu-Kong Nov 7, 2024
00c6d49
merge with eqv2 added and move nshtrainer and torch_sparse to inline …
Lingyu-Kong Nov 7, 2024
9f336a3
db, matbench, mp, mptraj, xyz passed test
Lingyu-Kong Nov 7, 2024
b56be6d
Add missing `collections.abcMapping` import for finetune/base.py
nimashoghi Nov 7, 2024
51b4a99
Refactor: Fix hparams_cls return type annotation
nimashoghi Nov 7, 2024
abf3854
db, matbench, mp, mptraj, xyz passed testing
Lingyu-Kong Nov 7, 2024
5eeb3eb
Merge branch 'nshv2' of github.com:nimashoghi/MatterTune into nshv2
Lingyu-Kong Nov 7, 2024
2a6fadb
db, matbench, mp, mptraj, xyz passed testing
Lingyu-Kong Nov 7, 2024
f3acd88
Refactor: Simplify dataset creation and configuration
nimashoghi Nov 7, 2024
80d9115
Refactor: Remove DatasetBase class and simplify dataset hierarchy
nimashoghi Nov 7, 2024
5700c01
Refactor: Implement MatterTuneDataModule to handle the dataset setup …
nimashoghi Nov 7, 2024
b4fd1ec
Bugfix: Remove sequence requirement for dataset
nimashoghi Nov 7, 2024
5e17ed3
AutoSplitDataModuleConfig: Set validation split value to be "auto" by…
nimashoghi Nov 7, 2024
511b534
Merge pull request #3 from nimashoghi/nshv2-data-revamp
lingyukong677 Nov 7, 2024
b03ac69
Change datasets to fit in new data revamp
Lingyu-Kong Nov 7, 2024
326ba7a
Removed performing spliting in matbench
Lingyu-Kong Nov 7, 2024
755337b
reshape stress to (3,3) before converting to (6,) in calculator
Lingyu-Kong Nov 8, 2024
f2b3b91
reshape stress to (3,3) before converting to (6,) in calculator
Lingyu-Kong Nov 8, 2024
92319fb
move ipynb to notebooks dir
Lingyu-Kong Nov 11, 2024
bba95ba
fix stress shape bugs in mptraj dataset
Lingyu-Kong Nov 11, 2024
6ba21b6
add water-thermodynamics example with jmp and m3gnet
Lingyu-Kong Nov 11, 2024
2e66567
add structure optimization
Lingyu-Kong Nov 11, 2024
294114b
add matbench examples
Lingyu-Kong Nov 11, 2024
4cc0908
Add conservative force and stress for JMP
Lingyu-Kong Nov 11, 2024
257c328
Fix zero_loss error in _common_step
Lingyu-Kong Nov 12, 2024
c8cd4f6
add skipbatch zero_output in _common_step
Lingyu-Kong Nov 12, 2024
16f8036
updated toml file and TODO
Lingyu-Kong Nov 12, 2024
9d529d2
set default minimun structure size to 5 for mptraj
Lingyu-Kong Nov 12, 2024
3e8a49b
added skipbatch for jmp when finding nan and inf output
Lingyu-Kong Nov 12, 2024
47a65e5
Generally updated application examples
Lingyu-Kong Nov 12, 2024
f085c61
Adds normalization configuration and utility classes
nimashoghi Nov 13, 2024
46a5f67
Implements reference energy computation system
nimashoghi Nov 13, 2024
e71cf15
Refactor: Enhance reference model with configurable options
nimashoghi Nov 13, 2024
c3dda09
Made unit conversion to water dataset
Lingyu-Kong Nov 14, 2024
37aa2ca
Updated TODO on Nov 13
Lingyu-Kong Nov 14, 2024
1a51178
Added draft for README
Lingyu-Kong Nov 14, 2024
8366322
Updated README
Lingyu-Kong Nov 14, 2024
50d865f
refactor: extract per-atom ref calculation to CLI
nimashoghi Nov 14, 2024
8413756
Adds property normalization support to finetuning
nimashoghi Nov 14, 2024
c58cb3a
Refactor: Rename "*Reference" to "*PropertyReferencer"
nimashoghi Nov 14, 2024
8dd7ad5
Refactor: Enhance normalization with context-aware modules
nimashoghi Nov 14, 2024
35bae49
Refactor: Remove no-longer-used referencing module & move normalizati…
nimashoghi Nov 14, 2024
c293e00
feat: add CLI interface to compute per-atom references
nimashoghi Nov 14, 2024
d574882
Adds composition-based normalization context to backbones
nimashoghi Nov 14, 2024
5b8d48e
Made unit conversion to water dataset
Lingyu-Kong Nov 14, 2024
72a9f49
Updated TODO on Nov 13
Lingyu-Kong Nov 14, 2024
4cc084b
Added draft for README
Lingyu-Kong Nov 14, 2024
3b2ec0d
Updated README
Lingyu-Kong Nov 14, 2024
25ce5dc
Re-generate the config exports
nimashoghi Nov 14, 2024
71c8caf
Adds checkpoint saving to finetune examples
nimashoghi Nov 14, 2024
2406461
Refactor: Migrate to unified trainer configuration
nimashoghi Nov 14, 2024
f48d5b4
Added new README, adavnced
nimashoghi Nov 14, 2024
f41f82e
Refactor: Move trainer kwargs to config and rename potential
nimashoghi Nov 15, 2024
e1d2443
Adds normalization configuration and utility classes
nimashoghi Nov 13, 2024
e052214
Implements reference energy computation system
nimashoghi Nov 13, 2024
ff01bb2
Refactor: Enhance reference model with configurable options
nimashoghi Nov 13, 2024
e670b7a
refactor: extract per-atom ref calculation to CLI
nimashoghi Nov 14, 2024
377f759
Adds property normalization support to finetuning
nimashoghi Nov 14, 2024
582171d
Refactor: Rename "*Reference" to "*PropertyReferencer"
nimashoghi Nov 14, 2024
d7da657
Refactor: Enhance normalization with context-aware modules
nimashoghi Nov 14, 2024
8068bd7
Refactor: Remove no-longer-used referencing module & move normalizati…
nimashoghi Nov 14, 2024
04a06da
feat: add CLI interface to compute per-atom references
nimashoghi Nov 14, 2024
4d0d64b
Adds composition-based normalization context to backbones
nimashoghi Nov 14, 2024
59c5cdf
Added draft for README
Lingyu-Kong Nov 14, 2024
3c0ca94
Updated README
Lingyu-Kong Nov 14, 2024
893b83c
Re-generate the config exports
nimashoghi Nov 14, 2024
4b534f2
Adds checkpoint saving to finetune examples
nimashoghi Nov 14, 2024
50ceacc
Refactor: Migrate to unified trainer configuration
nimashoghi Nov 14, 2024
9ae1f54
Added new README, adavnced
nimashoghi Nov 14, 2024
24c6bf6
Refactor: Move trainer kwargs to config and rename potential
nimashoghi Nov 15, 2024
59dec05
Merge pull request #4 from nimashoghi/nshv2-linref-normalization
nimashoghi Nov 18, 2024
9a5633e
Merge pull request #5 from nimashoghi/nshv2
nimashoghi Nov 18, 2024
af65bdf
Refactor: Move module creation to config classes
nimashoghi Nov 18, 2024
f7ccd01
Adds config file format support for TOML, JSON and dict
nimashoghi Nov 18, 2024
17765dd
Update config exports
nimashoghi Nov 18, 2024
2030b54
Upgrade to latest nshconfig; export typed dicts and json schemas for …
nimashoghi Nov 18, 2024
23eb012
Remove unused imports in examples
nimashoghi Nov 18, 2024
63783a3
Bugfix: Removes abstract model_cls method from FinetuneModuleBaseConfig
nimashoghi Nov 18, 2024
8371572
feat: export nshconfig metadata.
nimashoghi Nov 18, 2024
8fd2c2a
docs: update license information and indent ToC
nimashoghi Nov 18, 2024
e996254
Add development tooling and contributing guidelines
nimashoghi Nov 18, 2024
f833b74
Code cleanup (formatting etc)
nimashoghi Nov 18, 2024
b098c2f
Rename `potential.py` -> `property_predictor.py`
nimashoghi Nov 18, 2024
308c9a1
Fix a bug in trainer.logger. Previously logger not used
Lingyu-Kong Nov 19, 2024
760aeeb
Move some imports to under TYPE_CHECKING
Lingyu-Kong Nov 19, 2024
7190633
Add reshape attempts before metric forward
Lingyu-Kong Nov 19, 2024
93cc109
Add reshape attempts before loss forward
Lingyu-Kong Nov 19, 2024
ce99d54
Fix a bug in normalizer, remove the usage of .get since ModuleDict do…
Lingyu-Kong Nov 19, 2024
05744fa
Add normalizer support for m3gnet
Lingyu-Kong Nov 19, 2024
17689dc
Updated Installation instructions and package dependencies, jmp/m3gne…
Lingyu-Kong Nov 19, 2024
a426d65
Updated application scripts
Lingyu-Kong Nov 19, 2024
47918ca
Modified normalize implementation of jmp/eqv2/matgl
Lingyu-Kong Nov 19, 2024
f73078b
Add normalization to water example
Lingyu-Kong Nov 19, 2024
65c83c1
merge readme_and_finalize
Lingyu-Kong Nov 19, 2024
b1fc112
Testes and passed eqv2 installation
Lingyu-Kong Nov 19, 2024
a6af65f
Fix a mistake in matbench installation
Lingyu-Kong Nov 19, 2024
b2b6980
Updated __init__ configs
Lingyu-Kong Nov 19, 2024
1307320
Updated quick start example in README to fit in new codebase
Lingyu-Kong Nov 19, 2024
e7b9ae4
Set save_ckpt every 10 epochs in examples
Lingyu-Kong Nov 19, 2024
5952b2d
Updated configs by copying from main branch
Lingyu-Kong Nov 19, 2024
e17aff1
Merge branch 'nshv2-readme-and-finalize'
Lingyu-Kong Nov 19, 2024
dc9f6fb
Docs: Renames "Potential" to "MatterTunePropertyPredictor" in README
nimashoghi Nov 20, 2024
9d136df
refactor: Remove typed dictionary configs
nimashoghi Nov 22, 2024
8fa6f72
Adds barebones mode to lightning trainer config for the property pred…
nimashoghi Nov 22, 2024
326b83d
Started work on more extensive documentation.
nimashoghi Nov 22, 2024
6e47fa8
Cleaned up JMP-OMAT notebook
nimashoghi Nov 22, 2024
25e4084
Add default trainer config, if not set by the user in the config.
nimashoghi Nov 22, 2024
e2b170f
Remove typed dicts from the generated config JSON metadata
nimashoghi Nov 22, 2024
3fb33f8
Add argument batch_size to property_predictor's predict func
Lingyu-Kong Nov 25, 2024
371509d
Mod predict func
Lingyu-Kong Nov 25, 2024
fcc73e6
Add reshape to predict for batch prediction
Lingyu-Kong Nov 25, 2024
7671387
Update README and toml
Lingyu-Kong Nov 25, 2024
c0a1331
Update water-thermodynamics results
Lingyu-Kong Nov 25, 2024
a52be59
Delete some unused scripts
Lingyu-Kong Nov 25, 2024
9b00884
Update property screening results
Lingyu-Kong Nov 25, 2024
ceadc6f
Update struct-opt
Lingyu-Kong Nov 25, 2024
7750976
Merge branch 'main' of github.com:nimashoghi/MatterTune
Lingyu-Kong Nov 25, 2024
3fc3628
Add get_gnome_data.py
Lingyu-Kong Nov 25, 2024
287800d
Add get_gnome_data.py
Lingyu-Kong Nov 25, 2024
8ea21fa
Add get_gnome_data.py
Lingyu-Kong Nov 25, 2024
6cbc2d5
Add get_gnome_data.py
Lingyu-Kong Nov 25, 2024
9bf8a13
Add get_gnome_data.py
Lingyu-Kong Nov 25, 2024
ee975a8
Update gitignore
Lingyu-Kong Nov 25, 2024
c419ec5
Update water results
Lingyu-Kong Nov 25, 2024
7fd798a
Add M3GNet backbone docs
nimashoghi Nov 24, 2024
797e096
Detailed motivation doc
nimashoghi Nov 25, 2024
b34a210
Add comprehensive documentation for Lightning integration in MatterTune
nimashoghi Nov 27, 2024
fcbca08
Fix referencing and batch prediction
Lingyu-Kong Nov 27, 2024
c6ef3da
Update for property screening and md
Lingyu-Kong Nov 27, 2024
ae98bf2
Merge branch 'main' of github.com:nimashoghi/MatterTune
Lingyu-Kong Nov 27, 2024
44172eb
Docs: Add comprehensive project documentation site
nimashoghi Nov 27, 2024
be232c0
Fix README documentation link to point to the correct GitHub Pages UR…
nimashoghi Nov 27, 2024
7007676
Update documentation workflow to install package in editable mode wit…
nimashoghi Nov 27, 2024
e0334f2
Adds copy button to documentation code blocks
nimashoghi Nov 27, 2024
ea81577
Update copyright year in documentation configuration file
nimashoghi Nov 27, 2024
1b9ec4a
Fix README documentation link to point to the correct GitHub Pages UR…
nimashoghi Nov 27, 2024
d376d72
Docs: Added API reference docs
nimashoghi Nov 27, 2024
223e7b7
chore: Add __all__ = ... to all generated files
nimashoghi Nov 27, 2024
14d2207
Refactor type alias definitions to use TypeAliasType.
nimashoghi Nov 27, 2024
7c46f6e
Refactor documentation structure and add API reference
nimashoghi Nov 27, 2024
1942d09
Bugfix: Deps without version constraints syntax fix
nimashoghi Nov 27, 2024
c7bb94b
Update requirements.txt to include additional dependencies for docume…
nimashoghi Nov 27, 2024
8479fa3
Updates docs workflow and dependencies
nimashoghi Nov 27, 2024
b219387
Separates PyTorch dependencies into dedicated requirements
nimashoghi Nov 27, 2024
73ba1c3
Chore: Removed jaxtyping, nshutils, and pymatgen hard dependencies.
nimashoghi Nov 27, 2024
96bd369
Finally fixed API docs.
nimashoghi Nov 28, 2024
3123a59
Downgrade deploy pages version
nimashoghi Nov 28, 2024
637d242
Remove unused `mattertune.backbones.jmp.prediction_heads` module
nimashoghi Nov 28, 2024
4849c53
Update water and matbench results
Lingyu-Kong Nov 29, 2024
eca4ade
Merge branch 'main' of github.com:nimashoghi/MatterTune
Lingyu-Kong Nov 29, 2024
7dc025a
Make output contiguous to prevent bug caused by .view() in fairchem
qzheng75 Nov 29, 2024
23821f1
Update base.py predict_step to align with main branch
qzheng75 Nov 29, 2024
b2d4f05
Load dataset as an ase.Atoms list from a JSON file
qzheng75 Nov 29, 2024
5d466d4
Merge pull request #7 from Fung-Lab/eqv2-bugfix
nimashoghi Nov 29, 2024
d9856f5
Reformat base.py with ruff
nimashoghi Dec 1, 2024
f9d7050
Enhance documentation for EquiformerV2 and JMP backbones, including i…
nimashoghi Dec 1, 2024
82d1df9
Add type assertions to atoms objects across codebase
nimashoghi Dec 1, 2024
d179c34
Merge branch 'main' of github.com:Fung-Lab/MatterTune into json_dataset
qzheng75 Dec 1, 2024
45b89fd
Add comprehensive guide for supported datasets in MatterTune
nimashoghi Dec 1, 2024
ddd0dc7
Exported more dataset configs from data module. Re-ran config export …
nimashoghi Dec 1, 2024
fa0e92a
Replaced old, large README with new, concise README linking to docume…
nimashoghi Dec 1, 2024
07f7efd
Add link to datasets guide in documentation index
nimashoghi Dec 1, 2024
e13fc7c
Pass ruff tests
qzheng75 Dec 1, 2024
5e0e7ce
Docs: Add model usage example and update license info
nimashoghi Dec 1, 2024
41708db
Update README.md
vxfung Dec 1, 2024
21b445a
Align with main branch
qzheng75 Dec 1, 2024
d731c2e
Export JSONDataset from dat module
nimashoghi Dec 1, 2024
e67a72e
Re-run config gen
nimashoghi Dec 1, 2024
562a0c6
Docs: Add docs for JSON dataset
nimashoghi Dec 1, 2024
8c7446a
Merge pull request #8 from Fung-Lab/json_dataset
nimashoghi Dec 1, 2024
ef1cfef
Docs: Fix API reference links for the dataset config classes
nimashoghi Dec 1, 2024
d382998
Fix docstring formatting (removed unncessary/incorrect tabs for parag…
nimashoghi Dec 1, 2024
9011817
Docs: Added documentation for property normalization features.
nimashoghi Dec 1, 2024
37a40dc
Chore: Updated nshconfig version. This update ensures deterministic e…
nimashoghi Dec 1, 2024
613d3a0
Update docs by adding examples and notebooks link
Lingyu-Kong Dec 1, 2024
58dd1c3
Refactor: Clean up unused imports across codebase
nimashoghi Dec 2, 2024
067a933
Update pyproject to be in PEP 621 format.
nimashoghi Dec 2, 2024
76d7be9
Update pre-commit hooks and ruff configuration
nimashoghi Dec 2, 2024
0a574cc
Add MatterSim-M3GNet
Lingyu-Kong Dec 15, 2024
62e16b6
Merge branch 'main' of github.com:nimashoghi/MatterTune
Lingyu-Kong Dec 15, 2024
cf4d565
Add MatterSim document and examples
Lingyu-Kong Dec 16, 2024
c923adc
Refactor: Clean up imports and type hints
nimashoghi Dec 18, 2024
9d24ce6
Chore: Re-run codegen script with latest nshconfig version.
nimashoghi Dec 18, 2024
dbc6f22
Feature: Added matbench discovery evaluation script
nimashoghi Dec 18, 2024
7475efa
Fixed a few typos and made some clarifications in installation.md
jaeheonshim Dec 19, 2024
36ac732
Added optimizer and graph_computer to README example
jaeheonshim Dec 19, 2024
55c4414
MatterTune -> MatterTuner
jaeheonshim Dec 19, 2024
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.nshconfig.generated.json linguist-generated=true
67 changes: 67 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Deploy Documentation

on:
push:
branches:
- main # or your default branch
paths:
- "docs/**"
- ".github/workflows/docs.yml"

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r docs/requirements-torch.txt
pip install -r docs/requirements.txt
pip install --no-deps -e .

- name: Build documentation
run: |
cd docs
# Create _static directory
mkdir -p _static
# Create _autosummary directory
mkdir -p _autosummary
make html
# Create .nojekyll file to allow files and folders starting with an underscore
touch _build/html/.nojekyll

- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: docs/_build/html

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main' # only deploy from main branch
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,14 @@ pyrightconfig.json
lightning_logs/
nshtrainer/
wandb/
abandoned/
abandoned/
.ruff_cache/
examples/hidden/
checkpoints*/
md_results/
results_backup/
ZnMn2O4_*/
examples/matbench/data/
bfg.jar
.dir2textignore
docs/_autosummary/
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.1
hooks:
- id: ruff
args: [--fix, --extend-select, I] # Fix import sorting
- id: ruff-format # Format code
- id: ruff
name: ruff-check
args: [--no-fix] # Just check for issues
192 changes: 192 additions & 0 deletions ADVANCED_USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# MatterTune Advanced Usage Guide

This guide covers advanced topics for extending MatterTune with custom components. You'll learn how to create custom backbones (model architectures) and datasets.

## Table of Contents
- [MatterTune Advanced Usage Guide](#mattertune-advanced-usage-guide)
- [Table of Contents](#table-of-contents)
- [Implementing Custom Backbones](#implementing-custom-backbones)
- [Basic Structure](#basic-structure)
- [Implementing Custom Datasets](#implementing-custom-datasets)
- [Dataset Structure](#dataset-structure)
- [Usage](#usage)
- [Best Practices](#best-practices)

## Implementing Custom Backbones

### Basic Structure
To implement a custom backbone, you need to create two classes:
1. A configuration class inheriting from `FinetuneModuleBaseConfig`
2. A model class inheriting from `FinetuneModuleBase`

Here's the basic template:

```python
from typing import Literal
from typing_extensions import override
import mattertune as mt

@mt.backbone_registry.register
class MyBackboneConfig(mt.FinetuneModuleBaseConfig):
name: Literal["my_backbone"] = "my_backbone"

# Add your configuration parameters
hidden_size: int
num_layers: int

@override
def create_model(self):
return MyBackboneModule(self)

@override
@classmethod
def ensure_dependencies(cls):
# Check for required packages
pass

class MyBackboneModule(mt.FinetuneModuleBase["MyData", "MyBatch", MyBackboneConfig]):
@override
@classmethod
def hparams_cls(cls):
return MyBackboneConfig

# Your backbone module must implement these abstract methods:
@override
def create_model(self):
"""Initialize your model architecture here"""
pass

@override
def model_forward(self, batch, return_backbone_output=False):
"""Forward pass implementation"""
pass

@override
def pretrained_backbone_parameters(self):
"""Return backbone parameters"""
pass

@override
def output_head_parameters(self):
"""Return output head parameters"""
pass

@override
def cpu_data_transform(self, data):
"""Transform data on CPU before batching"""
pass

@override
def collate_fn(self, data_list):
"""Combine data samples into a batch"""
pass

@override
def gpu_batch_transform(self, batch):
"""Transform batch on GPU before forward pass"""
pass

@override
def batch_to_labels(self, batch):
"""Extract ground truth labels from batch"""
pass

@override
def atoms_to_data(self, atoms, has_labels):
"""Convert ASE Atoms to your data format"""
pass

@override
def create_normalization_context_from_batch(self, batch):
"""Create context for property normalization"""
pass
```

For detailed examples of backbone implementations, please refer to the existing backbone implementations in the MatterTune source code:
- JMP backbone: `mattertune/backbones/jmp/model.py`
- EquiformerV2 backbone: `mattertune/backbones/eqV2/model.py`
- M3GNet backbone: `mattertune/backbones/m3gnet/model.py`
- ORB backbone: `mattertune/backbones/orb/model.py`

## Implementing Custom Datasets

### Dataset Structure

Custom datasets require two classes:
1. A configuration class inheriting from `DatasetConfigBase`
2. A dataset class inheriting from `Dataset[ase.Atoms]`

Basic template:

```python
from typing import Literal
from typing_extensions import override
import mattertune as mt
from torch.utils.data import Dataset
from ase import Atoms

@mt.data_registry.register
class MyDatasetConfig(mt.DatasetConfigBase):
type: Literal["my_dataset"] = "my_dataset"

# Add your configuration parameters
data_path: str

@override
def create_dataset(self):
return MyDataset(self)

class MyDataset(Dataset[Atoms]):
def __init__(self, config: MyDatasetConfig):
self.config = config
# Initialize your dataset

def __len__(self):
return len(self.data)

def __getitem__(self, idx) -> Atoms:
# Return an ASE Atoms object
return self.data[idx]
```

For detailed examples of dataset implementations, please refer to the existing dataset implementations in the MatterTune source code:
- XYZ dataset: `mattertune/data/xyz.py`
- ASE database dataset: `mattertune/data/db.py`
- Materials Project dataset: `mattertune/data/mp.py`
- Matbench dataset: `mattertune/data/matbench.py`

## Usage

After implementing your custom components, you can use them in your training configuration:

```python
config = mt.configs.MatterTunerConfig(
model=MyBackboneConfig(
hidden_size=256,
num_layers=4,
properties=[
mt.configs.EnergyPropertyConfig(...)
]
),
data=mt.configs.AutoSplitDataModuleConfig(
dataset=MyDatasetConfig(
data_path="path/to/data"
),
train_split=0.8,
batch_size=32
)
)

tuner = mt.MatterTuner(config)
model, trainer = tuner.tune()
```

## Best Practices

1. **Type Hints**: Always use proper type hints to catch errors early
2. **Documentation**: Document your custom components thoroughly
3. **Error Handling**: Provide clear error messages for configuration issues
4. **Testing**: Write tests for your custom components
5. **Dependencies**: Clearly document any additional dependencies

For more examples, check the source code of the built-in backbones and datasets in the MatterTune repository.
Loading