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

[WIP] Add LoRA multihead attention module #1324

Open
wants to merge 47 commits into
base: main
Choose a base branch
from

Commits on Jan 5, 2024

  1. [WIP] Add LoRA multihead attention module

    For now, only works with _qkv_same_embed_dim=True.
    BenjaminBossan committed Jan 5, 2024
    Configuration menu
    Copy the full SHA
    49fab86 View commit details
    Browse the repository at this point in the history
  2. Make style

    BenjaminBossan committed Jan 5, 2024
    Configuration menu
    Copy the full SHA
    d8e9589 View commit details
    Browse the repository at this point in the history
  3. Remove commented code

    BenjaminBossan committed Jan 5, 2024
    Configuration menu
    Copy the full SHA
    0e188a3 View commit details
    Browse the repository at this point in the history
  4. Remove assignment of weight to new module

    This is no longer necessary when unloading the model because the
    base_layer is already the original layer. This is just a leftover
    from before we adopted the base_layer pattern.
    BenjaminBossan committed Jan 5, 2024
    Configuration menu
    Copy the full SHA
    b409d81 View commit details
    Browse the repository at this point in the history
  5. Make state_dict and named_parameters work

    There was a bug because the removal of the parameter resulted in it no
    longer appearing in the state_dict and named_parameters. This commit
    fixes this bug.
    
    The bug also exists in the referenced lora-torch library.
    BenjaminBossan committed Jan 5, 2024
    Configuration menu
    Copy the full SHA
    173062c View commit details
    Browse the repository at this point in the history

Commits on Jan 8, 2024

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

Commits on Jan 9, 2024

  1. Clean ups after reviewer feedback:

    - Some clarifying comments
    - Remove fan_in_fan_out
    
    Also:
    
    - Raise proper error instead of assert
    BenjaminBossan committed Jan 9, 2024
    Configuration menu
    Copy the full SHA
    557c4a1 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    add1f51 View commit details
    Browse the repository at this point in the history
  3. Make style

    BenjaminBossan committed Jan 9, 2024
    Configuration menu
    Copy the full SHA
    e44e030 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    8d62579 View commit details
    Browse the repository at this point in the history

Commits on Jan 12, 2024

  1. Apply LoRA also to the out_proj of MHA

    Before, LoRA was applied only to the in_proj. Now it is also applied to
    the out_proj.
    
    Unfortunately, there is no easy way to just apply a normal lora.Linear
    to the out_proj by targeting it with target_modules. If that worked, it
    would be much nicer to do that, so that users can decide for themselves
    if they want to apply LoRA to the out_proj or not.
    
    The reason why it doesn't work is twofold:
    
    1. We cannot really control the order in which LoRA is applied, so when
       the LoRA adapter is injected to out_proj, the whole MHA layer may
       already be wrapped by lora.MultiheadAttention.
    2. Even if we successfully applied a normal lora.Linear to the out_proj,
       it would not work correctly. This is because the forward method of
       out_proj is not used at all by nn.MultiheadAttention. Instead, it
       just passes the weight and bias to F.multi_head_attention_forward.
       Therefore, we must ensure that the weights are merged and unmerged
       correctly, same as for in_proj, and we cannot do that if we use a
       normal lora.Linear.
    
    Note that the test test_merge_layers for MHA fails. This is most likely
    because of an existing bug in now merging is implemented, see PR huggingface#1355.
    Once that is merged, the test should pass.
    BenjaminBossan committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    c5d8a6b View commit details
    Browse the repository at this point in the history

Commits on Feb 7, 2024

  1. Configuration menu
    Copy the full SHA
    9dc4a4d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c3fb2ce View commit details
    Browse the repository at this point in the history
  3. Fix failing tests

    BenjaminBossan committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    17d407b View commit details
    Browse the repository at this point in the history

Commits on Feb 26, 2024

  1. Configuration menu
    Copy the full SHA
    4cbf6e9 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e0cae11 View commit details
    Browse the repository at this point in the history
  3. Fix safe merging code

    BenjaminBossan committed Feb 26, 2024
    Configuration menu
    Copy the full SHA
    52c8d9b View commit details
    Browse the repository at this point in the history

Commits on Mar 11, 2024

  1. Configuration menu
    Copy the full SHA
    977c84b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    96d376d View commit details
    Browse the repository at this point in the history

Commits on Mar 26, 2024

  1. Configuration menu
    Copy the full SHA
    0c17476 View commit details
    Browse the repository at this point in the history
  2. Fix style

    BenjaminBossan committed Mar 26, 2024
    Configuration menu
    Copy the full SHA
    4b8db0c View commit details
    Browse the repository at this point in the history

Commits on May 21, 2024

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

