Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to prefix tuning to fit transformers #2096

Merged

Commits on Sep 25, 2024

  1. Configuration menu
    Copy the full SHA
    7c8e287 View commit details
    Browse the repository at this point in the history

Commits on Oct 22, 2024

  1. Update src/peft/peft_model.py

    Co-authored-by: Raushan Turganbay <[email protected]>
    BenjaminBossan and zucchini-nlp authored Oct 22, 2024
    Configuration menu
    Copy the full SHA
    b666532 View commit details
    Browse the repository at this point in the history
  2. FIX: Change check if past_key_values is empty (huggingface#2106)

    After transformers merged this PR:
    
    huggingface/transformers#33703
    
    The bool of past_key_values (a Cache instance) would change from False
    to True in one of our checks. Use get_seq_length() method instead, which
    is consistent before and after that commit.
    
    I checked the tests with the new change for both transformers before and
    after that commit and they passed, so this change should be backwards
    compatible.
    
    Unrelated change: Mark X-LoRA scaling test as xfail-ing for now.
    
    This should be addressed in a separate PR. Marking it to xfail for now
    to get the original fix through CI.
    BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    73496ee View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    d60d1b6 View commit details
    Browse the repository at this point in the history
  4. FIX Refactor OFT, small changes to BOFT (huggingface#1996)

    The previous OFT implementation contained a few errors, which are fixed now.
    
    Unfortunately, this makes previous OFT checkpoints invalid, which is why an
    error will be raised. Users are instructed to either retrain the OFT adapter or
    switch to an old PEFT version.
    Zeju1997 authored and BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    faa4dd8 View commit details
    Browse the repository at this point in the history
  5. ENH: Improved attribute access for modules_to_save (huggingface#2117)

    Resolves huggingface#2099
    
    So far, if a module was wrapped due to modules_to_save, we handled
    access to the weight and bias attribute (albeit incorrectly in case of
    disabled adapters!). However, there could be more attributes than those
    that could be accessed, in which case we got an error so far.
    
    Instead of special properties, we now implement a generic __getattr__
    method that can deal with any attribute. The implementation is a bit
    complex to take into account the way that torch.nn.Module handles
    __getattr__.
    BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    5cd5a45 View commit details
    Browse the repository at this point in the history
  6. FIX low_cpu_mem_usage consolidates devices (huggingface#2113)

    See: huggingface/diffusers#9510 (comment)
    
    Right now, the low_cpu_mem_usage=True option does not consolidate the
    devices. E.g. when the model is on GPU and the state_dict on CPU, the
    adapter weight will be on CPU after loading, when it should be GPU. This
    fix ensures that the devices are consolidated.
    BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    0312b30 View commit details
    Browse the repository at this point in the history
  7. TST Mark flaky X-LoRA test as xfail (huggingface#2114)

    Currently, CI is failing constantly because one of the X-LoRA tests has
    become flaky lately, most likely caused by the transformers 4.45.0
    release. Therefore, this test is now marked to non-strictly xfail.
    
    I cannot reproduce this error locally, neither on CPU nor GPU. It is
    thus unclear how to fix this test.
    BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    4c50892 View commit details
    Browse the repository at this point in the history
  8. ENH: Warn when from_pretrained misses PEFT keys (huggingface#2118)

    After merging huggingface#2084, we now clean up the missing_keys when loading a
    PEFT adapter to remove all but the relevant keys (the fact that base
    model keys are missing is expected when loading a PEFT adapter).
    
    Since the presence of missing_keys now really means that something might
    have gone wrong during loading, we can now warn the user if they call
    PeftModel.from_pretrained.
    
    Note that load_adapter still does not warn, as here we return the
    load_result and users can already check, but for from_pretrained, they
    don't have that possibility.
    BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    8699ba4 View commit details
    Browse the repository at this point in the history
  9. FEAT: Adding exclude modules param(huggingface#2044) (huggingface#2102)

    Allows to exclude target modules.
    JINO-ROHIT authored and BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    9ddc9f1 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    5a560da View commit details
    Browse the repository at this point in the history
  11. FEAT: VeRA quantization using bitsandbytes (huggingface#2070) (huggin…

    …gface#2076)
    
    VeRA can now be used with 4bit and 8bit bnb quantization.
    ZiadHelal authored and BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    d10151e View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    1d55d8b View commit details
    Browse the repository at this point in the history
  13. FEAT: Support torchao (huggingface#2062)

    Supports torch AO quantization. Currently supported:
    
    - int8_weight_only
    - int8_dynamic_activation_int8_weight
    
    ---------
    
    Co-authored-by: Marc Sun <[email protected]>
    BenjaminBossan and SunMarc committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    98cf284 View commit details
    Browse the repository at this point in the history
  14. FIX: PiSSA now works with Conv1D layers (huggingface#2103) (huggingfa…

    …ce#2104)
    
    Transpose weight matrix based on fan_in_fan_out condition in PiSSA
    initialization.
    
    Co-authored-by: Yang Su <[email protected]>
    2 people authored and BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    7961e8c View commit details
    Browse the repository at this point in the history
  15. FIX Type annoations in vera/bnb.py (huggingface#2139)

    The file was missing the from __future__ import annotations part. As
    this code is only running nightly with GPU, the normal CI missed this
    omission.
    BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    fe8ba8e View commit details
    Browse the repository at this point in the history
  16. ENH Make PEFT configs forward compatible (huggingface#2038)

    Right now, loading a PEFT config saved with a more recent PEFT version
    than is currently installed will lead to errors when new arguments are
    added to the config in the newer PEFT version. The current workaround is
    for users to manually edit the adapter_config.json to remove those
    entries.
    
    With this PR, PEFT will make an attempt at removing these unknown keys
    by inspecting the signature. The user will be warned about these removed
    keys. This should generally be a safe measure because we will generally
    not introduce new config settings that change the default behavior.
    However, if a non-default is used, this could lead to wrong results.
    This is mentioned in the warning.
    
    While working on the tests, I also converted the unittest.TestCase to a
    normal pytest test in order to be able to use pytest fixtures.
    
    I also plan on adding the PEFT version to the adapter_config.json in the
    future. This will allow us to better handle compatibility issues in the
    future. As adding that new key to all PEFT configs could cause a lot of
    disruption, I want to get this PR in first to ensure forward
    compatibility.
    
    Note that this new mechanism will not help anyone using a PEFT version
    < 0.14.0, so this will be a slow transition.
    BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    171cc75 View commit details
    Browse the repository at this point in the history
  17. FIX Raise mixed adapter infer with missing adapter (huggingface#2090)

    PEFT allows mixed batch adapter inference, i.e. when predicting, the
    same batch can use different adapters by passing the adapter_names
    argument. However, when users pass an adapter name that does not
    correspond to any of the existing adapters, these samples are currently
    being ignored (i.e. just the base model output is used). This is
    unexpected and can easily lead to errors, e.g. when users mistype the
    name of an adapter.
    
    This PR fixes this issue by checking all the existing adapter names
    first and comparing them to the adapter_names that the user passed. If
    there are unexpected entries, an error is raised.
    
    Due to this fix, an error in the test
    test_mixed_adapter_batches_lora_merged_raises was discovered and
    promptly fixed.
    BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    858e1d2 View commit details
    Browse the repository at this point in the history
  18. FIX Prompt learning with latest transformers error (huggingface#2140)

    The error in PEFT is occurring after this transformers change:
    
    huggingface/transformers#33870
    
    Now, in our tests, some model_kwargs no longer necessarily contain
    past_key_values, resulting in a KeyError. We now account for this
    possibility. Affected models were opt and gpt2.
    BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    b494d0e View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    f2d40e7 View commit details
    Browse the repository at this point in the history
  20. FIX TST NaN issue with HQQ GPU test (huggingface#2143)

    This test calculates the correlation coefficient of HQQ model outputs.
    Although the model outputs are finite, the resulting matrix contains
    NaNs. Casting the outputs from 16 to 32 bit precision resolves the
    issue.
    BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    7e5519a View commit details
    Browse the repository at this point in the history
  21. FIX Bug in target module optimization if suffix (huggingface#2144)

    Solves the following bug:
    
    huggingface/diffusers#9622 (comment)
    
    The cause for the bug is as follows: When we have, say, a module called
    "bar.0.query" that we want to target and another module called
    "foo_bar.0.query" that we don't want to target, there was potential for
    an error. This is not caused by _find_minimal_target_modules directly,
    but rather the bug was inside of BaseTuner.inject_adapter and how the
    names_no_target were chosen. Those used to be chosen based on suffix. In
    our example, however, "bar.0.query" is a suffix of "foo_bar.0.query",
    therefore "foo_bar.0.query" was *not* added to names_no_target when it
    should have. As a consequence, during the optimization, it looks like
    "query" is safe to use as target_modules because we don't see that it
    wrongly matches "foo_bar.0.query".
    BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    d0c22b3 View commit details
    Browse the repository at this point in the history
  22. Bump version to 0.13.2.dev0 (huggingface#2145)

    After the patch release of PEFT v0.13.2, let's bump the dev version of
    PEFT to v0.13.3.dev0 so that it stays ahead (the bugfix from the patch
    release is already contained in the main branch).
    BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    3d205bc View commit details
    Browse the repository at this point in the history
  23. FIX Don't assume past_key_valus for encoder models (huggingface#2149)

    Don't assume that past_key_values is part of the model_kwargs.
    
    This fix is similar to huggingface#2140 but for encoder-decoder models. It became
    necessary after huggingface/transformers#34048
    was merged into transformers.
    BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    7dfd956 View commit details
    Browse the repository at this point in the history
  24. FIX Use SFTConfig instead of SFTTrainer keyword args (huggingface…

    …#2150)
    
    Update training script using trl to fix deprecations in argument usage.
    qgallouedec authored and BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    e74a6b9 View commit details
    Browse the repository at this point in the history
  25. make style

    BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    f481c5d View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    9b223ea View commit details
    Browse the repository at this point in the history

Commits on Oct 23, 2024

  1. Some further fixes

    One test still failing
    BenjaminBossan committed Oct 23, 2024
    Configuration menu
    Copy the full SHA
    2d6f2fb View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f20652b View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    79250cc View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    bb6131a View commit details
    Browse the repository at this point in the history