anonymous commited on
Commit
8bc5533
·
1 Parent(s): 0301639

updated scripts for mace, updated readme and gitignore

Browse files
.gitignore CHANGED
@@ -19,3 +19,11 @@ models/matris/**/*.o
19
  *.so
20
  *.o
21
  *.pdf
 
 
 
 
 
 
 
 
 
19
  *.so
20
  *.o
21
  *.pdf
22
+
23
+ __pycache__/
24
+ *.py[cod]
25
+ *$py.class
26
+
27
+ # Evaluation outputs
28
+ eval_results/
29
+ **/eval_results/
README.md CHANGED
@@ -14,7 +14,7 @@ size_categories:
14
 
15
  ## Repository Structure
16
 
17
- Datasets are stored in the `datasets/` directory and are provided in both `.h5` and `.xyz` formats.
18
 
19
  All model implementations, training code, evaluation code, and checkpoints are located in the `models/` directory. Each model subdirectory contains:
20
 
@@ -25,4 +25,4 @@ The scripts are configured to be launched from the repository root directory. Fo
25
 
26
  ```bash
27
  ./models/matris/scripts/run_matris.sh
28
-
 
14
 
15
  ## Repository Structure
16
 
17
+ Datasets are stored in the `datasets/` directory and are provided in both `.h5` and `.xyz` formats. The directory also includes the 1000 larger systems dataset. For `.h5` datasets (used with EquiformerV2), the training and validation split is handled automatically during loading. The reaaining models used `.xyz` format.
18
 
19
  All model implementations, training code, evaluation code, and checkpoints are located in the `models/` directory. Each model subdirectory contains:
20
 
 
25
 
26
  ```bash
27
  ./models/matris/scripts/run_matris.sh
