{"id":23031252,"url":"https://github.com/thomas-bouvier/distributed-continual-learning","last_synced_at":"2025-10-06T16:59:56.404Z","repository":{"id":162527214,"uuid":"636867780","full_name":"thomas-bouvier/distributed-continual-learning","owner":"thomas-bouvier","description":"Towards Rehearsal-based Continual Learning at Scale: distributed CL using Horovod + PyTorch on up to 128 GPUs","archived":false,"fork":false,"pushed_at":"2024-10-21T14:32:03.000Z","size":952,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-23T17:51:38.662Z","etag":null,"topics":["continual-learning","data-parallelism","deep-learning","experience-replay","hpc","ptychography","rehearsal"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomas-bouvier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-05T20:53:14.000Z","updated_at":"2024-12-09T22:30:12.000Z","dependencies_parsed_at":"2024-03-02T14:24:24.994Z","dependency_job_id":"a52ca231-d31b-4eb9-828b-318252866894","html_url":"https://github.com/thomas-bouvier/distributed-continual-learning","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/thomas-bouvier/distributed-continual-learning","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-bouvier%2Fdistributed-continual-learning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-bouvier%2Fdistributed-continual-learning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-bouvier%2Fdistributed-continual-learning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-bouvier%2Fdistributed-continual-learning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomas-bouvier","download_url":"https://codeload.github.com/thomas-bouvier/distributed-continual-learning/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-bouvier%2Fdistributed-continual-learning/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278646773,"owners_count":26021511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["continual-learning","data-parallelism","deep-learning","experience-replay","hpc","ptychography","rehearsal"],"created_at":"2024-12-15T15:35:23.861Z","updated_at":"2025-10-06T16:59:56.388Z","avatar_url":"https://github.com/thomas-bouvier.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# distributed-continual-learning\n\nThis is a PyTorch + Horovod implementation of the continual learning experiments with deep neural networks described in the following article:\n\n* [Three types of incremental learning](https://www.nature.com/articles/s42256-022-00568-3) (2022, *Nature Machine Intelligence*)\n\nContinual learning approaches implemented here are based on rehearsal, which is delegated in a separate high-performance C++ backend [Neomem](https://github.com/thomas-bouvier/neomem).\n\nThis repository primarily supports experiments in the academic continual learning setting, whereby a classification-based problem is split up into multiple, non-overlapping tasks that must be learned sequentially (class-incremental scenario). Instance-incremental scenarios are supported too.\n\nSome Python code has been inspired by the [mammoth](https://github.com/aimagelab/mammoth) and [convNet.pytorch](https://github.com/eladhoffer/convNet.pytorch/tree/master) repositories.\n\n## Installation\n\nThe current version of the code has been tested with Python 3.10 with the following package versions:\n\n* `pytorch 2.2`\n* `timm 0.9.2`\n* `horovod 0.28.1`\n* `continuum 1.2.7`\n* `nvidia-dali-cuda110 1.27.0` (optional)\n\nMake sure to install [Neomem](https://github.com/thomas-bouvier/neomem) to benefit from global sampling of representatives. If not available, this code will fallback to a Python, local, low performance rehearsal buffer implementation.\n\nIf Neomem is installed outside of this directory, simlink it using `ln -s ../neomem cpp_loader`.\n\nFurther Python packages used are listed in requirements.txt. Assuming Python and pip are set up, these packages can be installed using:\n\n```bash\npip install -r requirements.txt\n```\n\nIn an HPC environment, we strongly advise to use [Spack](https://github.com/spack/spack) to manage dependencies.\n\n## Usage\n\nParameters defined in the `config.yaml` override CLI parameters. However, values for `backbone_config`, `buffer_config`, `tasksets_config` will be concatenated with those defined by CLI, instead of override them ;\n\nValues for `optimizer_regime` will override regimes defined by `backbone/` in Python.\n\n| Parameter name | Required | Description | Possible values |\n|---|---|---|---|\n| `--backbone` | Yes | DL backbone model to instanciate  | `mnistnet`, `resnet18`, `resnet50`, `mobilenetv3`, `efficientnetv2`, `convnext`, `ghostnet`, `ptychonn` |\n| `--backbone-config` |   | Backbone-specific parameters  | `\"{'lr': 0.01, 'lr_min': 1e-6, }\"` |\n| `--model` | Default: `Vanilla` | Continual Learning strategy | `Vanilla`, `Er`, `Agem`, `Der`, `Derpp` |\n| `--model-config` |   | Reset strategies and CL model-specific parameters | `\"{'reset_state_dict': True}\"` allows to reset the model internal state between tasks\u003cbr\u003e`\"{'alpha': 0.2}\"` is needed for Der model\u003cbr\u003e`\"{'alpha': 0.2, 'beta': 0.8}\"` are needed for Derpp model |\n| `--buffer-config` |   | Rehearsal buffer parameters  |  `\"{'rehearsal_ratio': 20}\"` sets the proportion of the input dataset to be stored in the rehearsal buffer |\n| `--tasksets-config` |   | Scenario configuration, as defined in the [`continuum` package](https://continuum.readthedocs.io/en/latest/tutorials/scenarios/scenarios.html)  | Class-incremental scenario with 2 tasks: `\"{'scenario': 'class', 'initial_increment': 5, 'increment': 5}\"`\u003cbr\u003eInstance-incremental scenario with 2 tasks: `\"{'scenario': 'instance', 'num_tasks': 5}\"`\u003cbr\u003e`\"{'concatenate_tasksets': True}\"` allows to concatenate previous tasksets before next task |\n| `--dataset` |   | Dataset  | `mnist`, `cifar10`, `cifar100`, `tinyimagenet`, `imagenet`, `imagenet_blurred`, `ptycho` |\n\n### WandB sweeps\n\nTo run a hyperparameter search, first adapt the `sweep.py` (located in this directory) file if needed. Then, configure your optimization objective in `sweep.yaml`.\n\nMake sure you exported your WandB API key before running anything `export WANDB_API_KEY=key` and set `WANDB_MODE=run`. Once you are ready, execute the `sweep_launcher.sh \u003chostname\u003e \u003cwandb_project\u003e \u003csweep_conf\u003e [\u003cexisting_sweep_id\u003e]` script on the master machine, providing the following parameters:\n\n- `hostname`: the address of the current machine e.g., `chifflot-7.lille.grid5000.fr:1`\n- `wandb_project`: the name of an existing W\u0026B project where the run will be saved\n- `sweep_conf`: the name of a sweep config defined in `sweep.py`\n\nTo stop a sweep run, go to the online WandB dashboard and click \"Stop run\". To stop the whole sweep process, `ps aux | grep agent` on the machine and kill the process, then `ps aux | grep wandb` and kill that process too.\n\n## Continual Learning Strategies\n\nSpecific implementations have to be selected using `--buffer-config \"{'implementation': \u003cimplementation\u003e}\"`. ER with implementation `standard` was used in the paper.\n\n| Approach | Name | Available Implementations |\n|---|---|---|\n| Experience Replay (ER) | `Er` | `standard`, `flyweight`, `python` |\n| Averaged (A-GEM) | `Agem` | `python` |\n| Dark Experience Replay (DER) | `Der` | `standard`, `flyweight`, `python` |\n| Dark Experience Replay ++ (DER++) | `Derpp` | `standard`, `flyweight`, `python` |\n\n### Baselines\n\n#### From Scratch\n\n```\npython main.py --backbone \u003cbackbone_model\u003e --dataset \u003cdataset\u003e --model Vanilla --model-config \"{'reset_state_dict': True}\" --tasksets-config \"{\u003c..tasksets-config, 'concatenate_tasksets': True\u003e}\"\n```\n\n#### Incremental\n\n```\npython main.py --backbone \u003cbackbone_model\u003e --dataset \u003cdataset\u003e --model Vanilla --tasksets-config \"{\u003ctasksets-config\u003e}\"\n```\n\n## Examples\n\n### Deep learning\n\nUsual deep learning can be done using this project. Model `Vanilla` will be instanciated by default:\n\n```\npython main.py --backbone mnistnet --dataset mnist\npython main.py --backbone resnet18 --dataset cifar100\npython main.py --backbone resnet50 --dataset tinyimagenet\npython main.py --backbone efficientnetv2 --dataset imagenet_blurred\n```\n\n### Continual learning\n\n```\npython main.py --backbone mnistnet --dataset mnist --tasksets-config \"{'scenario': 'class', 'initial_increment': 5, 'increment': 5}\"\npython main.py --backbone resnet18 --dataset cifar10 --tasksets-config \"{'scenario': 'class', 'initial_increment': 4, 'increment': 3}\"\npython main.py --backbone resnet18 --model Er --dataset cifar100 --tasksets-config \"{'scenario': 'instance', 'num_tasks': 5}\"\npython main.py --backbone resnet18 --model Der --buffer-config \"{'rehearsal_ratio': 20}\" --dataset cifar10 --tasksets-config \"{'scenario': 'class', 'initial_increment': 4, 'increment': 3}\"\npython main.py --backbone resnet18 --model Derpp --buffer-config \"{'rehearsal_ratio': 20}\" --dataset imagenet100small --tasksets-config \"{'scenario': 'class', 'initial_increment': 40, 'increment': 30}\"\npython main.py --backbone resnet50 --model Agem --dataset tinyimagenet --tasksets-config \"{'scenario': 'instance', 'num_tasks': 5}\"\n```\n\n# Citation\n\n```\n@inproceedings{bouvier:hal-04600107,\n  TITLE = {{Efficient Data-Parallel Continual Learning with Asynchronous Distributed Rehearsal Buffers}},\n  AUTHOR = {Bouvier, Thomas and Nicolae, Bogdan and Chaugier, Hugo and Costan, Alexandru and Foster, Ian and Antoniu, Gabriel},\n  URL = {https://inria.hal.science/hal-04600107},\n  BOOKTITLE = {{CCGrid 2024 - IEEE 24th International Symposium on Cluster, Cloud and Internet Computing}},\n  ADDRESS = {Philadelphia (PA), United States},\n  PAGES = {1-10},\n  YEAR = {2024},\n  MONTH = May,\n  DOI = {10.1109/CCGrid59990.2024.00036},\n  KEYWORDS = {continual learning ; data-parallel training ; experience replay ; distributed rehearsal buffers ; asynchronous data management ; scalability},\n  PDF = {https://inria.hal.science/hal-04600107/file/paper.pdf},\n  HAL_ID = {hal-04600107},\n  HAL_VERSION = {v1},\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomas-bouvier%2Fdistributed-continual-learning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomas-bouvier%2Fdistributed-continual-learning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomas-bouvier%2Fdistributed-continual-learning/lists"}