You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Global preserved rank (applies to all target modules)
95
+
config = OSFConfig(effective_rank=16)# preserves top-16 singular directions; trains the rest
96
96
97
-
# Automatic rank (50% of the smaller matrix dimension per target)
97
+
# Automatic preserved rank (50% of the smaller matrix dimension per target)
98
98
config = OSFConfig(effective_rank=None)
99
99
100
-
# Per-module rank overrides
100
+
# Per-module preserved-rank overrides
101
101
config = OSFConfig(
102
102
effective_rank=8,
103
103
rank_pattern={
@@ -107,6 +107,9 @@ config = OSFConfig(
107
107
)
108
108
```
109
109
110
+
Note: OSF's `effective_rank` is the preserved (frozen) rank, not the trainable rank. The trainable rank equals `min(weight.shape) - effective_rank`. This differs from LoRA's `r`, which directly specifies the trainable rank.
111
+
112
+
110
113
## Training Advice for Continual Learning
111
114
112
115
### Sequential Task Learning
@@ -120,13 +123,13 @@ model = get_peft_model(base_model, OSFConfig(effective_rank=r))
120
123
train_task(model, task_1_data)
121
124
122
125
# Task 2: recompute SVD on updated weights and increase preserved subspace
123
-
base_model = model.base_model.model# unwrap updated base
126
+
base_model = model.unload()# unwrap base model without assuming internals
124
127
r +=4# grow preserved subspace to include Task 1 knowledge
125
128
model = get_peft_model(base_model, OSFConfig(effective_rank=r))
126
129
train_task(model, task_2_data)
127
130
128
131
# Task 3: recompute again and expand preserved subspace further
129
-
base_model = model.base_model.model
132
+
base_model = model.unload()
130
133
r +=4
131
134
model = get_peft_model(base_model, OSFConfig(effective_rank=r))
132
135
train_task(model, task_3_data)
@@ -146,23 +149,23 @@ This approach ensures each task gets adequate learning capacity while progressiv
146
149
```python
147
150
# Example: 4-task sequence with progressive budget allocation
148
151
n_tasks =4
149
-
base_rank=32#Starting rank for full capacity
152
+
max_preserved_rank=512#Upper bound for preserved rank per target (heuristic)
150
153
151
154
for task_id inrange(n_tasks):
152
-
# Calculate remaining capacity for current task
153
-
freeze_fraction = task_id / n_tasks
154
-
remaining_capacity =1.0- freeze_fraction
155
-
current_rank =int(base_rank * remaining_capacity)
156
-
155
+
# Freeze increases over time; trainable capacity shrinks
0 commit comments