Skip to content

add_weighted_adapter() is unusable, throws error: "Invalid type <class 'list'> found in target_modules" #1045

@Vectorrent

Description

@Vectorrent

System Info

  • transformers version: 4.34.0
  • Platform: Linux-6.5.6-arch2-1-x86_64-with-glibc2.35
  • Python version: 3.10.12
  • Huggingface_hub version: 0.17.3
  • Safetensors version: 0.4.0
  • Accelerate version: 0.23.0
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.1.0+cu121 (True)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using GPU in script?: false
  • Using distributed or parallel set-up in script?: false

Who can help?

@pacman100 @you

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder
  • My own task or dataset (give details below)

Reproduction

Load the model:

model = AutoModelForCausalLM.from_pretrained(
        "RWKV/rwkv-4-169m-pile"
        device_map="auto"
    )

Convert it into a PeftModel (to make the add_weighted_adapter() method available):

model = PeftModel.from_pretrained(
        model, f"{adapter_dir}/{adapter}", adapter_name='adapter_1'
    )

Load the 2nd adapter:

model.load_adapter(
        f"{adapter_dir}/{adapter}", adapter_name='adapter_2'
    )

Attempt to merge the two adapters:

model.add_weighted_adapter(
        adapters=['adapter_1', 'adapter_2'],
        weights=[0.5, 0.5],
        adapter_name="combined",
        combination_type="svd",
    )

This will result in the error message:

Invalid type <class 'list'> found in target_modules

Expected behavior

I have 2 fully trained LoRA adapters. The only configuration difference between them is the rank and alpha used for each.

I would like to merge the two adapters into a new adapter, and set that adapter to the "active" one.

However, trying to use the add_weighted_adapter() method always results in the following error:

Invalid type <class 'list'> found in target_modules

I would expect the add_weighted_adapter() method to accept a list, for the "target_modules" argument.

If you can provide any advice, I would greatly appreciate it. I suspect that this is either unsupported and/or not fully-implemented; or, it has something to do with the way I'm attaching adapters. I've tried a bunch of alternate configurations, but I'm not having luck.

Thanks in advance for any help you might provide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions