22 Commits

Author SHA1 Message Date
b5ace6a8c4 CHORE: Clean up config kwargs in custom model tests (#2736)
Resolves #2695

For some PEFT methods, there was a bit of a mess when it comes to how
the init_weights argument was set in test_custom_models.py. The default
kwargs for the tests should be that the PEFT method is initialized as an
identity transform, and for specific tests we want to disable that. Note
that most PEFT methods are initialized by default to be identity
transforms, which is why the argument does not need to be set
explicitly, but it's not true for all PEFT methods.

With this PR, SHiRA, C3A, and FourierFT are now initialized to be
consistent with this. This made it possible to remove some extra
handling of those methods which was intermingled with certain tests.

Moreover, test_custom_models.py now uses the set_init_weights_false
helper function where appropriate.

While working on this, I also cleaned up a bit the docs for the
init_weights arguments of these PEFT methods where appropriate.

I added some clarifying comments.

For test_unload_adapter, I simplified a config type check and
rewrote it to load the base model only once.

---------

Co-authored-by: githubnemo <githubnemo@users.noreply.github.com>
2025-08-19 11:55:25 +02:00
44f001c695 Use hub_online_once in trainable token tests (#2701)
Also fix a minor import nit where `TrainableTokensWrapper` was not
added to `utils/__init__.py`. Fixed the corresponding imports as well.

Another housekeeping job is to move hub_online_once to testing_utils.py since it has 
grown to be used in a lot of places and testing_utils.py is the better place to keep 
such utilities.
2025-08-05 12:58:55 +02:00
a4f9334f12 FEAT Add SHiRA Adapters (#2584)
Implements: Sparse High Rank Adapters

Paper: https://arxiv.org/abs/2406.13175
2025-07-14 11:16:10 +02:00
6d133307ad align xpu behavior w/ cuda (#2551)
* align xpu behavior w/ CUDA in lorafa

for lorafa and randlora: i can see peft requirement torch >=1.13, and in 1.13, torch already has a device agnostic torch.autocast, switch to use the device agnostic API to also cover xpu

clean codes in tests folder to use device agnostic clean cache API. Before this PR, some test cases use device-agnostic clean cache API, some use torch.cuda.xx; after this PR, all use device-agnostic clean cache API

enable gptqmodel multi-device test case on XPU, enable torchao test cases on XPU

* randlora default dtype to bfloat16, align CUDA behavior
* refine randlora&vblora test, refine bnb test skip message
* enable torchao tests on XPU, all passed on torchao 0.11.0
* use accelerate utils
2025-06-02 17:23:42 +02:00
f7cda1f924 TST Make DoRA tests pass on XPU (#2493) 2025-04-17 12:38:06 +02:00
5e9ee26e79 TST Refactor (continued) of encoder tests (#2478) 2025-04-10 10:53:44 +02:00
8c8b529b31 CI: More caching in tests to avoid 429 (#2472) 2025-04-02 18:09:31 +02:00
6e30991e97 FEAT Add gptqmodel support (#2247)
Add support for gptqmodel quantization. This is a replacement for
auto-gptq.

For now, both packages are supported, but since auto-gptq is no longer
being developed, it will be deprecated and removed at some point in the
future.

---------

Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
Co-authored-by: LRL-ModelCloud <165116337+LRL-ModelCloud@users.noreply.github.com>
Co-authored-by: Qubitium-ModelCloud <qubitium@modelcloud.ai>
Co-authored-by: ZX-ModelCloud <165115237+ZX-ModelCloud@users.noreply.github.com>
Co-authored-by: LRL <lrl@lbx.dev>
Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
2025-01-23 14:00:11 +01:00
9918977ecf FEAT: Support torchao (#2062)
Supports torch AO quantization. Currently supported:

- int8_weight_only
- int8_dynamic_activation_int8_weight

---------

Co-authored-by: Marc Sun <57196510+SunMarc@users.noreply.github.com>
2024-10-08 18:10:19 +02:00
f5dd2acfed TST Skip some quantization tests on XPU (#2074)
Eetq/hqq/aqlm don't support XPU yet.
2024-09-18 11:27:19 +02:00
c3b63ce2c4 ENH Test and DoRA compatibility with XPU 2024-08-23 16:01:50 +02:00
6c832c1dd4 TST Make TestModelAndLayerStatus device-agnostic (#2026) 2024-08-21 12:43:35 +02:00
02ae6bcb37 Add LoRA support to HQQ Quantization (#1618)
* Add HQQ Lora

* fix error weight load

* Remove unused

* Add quantized lora

* fix make HQQLinear

* Fix dtype

* Revert back quantize lora

* Add prepare training for hqq quantization

* Forget revert hqq

* Remove warnings

* Other ways to check hqq quantization

* Add unit test for training

* change bfloat16 to float16

* Fix load weight when applied dora

* Move import hqq inside if clause

* Naming using CamelCase

* Remove unused function and fix naming convention

* Pop offload_meta

* Add use_dora params

* Remove confusing comments

* Additional test for checking output from HQQ

* Add license notice

* Add parameter decorator

* Redundant calling get_base_layer

* do make style

* Remove unused comments

* Move dispatch_hqq out of if clause

* make style all scripts

* Add comment for explanation

* Mention HQQ to docs

* Add HQQ to Dockerfile

* Fix styling

* Styling scripts

* Comply with transformers HQQ integration

* Test fully using transformers

* Add comments handling HQQ

* Fix naming problem
2024-05-03 15:43:26 +02:00
d0fa70aeb6 FEAT: Add EETQ support in PEFT (#1675)
* v1

* fix tests'

* fix unneeded change

* fix unneeded change

* fix unneeded change

* fix

* fix CI

* fix docker image

* fix docker image

* add docs

* lazy import

* raise when merge

* raise when merge

* Update eetq.py

* merge

* style

* add unmerge

* indent

* Update docs/source/developer_guides/quantization.md

Co-authored-by: Benjamin Bossan <BenjaminBossan@users.noreply.github.com>

* add details about transformers

---------

Co-authored-by: Benjamin Bossan <BenjaminBossan@users.noreply.github.com>
2024-04-26 10:20:18 +02:00
23213cad8d AQLM support for LoRA (#1476)
* aqlm

* Style and copied tests

* aqlm import guadr

* docs

* correct model in tests

* Update docs/source/developer_guides/quantization.md

Co-authored-by: Benjamin Bossan <BenjaminBossan@users.noreply.github.com>

* Update docs/source/developer_guides/quantization.md

Co-authored-by: Benjamin Bossan <BenjaminBossan@users.noreply.github.com>

* moved aqlm install and added >=

* Removed `quant_linear_module`

* AqlmLoraLinear

* docs update

* transformers version check

---------

Co-authored-by: Benjamin Bossan <BenjaminBossan@users.noreply.github.com>
2024-02-22 02:31:04 +01:00
65513e5db4 FEAT: add awq suppot in PEFT (#1399)
* add awq suppot in PEFT

* fix

* fux

* Update src/peft/tuners/lora/awq.py

* style & fix tests

* forward contrib credits from PR14084

* forward contrib credits from autoawq PR

* change name

* fix

* change to peft internal testing

* fix

* fix

* add multi-GPU tests

* add to dockerfile

* fix todo

* raise error only at the dispatch level

* quality

* fix test

* fix dockerfile

* fix

* fix

* update dockerfile and tests

---------

Co-authored-by: s4rduk4r <s4rduk4r@users.noreply.github.com>
2024-02-19 01:31:21 +01:00
fc78a2491e MNT Move code quality fully to ruff (#1421) 2024-02-07 12:52:35 +01:00
fc9f4b3176 Bnb integration test tweaks (#1242)
* allow bitsandbytes integration test selection

* fix typo: mutli -> multi

* enable tests to run on >2 GPUs

* fix for >3 GPUs, due to artidoro/qlora #186

* fix formatting
2023-12-08 13:20:13 +01:00
39264a0141 Fix some tests that would fail with torch.compile (#949)
Some tests would currently fail with torch.compile, not because there is
anything wrong with how PEFT works with compiled models, but simply
because of the way the tests are written. This is because when models
are compiled, the keys of the state dict change. Tests have now been
adapted to unwrap the compiled model first before getting the state
dict.

Note that the mentioned issue does not affect saving and loading,
because save_pretrained is already called on the original module, so
there is no issue with mismatched keys.

Also fixed the docstring of get_peft_model_state_dict.
2023-09-21 09:46:28 +02:00
a916465ad0 GPTQ Integration (#771)
* add gptq lora

* fix peft gptq

* fix condition

* fix test

* remove unused weights

* check type

* style

* change attribute

* remove print

* add exllama

* make style

* refactor + fix tests

* remove print

* remove dep on transformers
2023-08-11 17:31:17 -04:00
66fd087205 [Bugfix] Fixed LoRA conv2d merge (#637)
* Fixed LoRA conv2d merge

* Fixed typo
2023-06-27 12:18:08 +05:30
2632e7eba7 [CI] Add ci tests (#203)
* add ci tests

* fix some tests

* fix tests

* rename

* fix

* update tests

* try

* temp hotfix

* refactor tests

* Update .github/workflows/tests.yml

* fix test
2023-03-23 12:38:40 +01:00