mirror of
https://github.com/ml-explore/mlx-examples.git
synced 2025-09-01 12:49:50 +08:00
chore(lora): support mixtral in lora example (#343)
This commit is contained in:
@@ -315,6 +315,8 @@ if __name__ == "__main__":
|
||||
for l in model.model.layers[len(model.model.layers) - args.lora_layers :]:
|
||||
l.self_attn.q_proj = LoRALinear.from_linear(l.self_attn.q_proj)
|
||||
l.self_attn.v_proj = LoRALinear.from_linear(l.self_attn.v_proj)
|
||||
if hasattr(l, "block_sparse_moe"):
|
||||
l.block_sparse_moe.gate = LoRALinear.from_linear(l.block_sparse_moe.gate)
|
||||
|
||||
p = sum(v.size for _, v in tree_flatten(model.parameters())) / 10**6
|
||||
print(f"Total parameters {p:.3f}M")
|
||||
@@ -349,7 +351,7 @@ if __name__ == "__main__":
|
||||
|
||||
if args.test:
|
||||
print("Testing")
|
||||
|
||||
model.eval()
|
||||
test_loss = evaluate(
|
||||
model,
|
||||
test_set,
|
||||
|
Reference in New Issue
Block a user