Skip to content

Commit

Permalink
Bugfix to adapters: incorrect key caused adapters to not be applied.
Browse files Browse the repository at this point in the history
Interestingly, random projection seems to get pretty far in the toy
tasks, so this was not immediately obvious. The bug was detected by
observing that the adapter parameters did not change during training.
  • Loading branch information
Waino committed Nov 18, 2024
1 parent 162e675 commit d3d0ee0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mammoth/modules/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ def is_wrapper(self):

def apply(self, tmp_layer_types, tmp_layer_structs, tmp_layer_dropouts):
# LoraAdapterLayer wraps the existing feedforward. No norms are added.
tmp_layer_structs[0][1] = self.wrap(tmp_layer_structs[0][1])
return tmp_layer_types, tmp_layer_structs, tmp_layer_dropouts
new_layer_structs = [nn.ModuleList(x) for x in tmp_layer_structs]
new_layer_structs[0][1] = self.wrap(new_layer_structs[0][1])
return tmp_layer_types, new_layer_structs, tmp_layer_dropouts

def wrap(self, base_layer):
self.wrapped_base_layer = base_layer
Expand Down Expand Up @@ -201,7 +202,7 @@ def _inject_adapters(self):
):
if layer_type == 'f':
# Adapters apply to feedforward layers
adapter_layers = adapter_layers_by_index[i]
adapter_layers = adapter_layers_by_index[f'layer{i}']
tmp_layer_types = [layer_type]
tmp_layer_structs = [layer_struct]
tmp_layer_dropouts = [layer_dropout]
Expand Down

0 comments on commit d3d0ee0

Please sign in to comment.