Skip to content

Repository files navigation

MLFF Attack Data Collection

This repo runs an HPC data-collection workflow from the mlff_attack package:

https://github.com/TRustworthy-AI-Tools-for-Science/mlff_attack

This repo has two dataset workflows:


Setup for HPC

This repo expects three separate Python environments because each MLFF have different dependency stacks.

Expected Folder Layout

After completing the following 4 steps:

~/project/
├── mlff_attack/
├── mlff_attack_data_collection/
│   ├── .env
│   ├── mace-mh-1.model
│   ├── uma-s-1p1.pt
│   ├── pot.almtp
│   ├── pot.almtp.elements
│   └── MACE_model.model
├── .venv-mace/
├── .venv-uma/
├── .venv-chgnet/
├── mlip-3/bin/mlp
└── .venv-mtp/bin/mlp

1. Clone Repos

git clone https://github.com/TRustworthy-AI-Tools-for-Science/mlff_attack.git
git clone https://github.com/declanwhchan/mlff_attack_data_collection.git

2. Create Python Environments

cd ~/project/mlff_attack_data_collection
bash mlff_venvs_for_hpc.sh

3. Create .env

Create .env in mlff_attack_data_collection and enter the following:

MP_API_KEY=your_materials_project_key
HF_TOKEN=hf_your_huggingface_token_here

Then protect it:

chmod 600 .env

4. Import MLFFs

Download models externally into mlff_attack_data_collection (CHGNet is already built-in):


Workflow

Scripts in run_<dataset>/sample_1/ are the single-test versions of the same workflow, so you can run them for a quick check before running the full collection.

Reminder to sync local changes to HPC: Before running or submitting jobs on the HPC, in SFTP, push/sync all local changes from this computer so the HPC copy is up to date.

Data Collection Jobs

Run the next step only after the previous step is fully completed.

All steps are to be executed in SSH.

Step 1 — Run Setup

bash run_<dataset>/setup.sh

# Generate initial and perturbed cif structures (OPTIONAL)
bash run_<dataset>/cifs.sh

Step 2 — Run Main Jobs

sbatch run_<dataset>/main.sh
sbatch run_<dataset>/main_gpu.sh

# Run contour exploration (OPTIONAL)
sbatch run_<dataset>/contour.sh
sbatch run_<dataset>/contour_gpu.sh

Step 3 — Generate Plots

sbatch run_<dataset>/plot.sh

# Run for faster generation of publication plots if plot.sh was initially completed
sbatch run_<dataset>/good_plots.sh

# Visualize initial atomic structures (OPTIONAL)
sbatch run_<dataset>/visualize.sh

Optional — Run Supercell Stress Test

This submits a controller job that generates supercell CIFs, launches the full MLFF attack array, and then runs a dependent plotting job.

sbatch run_<dataset>/supercell.sh
sbatch run_<dataset>/supercell_gpu.sh

Check Status of Jobs

# Refresh checking the queue every second:
watch -n 1 sq

# Follow live Slurm output:
tail -f slurm-<jobid>.out

Export Outputs

View Plots Without Downloading

PowerShell

ssh -L 8000:localhost:8000 <username>@fir.alliancecan.ca

HPC

Then, open a separate terminal and ensure you are in the same login<#>. If not, then ssh login<#> and continue on HPC:

cd mlff_attack_data_collection
python -m http.server 8000

Open

http://localhost:8000

Or Download Target Results

Login using SFTP:

cd /mlff_attack_data_collection

get -r <target_directory>

About

Reproducible MLFF adversarial robustness framework for HPC

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages