Skip to content

Fix compatibility with newer transformers/PEFT versions#96

Draft
rosacry wants to merge 1 commit into
OliBomby:mainfrom
rosacry:fix/transformers-compatibility
Draft

Fix compatibility with newer transformers/PEFT versions#96
rosacry wants to merge 1 commit into
OliBomby:mainfrom
rosacry:fix/transformers-compatibility

Conversation

@rosacry

@rosacry rosacry commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Fixes compatibility issues when using newer versions of transformers and PEFT libraries.

Changes

  • Mapperatorinator.__init__: Accept **kwargs to handle additional keyword arguments passed by newer transformers versions
  • MapperatorinatorConfig: Store dtype kwarg on config object so get_backbone_model can access it

Context

When using transformers >= 4.57 with PEFT >= 0.18, the model initialization fails because newer transformers passes additional kwargs (dtype, etc.) that the custom __init__ doesn't accept. These changes make the model forward-compatible.

Copilot AI review requested due to automatic review settings April 9, 2026 17:57
@rosacry rosacry marked this pull request as draft April 9, 2026 18:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the custom Mapperatorinator model initialization to be forward-compatible with newer transformers/PEFT versions that pass additional keyword arguments during from_pretrained construction.

Changes:

  • Update Mapperatorinator.__init__ to accept **kwargs and forward them to PreTrainedModel.
  • Persist a dtype kwarg onto the config so get_backbone_model() can read it when constructing the backbone model.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +76 to +77
if not hasattr(config, 'dtype'):
config.dtype = kwargs.get('dtype', None)

Copilot AI Apr 9, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hasattr(config, 'dtype') guard means a user-provided dtype kwarg can be silently ignored on subsequent loads. After this change, configs saved once without a dtype will likely contain dtype=None; later from_pretrained(..., dtype=...) will not update it because the attribute already exists. Prefer applying the explicit kwarg when present (e.g., override when config.dtype is missing or None, and consider also checking torch_dtype since HF commonly uses that name).

Suggested change
if not hasattr(config, 'dtype'):
config.dtype = kwargs.get('dtype', None)
explicit_dtype = kwargs.get("dtype", kwargs.get("torch_dtype", None))
if explicit_dtype is not None:
config.dtype = explicit_dtype
elif not hasattr(config, "dtype"):
config.dtype = None

Copilot uses AI. Check for mistakes.
Newer versions of transformers pass additional kwargs (like torch_dtype)
to model __init__. This fixes two issues:

1. Accept **kwargs in Mapperatorinator.__init__ to avoid TypeError
2. Store dtype on config so get_backbone_model can read it from config
   instead of receiving it as a kwarg it doesn't expect
@rosacry rosacry force-pushed the fix/transformers-compatibility branch from 3b29f32 to 525d5a0 Compare April 9, 2026 18:11
@OliBomby

OliBomby commented Apr 9, 2026

Copy link
Copy Markdown
Owner

compatibility for newer versions might need more work than this, so I don't consider upgrading atm. PR can stay open for if i change my mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants