Skip to content

Latest commit

 

History

History

FermiML-Framework-Classification

README.md

FermiML-Framework-Classification

Star on GitHub GitHub forks Python 3.6 downloads PyPI version License

Tests Workflow Dist Workflow Doc Workflow Code style: black Imports: isort

Description

Reproduction of Better than classical? The subtle art of benchmarking quantum machine learning models with free-fermionic models.

Installation

Development Dependencies

With uv installed, run the following commands to install the dependencies:

uv venv .venv
uv sync --dev

With python and pip installed, run the following commands to install the dependencies:

python -m venv .venv
source .venv/bin/activate
pip install uv
python -m uv sync --dev

With poetry installed, run the following commands to install the dependencies:

python -m venv .venv
source .venv/bin/activate
poetry install

Scripting Usage

To run a single training, you can run the following command:

python -m <package_name> <your_parameters>

and to know the parameters you can use the help command:

python -m <package_name> --help

Deployment

You will need to install Docker to run the trainings in a container. You can install Docker by following the instructions here.

To build the docker image of the project you can run the following command:

docker build -t <package_name>:latest .

The container can be run in two different modes:

  • release: This mode is responsible for running the main.py of the current package.
  • it: This is a development mode that is responsible for running the container in the interactive mode.

To run a mode <mode> you can run the following command:

docker run --name <package_name>-<phase> --detach --rm --volume=<data_path>:/<ROOT_DIR>/data -e "MODE=<mode>" <package_name>:latest <your_arguments>

where <data_path> is the absolute path in your local machine where you want to store the data generated by the phase. The <ROOT_DIR> is the root directory of the project.

There is another way you can do all of this. You can use the docker_files/build_image_and_run.py script. This script will build the image and run the mode you want. You can run the script with the following command:

python docker_files/build_image_and_run.py --mode=<mode>

Running on the Cluster

This project uses Snakemake with the SLURM executor plugin to manage job submission on HPC clusters (Alliance Canada / Compute Canada).

Prerequisites

  • Apptainer (Singularity) module available on the cluster (module load apptainer/1.4.5)
  • Project .sif image placed under data/dockerfiles/ (see the Deployment section)
  • Snakemake ≥ 8 and the SLURM executor plugin:
uv add --dev snakemake snakemake-executor-plugin-slurm

1. Get the experiment config

The experiment configuration is at data/configs/config_20splits.yaml. Make sure this file is present on the cluster (it is tracked in the repository, so a git pull is sufficient).

2. Dry-run

Preview all jobs that Snakemake would submit without running anything:

uv run python -m snakemake --snakefile workflow/Snakefile --cores 1 -n

3. Submit to the cluster

From the login node, launch the full experiment using the bundled SLURM profile:

uv run python -m snakemake --snakefile workflow/Snakefile \
    --profile workflow/profiles/slurm

Snakemake submits one independent SLURM job per unfinished experiment config. Jobs whose state.finished file already exists are automatically skipped — re-running the command safely resumes where it left off.

Common flags:

Flag Effect
-n Dry-run: print the job DAG without submitting
--forceall Re-run all jobs, even finished ones
--rerun-incomplete Retry jobs that started but did not finish
--jobs N Override the cap on concurrent SLURM submissions

4. Monitor progress

squeue -u $USER
squeue -u $USER -h -r -O state | uniq -c   # counts by state

Per-job logs are written to data/{experiment_name}/logs/snakemake/{hash}.log.

Customising resources or the experiment

File Purpose
workflow/config.yaml Active experiment name, config path, SIF version
workflow/profiles/slurm/config.yaml Default SLURM account, memory, time limit
workflow/Snakefile Rule definitions; add per-rule resources: blocks to override defaults

To switch to a different experiment, update config_file in workflow/config.yaml to point to the new config.

References

License

Acknowledgements

AI usage disclosure

The author acknowledges the use of AI-assisted tools during the implementation of this project to assist debugging and improve the quality of the code. AI tools were also used to generate the unit tests. The author has reviewed, edited, and validated all AI-assisted content and assumes full responsibility for the final version of the code.

Citation