28
+ ```
models/mace/README.md DELETED
@@ -1,5 +0,0 @@
1
- ## Introduction
2
-
3
- Running the script can be found in mace/cli/run_train
4
-
5
- you can run it from scripts/run_mace.sh. Just speicfy pathways
 
 
 
 
 
 
models/mace/mace/cli/our_files/__pycache__/run_calc.cpython-310.pyc DELETED
Binary file (22.1 kB)
 
models/mace/mace/cli/our_files/__pycache__/run_eval.cpython-310.pyc DELETED
Binary file (9.43 kB)
 
models/mace/mace/cli/our_files/__pycache__/run_eval_foundation.cpython-310.pyc DELETED
Binary file (11.3 kB)
 
models/mace/mace/cli/our_files/__pycache__/run_eval_foundation_no_finetuning.cpython-310.pyc DELETED
Binary file (11.3 kB)
 
models/mace/mace/cli/our_files/{run_eval.py → eval_matris.py} RENAMED
@@ -329,7 +329,9 @@ def main():
329
  # Build validation set/loader ONCE, using the first model for z_table + r_max
330
  # (assumes comparable checkpoints; if not, rebuild per model instead)
331
  # -------------------------------------------------------------------------
332
- first_model = torch.load(model_paths[0], map_location="cpu")
 
 
333
  n_params_total = count_params_millions(first_model, trainable_only=False)
334
  n_params_train = count_params_millions(first_model, trainable_only=True)
335
 
 
329
  # Build validation set/loader ONCE, using the first model for z_table + r_max
330
  # (assumes comparable checkpoints; if not, rebuild per model instead)
331
  # -------------------------------------------------------------------------
332
+ print("\n")
333
+ print(model_paths[0])
334
+ first_model = torch.load(model_paths[0], map_location="cpu", weights_only=False)
335
  n_params_total = count_params_millions(first_model, trainable_only=False)
336
  n_params_train = count_params_millions(first_model, trainable_only=True)
337
 
models/mace/scripts/eval_matris.sh ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # ----------------------------
5
+ # Resolve paths
6
+ # ----------------------------
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ MACE_REPO_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
9
+ REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
10
+
11
+ # ----------------------------
12
+ # User settings
13
+ # ----------------------------
14
+ NAME="eval"
15
+
16
+ VALID_FILE="$REPO_ROOT/datasets/xyz/test.xyz"
17
+
18
+ OUT_DIR="$MACE_REPO_DIR/eval_results"
19
+ OUT_TXT_FILE="$OUT_DIR/test.txt"
20
+
21
+ MODEL_PATHS=(
22
+ "$MACE_REPO_DIR/runs/mace_seed42.model"
23
+ )
24
+
25
+ BATCH_SIZE="5"
26
+ SEED="42"
27
+ DEVICE="cuda"
28
+
29
+ # ----------------------------
30
+ # Detect number of visible GPUs
31
+ # ----------------------------
32
+ if command -v nvidia-smi &> /dev/null; then
33
+ NGPUS="$(nvidia-smi -L | wc -l | tr -d ' ')"
34
+ else
35
+ NGPUS="1"
36
+ fi
37
+
38
+ NGPUS="${NGPUS:-1}"
39
+
40
+ # ----------------------------
41
+ # Sanity checks
42
+ # ----------------------------
43
+ if [ ! -d "$MACE_REPO_DIR/mace" ]; then
44
+ echo "ERROR: MACE package directory not found:"
45
+ echo "$MACE_REPO_DIR/mace"
46
+ exit 1
47
+ fi
48
+
49
+ if [ ! -f "$VALID_FILE" ]; then
50
+ echo "ERROR: Validation file not found:"
51
+ echo "$VALID_FILE"
52
+ exit 1
53
+ fi
54
+
55
+ for model_path in "${MODEL_PATHS[@]}"; do
56
+ if [ ! -f "$model_path" ]; then
57
+ echo "ERROR: Model checkpoint not found:"
58
+ echo "$model_path"
59
+ exit 1
60
+ fi
61
+ done
62
+
63
+ mkdir -p "$OUT_DIR"
64
+
65
+ echo "Using NGPUS=${NGPUS}"
66
+ echo "MACE_REPO_DIR=${MACE_REPO_DIR}"
67
+ echo "REPO_ROOT=${REPO_ROOT}"
68
+ echo "Validation file=${VALID_FILE}"
69
+ echo "Output file=${OUT_TXT_FILE}"
70
+ echo "Evaluating models:"
71
+ for m in "${MODEL_PATHS[@]}"; do
72
+ echo " - $m"
73
+ done
74
+
75
+ # ----------------------------
76
+ # Go to MACE repo root and expose it to Python
77
+ # ----------------------------
78
+ cd "$MACE_REPO_DIR"
79
+ export PYTHONPATH="$MACE_REPO_DIR:${PYTHONPATH:-}"
80
+
81
+ unset SLURM_JOB_NODELIST \
82
+ SLURM_NTASKS \
83
+ SLURM_NTASKS_PER_NODE \
84
+ SLURM_NNODES \
85
+ SLURM_LOCALID \
86
+ SLURM_PROCID \
87
+ SLURM_NODEID \
88
+ SLURM_JOB_ID
89
+
90
+ # ----------------------------
91
+ # Launch evaluation
92
+ # ----------------------------
93
+ torchrun --standalone --nproc_per_node="$NGPUS" -m mace.cli.our_files.eval_matris \
94
+ --name "$NAME" \
95
+ --seed "$SEED" \
96
+ --valid_file "$VALID_FILE" \
97
+ --batch_size "$BATCH_SIZE" \
98
+ --valid_batch_size "$BATCH_SIZE" \
99
+ --device "$DEVICE" \
100
+ --energy_key "energy" \
101
+ --forces_key "forces" \
102
+ --out_txt "$OUT_TXT_FILE" \
103
+ --model_paths "${MODEL_PATHS[@]}"
models/mace/scripts/run_mace.sh CHANGED
@@ -1,33 +1,29 @@
1
  #!/usr/bin/env bash
2
  set -euo pipefail
3
 
4
-
5
-
6
  # ----------------------------
7
- # User settings (edit these)
8
  # ----------------------------
9
- MACE_REPO_DIR="" # repo root (contains "mace/" folder)
10
- NAME="new_testing"
11
- CHECKPOINT_DIR="new_models/"
12
-
13
- TRAIN_FILE=""
14
- VALID_FILE=""
15
- TEST_FILE=""
16
-
17
- # If you want a fixed validation set instead of valid_fraction, replace VALID_FRACTION with VALID_FILE below.
18
- VALID_FRACTION="0.5"
19
- # VALID_FILE="valid.xyz" # uncomment and use this instead of --valid_fraction if desired
20
 
 
 
 
 
21
 
 
 
 
22
 
 
23
 
24
  # From the docs screenshot:
25
  CONFIG_TYPE_WEIGHTS='{"Default":1.0}'
26
 
27
- # IMPORTANT: Replace these example E0s with your actual values if needed.
28
- # The screenshot shows a dict with element keys; keep as a single-quoted string.
29
  E0S='{1: 2.467478445, 6: 8.0273263225, 8: 3.334308855, 22: 4.879036065}'
30
- #E0S='{1: 1.0, 6: 1.0, 8: 1.0, 22: 1.0}'
31
  ATOMIC_NUMBERS='[1,6,8,22]'
32
 
33
  MODEL="MACE"
@@ -42,6 +38,8 @@ SEED="11"
42
  DEVICE="cuda"
43
  MAX_NUM_EPOCHS="10"
44
 
 
 
45
  # ----------------------------
46
  # Detect number of visible GPUs
47
  # ----------------------------
@@ -50,19 +48,58 @@ if command -v nvidia-smi &> /dev/null; then
50
  else
51
  NGPUS="1"
52
  fi
 
53
  NGPUS="${NGPUS:-1}"
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  echo "Using NGPUS=${NGPUS}"
56
  echo "MACE_REPO_DIR=${MACE_REPO_DIR}"
57
- echo "Train=${TRAIN_FILE} Test=${TEST_FILE}"
 
 
 
58
  echo "Checkpoint_dir=${CHECKPOINT_DIR}"
59
 
60
  # ----------------------------
61
- # Go to repo root and expose it to Python
62
- cd "${MACE_REPO_DIR}"
63
- export PYTHONPATH="$(pwd):${PYTHONPATH:-}"
64
-
65
- unset SLURM_JOB_NODELIST SLURM_NTASKS SLURM_NTASKS_PER_NODE SLURM_NNODES SLURM_LOCALID SLURM_PROCID SLURM_NODEID SLURM_JOB_ID
 
 
 
 
 
 
 
 
66
 
67
  # ----------------------------
68
  # Per-run output folders
@@ -77,67 +114,57 @@ RUN_LOGS_DIR="${RUN_DIR}/logs"
77
  RUN_WANDB_DIR="${RUN_DIR}/wandb"
78
 
79
  mkdir -p \
80
- "${RUN_CHECKPOINTS_DIR}" \
81
- "${RUN_MODELS_DIR}" \
82
- "${RUN_RESULTS_DIR}" \
83
- "${RUN_LOGS_DIR}" \
84
- "${RUN_WANDB_DIR}"
85
 
86
  echo "RUN_DIR=${RUN_DIR}"
87
 
88
- WAND_PROJECT="testing_mace_wandb"
89
-
90
  # ----------------------------
91
  # Launch training
92
  # ----------------------------
93
- torchrun --standalone --nproc_per_node=$NGPUS -m mace.cli.run_train \
94
- --name="${NAME}" \
95
- --seed="${SEED}" \
96
- --checkpoints_dir="${RUN_CHECKPOINTS_DIR}" \
97
- --model_dir="${RUN_MODELS_DIR}" \
98
- --results_dir="${RUN_RESULTS_DIR}" \
99
- --log_dir="${RUN_LOGS_DIR}" \
100
  \
 
 
 
 
101
  \
102
- --max_num_epochs="${MAX_NUM_EPOCHS}" \
103
- --train_file="${TRAIN_FILE}" \
104
- --valid_file="${VALID_FILE}" \
105
- --test_file="${TEST_FILE}" \
 
106
  \
107
- \
108
- --hidden_irreps="${HIDDEN_IRREPS}" \
109
- --config_type_weights="${CONFIG_TYPE_WEIGHTS}" \
110
- --E0s="${E0S}" \
111
- --model="${MODEL}" \
112
- --r_max="${R_MAX}" \
113
- \
114
- \
115
- --batch_size="${BATCH_SIZE}" \
116
- --valid_batch_size="${VALID_BATCH_SIZE}" \
117
  --ema \
118
- --ema_decay="${EMA_DECAY}" \
119
  --amsgrad \
120
- --device="${DEVICE}" \
121
- --atomic_numbers "${ATOMIC_NUMBERS}" \
122
- \
123
  \
124
  --energy_key "energy" \
125
  --forces_key "forces" \
126
  \
127
- \
128
  --loss "ours_mae" \
129
  --forces_weight 1.0 \
130
  --energy_weight 1.0 \
131
  --default_dtype "float32" \
132
  \
133
- \
134
  --distributed \
135
  \
136
- \
137
  --wandb \
138
- --wandb_dir "${RUN_WANDB_DIR}" \
139
- --wandb_project "${WAND_PROJECT}" \
140
- --wandb_name "${NAME}" \
141
  \
142
- --swa \
143
-
 
1
  #!/usr/bin/env bash
2
  set -euo pipefail
3
 
 
 
4
  # ----------------------------
5
+ # Resolve paths
6
  # ----------------------------
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ MACE_REPO_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
9
+ REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
 
 
 
 
 
 
 
 
10
 
11
+ # ----------------------------
12
+ # User settings
13
+ # ----------------------------
14
+ NAME="mace"
15
 
16
+ TRAIN_FILE="$REPO_ROOT/datasets/xyz/train.xyz"
17
+ VALID_FILE="$REPO_ROOT/datasets/xyz/val.xyz"
18
+ TEST_FILE="$REPO_ROOT/datasets/xyz/test.xyz"
19
 
20
+ CHECKPOINT_DIR="$MACE_REPO_DIR/checkpoints_mace"
21
 
22
  # From the docs screenshot:
23
  CONFIG_TYPE_WEIGHTS='{"Default":1.0}'
24
 
25
+ # Replace these E0s if needed.
 
26
  E0S='{1: 2.467478445, 6: 8.0273263225, 8: 3.334308855, 22: 4.879036065}'
 
27
  ATOMIC_NUMBERS='[1,6,8,22]'
28
 
29
  MODEL="MACE"
 
38
  DEVICE="cuda"
39
  MAX_NUM_EPOCHS="10"
40
 
41
+ WAND_PROJECT="mace"
42
+
43
  # ----------------------------
44
  # Detect number of visible GPUs
45
  # ----------------------------
 
48
  else
49
  NGPUS="1"
50
  fi
51
+
52
  NGPUS="${NGPUS:-1}"
53
 
54
+ # ----------------------------
55
+ # Sanity checks
56
+ # ----------------------------
57
+ if [ ! -d "$MACE_REPO_DIR/mace" ]; then
58
+ echo "ERROR: MACE package directory not found:"
59
+ echo "$MACE_REPO_DIR/mace"
60
+ exit 1
61
+ fi
62
+
63
+ if [ ! -f "$TRAIN_FILE" ]; then
64
+ echo "ERROR: Training file not found:"
65
+ echo "$TRAIN_FILE"
66
+ exit 1
67
+ fi
68
+
69
+ if [ ! -f "$VALID_FILE" ]; then
70
+ echo "ERROR: Validation file not found:"
71
+ echo "$VALID_FILE"
72
+ exit 1
73
+ fi
74
+
75
+ if [ ! -f "$TEST_FILE" ]; then
76
+ echo "ERROR: Test file not found:"
77
+ echo "$TEST_FILE"
78
+ exit 1
79
+ fi
80
+
81
  echo "Using NGPUS=${NGPUS}"
82
  echo "MACE_REPO_DIR=${MACE_REPO_DIR}"
83
+ echo "REPO_ROOT=${REPO_ROOT}"
84
+ echo "Train=${TRAIN_FILE}"
85
+ echo "Valid=${VALID_FILE}"
86
+ echo "Test=${TEST_FILE}"
87
  echo "Checkpoint_dir=${CHECKPOINT_DIR}"
88
 
89
  # ----------------------------
90
+ # Go to MACE repo root and expose it to Python
91
+ # ----------------------------
92
+ cd "$MACE_REPO_DIR"
93
+ export PYTHONPATH="$MACE_REPO_DIR:${PYTHONPATH:-}"
94
+
95
+ unset SLURM_JOB_NODELIST \
96
+ SLURM_NTASKS \
97
+ SLURM_NTASKS_PER_NODE \
98
+ SLURM_NNODES \
99
+ SLURM_LOCALID \
100
+ SLURM_PROCID \
101
+ SLURM_NODEID \
102
+ SLURM_JOB_ID
103
 
104
  # ----------------------------
105
  # Per-run output folders
 
114
  RUN_WANDB_DIR="${RUN_DIR}/wandb"
115
 
116
  mkdir -p \
117
+ "$RUN_CHECKPOINTS_DIR" \
118
+ "$RUN_MODELS_DIR" \
119
+ "$RUN_RESULTS_DIR" \
120
+ "$RUN_LOGS_DIR" \
121
+ "$RUN_WANDB_DIR"
122
 
123
  echo "RUN_DIR=${RUN_DIR}"
124
 
 
 
125
  # ----------------------------
126
  # Launch training
127
  # ----------------------------
128
+ torchrun --standalone --nproc_per_node="$NGPUS" -m mace.cli.run_train \
129
+ --name="$NAME" \
130
+ --seed="$SEED" \
131
+ --checkpoints_dir="$RUN_CHECKPOINTS_DIR" \
132
+ --model_dir="$RUN_MODELS_DIR" \
133
+ --results_dir="$RUN_RESULTS_DIR" \
134
+ --log_dir="$RUN_LOGS_DIR" \
135
  \
136
+ --max_num_epochs="$MAX_NUM_EPOCHS" \
137
+ --train_file="$TRAIN_FILE" \
138
+ --valid_file="$VALID_FILE" \
139
+ --test_file="$TEST_FILE" \
140
  \
141
+ --hidden_irreps="$HIDDEN_IRREPS" \
142
+ --config_type_weights="$CONFIG_TYPE_WEIGHTS" \
143
+ --E0s="$E0S" \
144
+ --model="$MODEL" \
145
+ --r_max="$R_MAX" \
146
  \
147
+ --batch_size="$BATCH_SIZE" \
148
+ --valid_batch_size="$VALID_BATCH_SIZE" \
 
 
 
 
 
 
 
 
149
  --ema \
150
+ --ema_decay="$EMA_DECAY" \
151
  --amsgrad \
152
+ --device="$DEVICE" \
153
+ --atomic_numbers "$ATOMIC_NUMBERS" \
 
154
  \
155
  --energy_key "energy" \
156
  --forces_key "forces" \
157
  \
 
158
  --loss "ours_mae" \
159
  --forces_weight 1.0 \
160
  --energy_weight 1.0 \
161
  --default_dtype "float32" \
162
  \
 
163
  --distributed \
164
  \
 
165
  --wandb \
166
+ --wandb_dir "$RUN_WANDB_DIR" \
167
+ --wandb_project "$WAND_PROJECT" \
168
+ --wandb_name "$NAME" \
169
  \
170
+ #--swa