Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/peft/tuners/adalora/bnb.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def __init__(
adapter_name: str,
config: AdaLoraConfig,
r: int = 0,
lora_alpha: int = 1,
**kwargs,
) -> None:
super().__init__()
Expand All @@ -97,7 +98,7 @@ def __init__(
self.get_base_layer().weight.requires_grad = False

self._active_adapter = adapter_name
self.update_layer(adapter_name, r, config=config)
self.update_layer(adapter_name, r, lora_alpha, config=config)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not so sure the reason here, especially it passes a new positional argument. It won't break something?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just so that it is compatible with all the other update_layer definitions - the parameter was simply forgotten in PR #2960. Adding lora_alpha restores compatibility.


def forward(self, x: torch.Tensor, *args: Any, **kwargs: Any) -> torch.Tensor:
# note: no check for self.merged because merging is not supported (yet)
Expand Down
4 changes: 2 additions & 2 deletions src/peft/tuners/adalora/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def _create_new_module(lora_config, adapter_name, target, device_map=None, **kwa
"index": target_base_layer.index,
}
)
new_module = SVDLinear8bitLt(target, adapter_name, **kwargs)
new_module = SVDLinear8bitLt(target, adapter_name, config=lora_config, **kwargs)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is SVDLinear8bitLt defined in peft? If so, Just make sure we handle the deprecation etc.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, indeed! However, we consider this not part of the public API, otherwise #2960 would have needed to do that in the first place, this is just a patch to fix places where the change from #2960 was forgotten.

elif loaded_in_4bit and is_bnb_4bit_available() and isinstance(target_base_layer, bnb.nn.Linear4bit):
fourbit_kwargs = kwargs.copy()
fourbit_kwargs.update(
Expand All @@ -191,7 +191,7 @@ def _create_new_module(lora_config, adapter_name, target, device_map=None, **kwa
"quant_type": target_base_layer.weight.quant_type,
}
)
new_module = SVDLinear4bit(target, adapter_name, **fourbit_kwargs)
new_module = SVDLinear4bit(target, adapter_name, config=lora_config, **fourbit_kwargs)
elif QuantLinear is not None and isinstance(target, QuantLinear):
new_module = SVDQuantLinear(target, adapter_name, **kwargs)
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gpu_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -4133,7 +4133,7 @@ def test_causal_lm_training_single_gpu_torchao_dora_int8_dynamic_activation_int8
@pytest.mark.single_gpu_tests
@pytest.mark.xfail(
reason="int4_weight_only still has issues",
raises=RuntimeError,
raises=(RuntimeError, ValueError),
)
def test_causal_lm_training_single_gpu_torchao_int4_raises(self):
# TODO: Once proper torchao support for int4 is added, remove this test and add int4 to supported_quant_types
Expand Down
Loading