Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qp #1606

Merged
merged 8 commits into from
Feb 27, 2024
Merged

Qp #1606

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
7 changes: 5 additions & 2 deletions avalanche/training/plugins/gem.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Dict
import numpy as np
import quadprog
import qpsolvers
import torch
from torch import Tensor
from torch.utils.data import DataLoader
Expand Down Expand Up @@ -171,7 +171,10 @@ def solve_quadprog(self, g):
q = np.dot(memories_np, gradient_np) * -1
G = np.eye(t)
h = np.zeros(t) + self.memory_strength
v = quadprog.solve_qp(P, q, G, h)[0]
# solution with old quadprog library, same as the author's implementation
# v = quadprog.solve_qp(P, q, G, h)[0]
# using new library qpsolvers
v = qpsolvers.solve_qp(P=P, q=-q, G=-G.transpose(), h=-h, solver="quadprog")
v_star = np.dot(v, memories_np) + gradient_np

return torch.from_numpy(v_star).float()
11 changes: 0 additions & 11 deletions docker/Dockerfile_dev
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
# syntax=docker/dockerfile:1

FROM nvcr.io/nvidia/pytorch:23.09-py3

# Needed for quadprog
RUN apt-get update && apt-get install -y \
build-essential \
&& rm -rf /var/lib/apt/lists/*

ADD requirements.txt .

# RUN pip install virtualenv
# RUN python -m venv local_venv
# RUN source local_venv/bin/activate
RUN pip install -r requirements.txt

SHELL ["/bin/bash", "--login", "-c"]
7 changes: 0 additions & 7 deletions docker/nightly/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
# syntax=docker/dockerfile:1

FROM continualai/avalanche-test-3.9:latest

# Needed for quadprog
RUN apt-get update && apt-get install -y \
build-essential \
&& rm -rf /var/lib/apt/lists/*

RUN echo "conda activate avalanche-env" >> ~/.bashrc
SHELL ["/bin/bash", "--login", "-c"]

RUN pip install git+https://github.com/ContinualAI/avalanche.git
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ torchmetrics
gdown
dill
packaging
quadprog @ git+https://github.com/HKaras/quadprog.git@690081f3285d4eb554394209473a274f230cd9ba
qpsolvers
Loading