Skip to content

Support target_modules: all in YAML configs #10

Description

@marksverdhei

Problem

When using target_modules: all in a YAML config, bakery fails with:

ValueError: Target modules all not found in the base model.

The LoraConfig.target_modules field is typed as List[str], so YAML scalar all gets parsed as the string "all" and passed directly to PEFT, which doesn't recognize it.

Expected behavior

target_modules: all (or target_modules: all-linear) in YAML should work and map to PEFT's "all-linear" string, which targets all linear layers.

Suggested fix

In config.py, add a __post_init__ to LoraConfig that normalizes the value:

def __post_init__(self):
    if self.target_modules == "all" or self.target_modules == ["all"]:
        self.target_modules = "all-linear"
    elif self.target_modules == ["all-linear"]:
        self.target_modules = "all-linear"

The type annotation may also need to accept Optional[Union[str, List[str]]] or similar to handle both forms from HfArgumentParser.

Workaround

Use a list with the PEFT-recognized string:

target_modules:
  - all-linear

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions