Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,22 @@ poetry run mypy .


### What `main.py` Does
- Builds the `DummyCNN_MNIST` model defined in `src/model/DummyCNN_MNIST.py`, a cross-entropy loss, and an Adam optimizer.
- Loads the MNIST training split, stacks the tensors, and iterates over 10 tasks (digits 0–9). Each task applies random rotation and translation to encourage continual adaptation.
- Maintains replay buffers (`memory_image`, `memory_label`, etc.) so past samples remain available for rehearsal while training new tasks.
- Calls `CL(...)` to assemble task-specific dataloaders and drive the `One_task_CL` loop. The loop trains for five epochs, records loss/accuracy metrics, and prints periodic progress reports.
- Computes sensitivity scores with `src/validation/validation_utils/return_score` after each task; you can repurpose these values for analysis or adaptive triggers.
- Builds a `Config` from the TOML file, `APP_` environment variables, and `--set` CLI overrides (`src/apeiron/config/configuration.py`).
- Configures the logging backend and console logger (`src/apeiron/logger/`), before constructing the harness so a harness that logs from `__init__` cannot pin the config.
- Selects a concrete `BaseModelHarness` from `cfg.data.name` via `examples/utils.py:get_example`.
- Runs `ContinuousMonitor` (`src/apeiron/driver/continuous_monitor.py`), which evaluates streaming batches and calls the drift detector every `detection_interval` batches.
- On drift, dispatches `ContinuousTrainer` (`src/apeiron/training/continuous_trainer.py`) with the updater named by `[continual_learning] update_mode`.

See [`docs/architecture.md`](docs/architecture.md) for the full pipeline, including the detection-only (`src/drift_only.py`) and adaptation-only (`src/cl_only.py`) entry points.

## Tuning Tips
- Change the number of epochs by editing `n_epoch` inside `CL`.
- Adjust replay/adversarial update counts through the `params` dictionaries in `One_task_CL` and `util.update_CL_`.
- Experiment with different transforms or task definitions by modifying `data.py`.
- Update batch sizes by changing the `batch_size` parameter used when constructing the dataloaders.
- Change the CL loop's outer/inner iteration counts and learning rate through the `[continual_learning]` and `[train]` config sections.
- Swap the adaptation strategy with `[continual_learning] update_mode` (`base`, `jvp_reg`, `ewc_online`, `kfac_online`, `none`).
- Tune detection sensitivity with `[drift_detection] detector_name` and its per-detector parameters — see [`docs/drift_detectors.md`](docs/drift_detectors.md).
- Update batch size and worker count with `[train] batch_size` and `[train] num_workers`.

## Output
Training logs report the task id, training/test accuracy, and replay-memory accuracy every five epochs. Accuracy is computed via `test(...)` on both the current task and the accumulated memory set.
The console logger reports per-stage metrics (`eval`, `drift`, `cl`). When `[visualization] input` is set, the run also writes a metrics CSV at that path for external plotting.

## Deployment

Expand Down
2 changes: 1 addition & 1 deletion examples/mnist/model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# src/model/mnist_cnn_harness.py
# examples/mnist/model.py
import gc
import torch
import torch.nn.functional as F
Expand Down
4 changes: 2 additions & 2 deletions src/apeiron/deployment/frontier/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Clone the repo into your scratch directory and run the install script:
cd $MEMBERWORK
git clone https://github.com/AI-ModCon/BaseSim_Framework.git
cd BaseSim_Framework
source ./src/deployment/frontier/install_venv.sh
source ./src/apeiron/deployment/frontier/install_venv.sh
```

`install_venv.sh` creates a virtual environment, installs Poetry, and uses it to resolve and install project dependencies. The environment is saved to `.venv` in the project root. The script runs the following:
Expand Down Expand Up @@ -51,7 +51,7 @@ The virtual environment can be sourced directly at the top of your SLURM script
From the project root:

```bash
sbatch -A xxx src/deployment/frontier/mnist_example.sbatch
sbatch -A xxx src/apeiron/deployment/frontier/mnist_example.sbatch
```

### Troubleshooting
Expand Down
4 changes: 2 additions & 2 deletions src/apeiron/deployment/perlmutter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Clone the repo into your scratch directory and run the install script:
cd $SCRATCH
git clone https://github.com/AI-ModCon/BaseSim_Framework.git
cd BaseSim_Framework
source ./src/deployment/perlmutter/install_venv.sh
source ./src/apeiron/deployment/perlmutter/install_venv.sh
```

`install_venv.sh` creates a virtual environment, installs Poetry, and uses it to resolve and install project dependencies. The environment is saved to `.venv` in the project root. The script runs the following:
Expand All @@ -37,7 +37,7 @@ The virtual environment can be sourced directly at the top of your SLURM script
From the project root:

```bash
sbatch -A amsc002 src/deployment/perlmutter/mnist_example.sbatch
sbatch -A amsc002 src/apeiron/deployment/perlmutter/mnist_example.sbatch
```

### Troubleshooting
Expand Down
2 changes: 1 addition & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for src/config/configuration.py"""
"""Tests for src/apeiron/config/configuration.py"""

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion tests/test_continuous_monitor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for src/driver/continuous_monitor.py"""
"""Tests for src/apeiron/driver/continuous_monitor.py"""

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion tests/test_continuous_trainer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for src/training/continuous_trainer.py"""
"""Tests for src/apeiron/training/continuous_trainer.py"""

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion tests/test_evaluation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for src/evaluation/metrics.py and src/evaluation/evaluation.py"""
"""Tests for src/apeiron/evaluation/metrics.py and src/apeiron/evaluation/evaluation.py"""

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion tests/test_model_harness.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for src/model/torch_model_harness.py (BaseModelHarness via DummyHarness)."""
"""Tests for src/apeiron/model/torch_model_harness.py (BaseModelHarness via DummyHarness)."""

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion tests/test_profiler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for src/profilers/count_flops.py"""
"""Tests for src/apeiron/profilers/count_flops.py"""

from __future__ import annotations

Expand Down
Loading