Skip to content

Commit

Permalink
conditional bnb in lora+ tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kallewoof committed Jul 15, 2024
1 parent b719e18 commit bbefbec
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/test_loraplus_helper.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import bitsandbytes as bnb
import torch
from torch import nn

from peft.import_utils import is_bnb_available
from peft.optimizers import create_loraplus_optimizer

from .testing_utils import require_bitsandbytes


if is_bnb_available():
import bitsandbytes as bnb


class SimpleNet(nn.Module):
def __init__(self, bias=True):
Expand All @@ -21,6 +27,7 @@ def forward(self, X):
return X


@require_bitsandbytes
def test_lora_plus_helper_sucess():
model = SimpleNet()
optimizer_cls = bnb.optim.Adam8bit
Expand All @@ -46,6 +53,7 @@ def test_lora_plus_helper_sucess():
assert optim.param_groups[2]["lr"] == optim.param_groups[3]["lr"] == (optim_config["lr"] * loraplus_lr_ratio)


@require_bitsandbytes
def test_lora_plus_optimizer_sucess():
"""
Test if the optimizer is correctly created and step function runs without any exception
Expand Down

0 comments on commit bbefbec

Please sign in to comment.