Run matched rank allocation and trajectory distillation experiments for LiSA
This commit is contained in:
@@ -77,12 +77,13 @@ def checkpoint(path, obj):
|
||||
pending.replace(path)
|
||||
|
||||
|
||||
def train(model, tokenizer, out, split, epochs, rank):
|
||||
c = model.config
|
||||
rope = c['rope_parameters']
|
||||
adapters = {i: LearnableSharingAttention(c['hidden_size'], c['num_attention_heads'],
|
||||
c['num_key_value_heads'], rank, rope['rope_theta'], rope['partial_rotary_factor'],
|
||||
bias=c.get('attention_bias', False)) for i in model.sites}
|
||||
def train(model, tokenizer, out, split, epochs, rank, *, adapters=None, captures=None):
|
||||
if adapters is None:
|
||||
c = model.config
|
||||
rope = c['rope_parameters']
|
||||
adapters = {i: LearnableSharingAttention(c['hidden_size'], c['num_attention_heads'],
|
||||
c['num_key_value_heads'], rank, rope['rope_theta'], rope['partial_rotary_factor'],
|
||||
bias=c.get('attention_bias', False)) for i in model.sites}
|
||||
tail = TorchTail(model, model.sites[0], adapters)
|
||||
optim = torch.optim.AdamW(tail.parameters(), lr=.0003, weight_decay=.1)
|
||||
last = out/'resume.pt'
|
||||
@@ -101,7 +102,7 @@ def train(model, tokenizer, out, split, epochs, rank):
|
||||
yield start, w
|
||||
start += len(w)
|
||||
|
||||
paths = sorted((out/'fit-capture').glob('*.npz'))
|
||||
paths = sorted((captures or out/'fit-capture').glob('*.npz'))
|
||||
for epoch in range(state['epoch'], epochs):
|
||||
for path in paths[len(state['steps']):]:
|
||||
with np.load(path, allow_pickle=False) as entry:
|
||||
|
||||
Reference in New Issue
Block a user