Commits on Jul 25, 2024

  1. Configuration menu
    Copy the full SHA
    e12070b View commit details
    Browse the repository at this point in the history
  2. Remove duplicate merge

    BenjaminBossan committed Jul 25, 2024
    Configuration menu
    Copy the full SHA
    7b6c7cb View commit details
    Browse the repository at this point in the history
  3. Raise error for multi adapter batch inference

    Not trivial to implement for MHA
    BenjaminBossan committed Jul 25, 2024
    Configuration menu
    Copy the full SHA
    e6ab8ed View commit details
    Browse the repository at this point in the history
  4. Raise error for DoRA + MHA

    Probably not hard to implement
    BenjaminBossan committed Jul 25, 2024
    Configuration menu
    Copy the full SHA
    8ec6c3c View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    f6ba465 View commit details
    Browse the repository at this point in the history

Commits on Jul 26, 2024

  1. Configuration menu
    Copy the full SHA
    fb18886 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    4ff2ec3 View commit details
    Browse the repository at this point in the history
  3. make style

    BenjaminBossan committed Jul 26, 2024
    Configuration menu
    Copy the full SHA
    d1f6ab2 View commit details
    Browse the repository at this point in the history

Commits on Sep 3, 2024

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

Commits on Sep 4, 2024

  1. Configuration menu
    Copy the full SHA
    7ba2e68 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6ef04b0 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    07c7240 View commit details
    Browse the repository at this point in the history
  4. Remove xpass-ing test

    There was a situation were loading the state dict would fail and require
    a workaround. For this, there was an xfail-ing test with strict=True.
    This test no longer fails, so the marker has been removed, as well as
    the test with the workaround.
    BenjaminBossan committed Sep 4, 2024
    Configuration menu
    Copy the full SHA
    cc3ac3d View commit details
    Browse the repository at this point in the history

Commits on Sep 12, 2024

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

Commits on Sep 18, 2024

  1. Configuration menu
    Copy the full SHA
    e558caa View commit details
    Browse the repository at this point in the history
  2. ENH BOFT don't save boft_P buffer (huggingface#2050)

    The buffer does not need to be part of the checkpoint, by making it
    non-persistent, the file size can be greatly reduced.
    sywangyi authored and BenjaminBossan committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    38f4a98 View commit details
    Browse the repository at this point in the history
  3. FIX Command line args in PiSSA preprocess (huggingface#2053)

    Fix bug in parsing command line arguments in the PiSSA preprocess.py script from
    the PiSSA example.
    keakon authored and BenjaminBossan committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    7e5c61d View commit details
    Browse the repository at this point in the history
  4. MNT Update deprecated evaluation_strategy (huggingface#1664)

    In docs and examples, use eval_strategy instead of evaluation_strategy, which is
    deprecated.
    muellerzr authored and BenjaminBossan committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    183bf52 View commit details
    Browse the repository at this point in the history
  5. ENH Multi adapters in same batch: modules_to_save (huggingface#1990)

    Extend the functionality of having different adapters in the same batch to also
    work with `modules_to_save`.
    saeid93 authored and BenjaminBossan committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    b970607 View commit details
    Browse the repository at this point in the history
  6. FIX Bug that prevents BOFT from loading 2 adapters (huggingface#2068)

    There was a bug in BOFT that made it impossible in some circumstances to
    load more than one adapter (creating more than 1 adapter was possible
    though). This was because a code path that adjusts
    boft_n_butterfly_factor was only visited when creating a fresh adapter,
    but not when updating with the 2nd adapter. This was fixed by moving
    this code path from the BOFT layer's __init__ method to update_layer.
    
    A test for loading multiple adapters was added. Since this was a gap in
    our test suite, this test will be applied to all appropriate PEFT
    methods, not only BOFT, but the others methods are all passing without
    needing further changes.
    
    For good measure, I also added BOFT to the test suite that checks
    multiple active adapters. These tests would have also passed without the
    fix in this PR, since these tests do not load multiple adapters but
    instead create them, which always worked. Still it's better to have
    these tests as well.
    BenjaminBossan committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    732e8e7 View commit details
    Browse the repository at this point in the history
  7. TST Skip some quantization tests on XPU (huggingface#2074)

    Eetq/hqq/aqlm don't support XPU yet.
    faaany authored and BenjaminBossan committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    79e2b38 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    61e6934 View commit details
    Browse the repository at this point in the history

Commits on Oct 14, 2024

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

Commits on Oct 21, 2024

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

Commits on Oct 22, 2024

  1. Fix bug in unloading

    Params need to be re-registered to appear in state dict.
    BenjaminBossan committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    1dbb9a5 View commit details
    Browse the repository at this point in the history