Skip to content

Comments

fix: Handle check_model_inputs removal in transformers 5.2.0#1369

Open
oliverholworthy wants to merge 3 commits intomainfrom
oholworthy/transformers-check-model-inputs
Open

fix: Handle check_model_inputs removal in transformers 5.2.0#1369
oliverholworthy wants to merge 3 commits intomainfrom
oholworthy/transformers-check-model-inputs

Conversation

@oliverholworthy
Copy link
Contributor

@oliverholworthy oliverholworthy commented Feb 24, 2026

What does this PR do ?

Fix get_check_model_inputs_decorator() to handle transformers >= 5.2.0 where check_model_inputs was removed and split into merge_with_config_defaults and capture_outputs, and fix the null_decorator fallback that was broken by @contextmanager.

Changelog

  • Remove @contextmanager from null_decorator — it turned the function into a ContextDecorator whose __call__(self, func) signature collided with model forward kwargs like input_ids, causing TypeError at runtime.
  • Add a new branch in get_check_model_inputs_decorator() for transformers >= 5.2.0 that composes merge_with_config_defaults and capture_outputs into a single decorator.
  • Add tests verifying the fallback decorator works with keyword arguments and that null_decorator works in both @decorator and @decorator() forms.

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?

Additional Information

Affects all three models using get_check_model_inputs_decorator(): biencoder, llama, and qwen2. No model file changes needed, they already call the shared helper and will pick up the fix automatically.

Signed-off-by: Oliver Holworthy <1216955+oliverholworthy@users.noreply.github.com>
Signed-off-by: Oliver Holworthy <1216955+oliverholworthy@users.noreply.github.com>
Signed-off-by: Oliver Holworthy <1216955+oliverholworthy@users.noreply.github.com>
@oliverholworthy oliverholworthy force-pushed the oholworthy/transformers-check-model-inputs branch from 960cec6 to 7df5cd8 Compare February 24, 2026 16:25
@oliverholworthy
Copy link
Contributor Author

/ok to test 7df5cd8

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.

1 participant