# How MaterialsSaddles v2 was produced from v1 These are the scripts that were run, with one change. We removed the 2 broken triplets of step 7 in a separate step after the write. Here, steps 7 to 9 do this removal. The scripts write the same rows and tables as the release. Absolute paths inside them are those of the original run (`ROOT` = the v1 files, `OUT` = a work directory) and must be adapted. Dependencies: `numpy`, `scipy`, `pyarrow`, `ase`, `ase_db_backends`, `lmdb`, `huggingface_hub`; `fairchem-core` only for one check in `v2_verify.py`. ## Duplicate detection and split (computed on the v1 files) 1. `dedup_pass1.py` — reads every row once. A triplet is the three consecutive `ms_id`s `3k, 3k+1, 3k+2` (asserted against the stored `side` where present). Per triplet it stores the reactant, saddle and product positions, atomic numbers, FixAtoms mask and cell, bucketed by a hash of the exact composition, plus the chemical system, reduced formula and upstream source identifier. 2. `dedup_pass2.py` — within each exact composition (all subsets together), triplets in `ms_id` order are leader-clustered: a triplet joins the first cluster whose representative has - the same lattice: cell lengths within 2 %, angles within 1°, every cell-matrix entry within 2 % of the longest cell vector; - a saddle within 0.2 Å max-atom distance; - reactant and product both within 0.2 Å, in the same or the swapped orientation. Max-atom distance = largest atomic displacement after per-species Hungarian matching (minimum summed squared distance) under the minimum-image convention, fractional coordinates mapped into the mean cell. The representative of each cluster (its lowest `ms_id`) is kept. 3. `dedup_pass3.py` — drops non-representatives and assigns every chemical system (element set of the cell) as a whole to train / val / test with probabilities 0.90 / 0.05 / 0.05 (`numpy.random.default_rng(0)`), one draw per chemical system, globally across subsets. Writes the per-split `ms_id` lists and `duplicates.parquet` (every triplet → its representative). 4. Audits: `verify_integrity.py` (every v1 row: `ms_id`s are exactly 0..3N−1, the three rows of a triplet share atomic numbers, cell and pbc, `side` = `ms_id % 3 − 1`) and `verify_dedup.py` (an independent distance implementation re-checks removed triplets against their representative, searches kept triplets against *all* same-composition triplets for missed duplicates, and checks the split files). ## Rewrite into the v2 layout (from the SciLM v1 files, which carry energies and forces) 5. `v2_sha.py` — checks every downloaded v1 file against the SHA-256 recorded by Hugging Face. 6. `v2_index.py` — indexes every row of a set of files: `ms_id`, file, LMDB key, SHA-1 of the stored bytes, and hashes of the geometry and of `data.info`. Run on the v1 files the deduplication was computed from and on the SciLM v1 files; `v2_compare.py` then shows both hold the same `ms_id`s with identical geometry and `info`, and that every row has finite energy and forces. 7. `v2_write.py` — writes `//__.aselmdb`, at most 50,000 triplets per file, in ascending `ms_id` order. Rows are not re-serialised: the stored (compressed JSON) value of each row is copied unchanged under the new ASE row id, and `nextid` is written as `ase_db_backends` does. `v2_write.py` cuts the files on the full split lists. Then it skips the 2 broken triplets (saddle `ms_id` 35584423 and 79800988, forces at the saddle above 100 million eV/Å). As a result, `lemat_train_0213` and `lemat_train_0479` hold 49,999 triplets each. The other files do not change. 8. `v2_verify.py` — reads every row of every output file and checks: keys `1..N` + `nextid`; complete, adjacent R, S, P triplets in ascending `ms_id` order; every stored value byte-identical to the v1 row with the same `ms_id`; files of a split named consecutively, in `ms_id` order, all but the last full (except `lemat_train_0213` and `lemat_train_0479`, each one broken triplet short); each split directory holds exactly the `ms_id`s of its split, less the 2 broken triplets; the union is exactly the kept set, less the 2 broken triplets; no removed or broken triplet present. It also compares a random sample of rows read through `ase.db` against the v1 rows and opens files with fairchem's `AseDBDataset`. 9. `v2_metadata.py` — builds `metadata/triplets.parquet` and `metadata/removed_duplicates.parquet` from what `v2_verify.py` observed in the written files (refuses to run if verification failed). `removed_duplicates.parquet` lists each removed duplicate with its kept triplet (`reason` = `duplicate`) and the 2 broken triplets with no kept triplet (`reason` = `broken`). A later commit removed 2 triplets whose cell has 1 atom and added them with no kept triplet (`reason` = `one_atom`).