Skip to content

feat(ocl): add Memory Aware Synapses (MAS) strategy - #406

Open
tachyonicClock wants to merge 1 commit into
feat/ocl-lwffrom
feat/ocl-mas
Open

feat(ocl): add Memory Aware Synapses (MAS) strategy#406
tachyonicClock wants to merge 1 commit into
feat/ocl-lwffrom
feat/ocl-mas

Conversation

@tachyonicClock

@tachyonicClock tachyonicClock commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator
  • Stacked on feat(ocl): add Learning Without Forgetting (LWF) strategy #404 (feat/ocl-lwf), which is stacked on feat(ocl): add Synaptic Intelligence (SI) strategy #403 (feat/ocl-si) - this PR only diffs the MAS-specific changes and depends on both for capymoa.ocl.util._optim.reset_optimizer_state and capymoa.ocl.util._buffer_list.BufferList.
  • Cherry-picks the Memory Aware Synapses (MAS) continual learning strategy from the blurry-ocl draft branch, adapting it to the current capymoa.ocl module layout.
  • Drops the draft's ReplayBuilder abstraction and capymoa.ocl.replay import (neither exist on main) in favour of using SlidingWindow from capymoa.ocl.util._replay directly, matching EWC.
  • Inlines trainable_params/weighted_l2_reg instead of importing them from _ewc, whose current signature no longer matches what the draft's (diverged) _ewc.py had. This also matches the self-contained pattern EWC and SI already follow, rather than adding cross-file coupling between strategies.
  • Adds a proper class docstring with a citation, and documents __init__ parameters, matching EWC/SI's docstring conventions.
  • Renames on_train_task/on_test_task to _on_train_task_begin/_on_test_task_begin and has attach_with return self, for consistency with SI and LWF.
  • Registers MAS in capymoa.ocl.strategy.__init__.
  • Adds masked and unmasked MAS cases to tests/ocl/test_strategy.py.

Closes adaptive-machine-learning/backlog#147

Assisted-by: claude-code:claude-sonnet-5

Memory Aware Synapses (MAS) is a regularisation-based continual
learning strategy that estimates per-parameter importance from the
sensitivity of the model's output (rather than the task loss) to
small parameter perturbations, then penalises changes to parameters
that were important for previous tasks (Aljundi et al., 2018).

Ported from the `blurry-ocl` draft branch and adapted to the current
`capymoa.ocl` module layout. Also:

* Drops the draft's `ReplayBuilder` abstraction and `capymoa.ocl.replay`
  import (neither exist on `main`) in favour of using `SlidingWindow`
  from `capymoa.ocl.util._replay` directly, matching EWC.
* Inlines `trainable_params`/`weighted_l2_reg` instead of importing
  them from `_ewc`, whose current signature no longer matches (the
  draft's `_ewc.py` had since diverged from what actually shipped).
  This also matches the self-contained pattern EWC and SI already
  follow, rather than adding cross-file coupling between strategies.
* Adds a proper class docstring with a citation, and documents
  `__init__` parameters, matching EWC/SI's docstring conventions.
* Renames `on_train_task`/`on_test_task` to `_on_train_task_begin`/
  `_on_test_task_begin` and has `attach_with` return `self`, for
  consistency with SI and LWF.

Stacked on `feat/ocl-lwf` (#404), which is in turn stacked on
`feat/ocl-si` (#403); this PR depends on both for
`capymoa.ocl.util._optim.reset_optimizer_state` and
`capymoa.ocl.util._buffer_list.BufferList`.

Assisted-by: claude-code:claude-sonnet-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant