[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2026-07-26 15:25:27 +00:00
commit fba59861e9
2 changed files with 6 additions and 5 deletions

View file

@ -138,6 +138,7 @@ def test_generate_kwarg_gate():
# The only values that must be stripped are the ones the strict validator would
# raise on, which is exactly what the gate above predicts.
def _filter_logits_kwargs(model, kwargs):
"""The v5 branch of unsloth_base_fast_generate, as a testable function."""
for key in ("logits_to_keep", "num_logits_to_keep"):
@ -169,9 +170,10 @@ def test_v5_leaves_other_kwargs_alone():
def test_source_has_no_unconditional_pop():
src = open(VISION).read()
assert 'kwargs.pop("logits_to_keep", None)\n kwargs.pop("num_logits_to_keep", None)' not in src, (
"the v5 branch must not drop caller-supplied logits_to_keep unconditionally"
)
assert (
'kwargs.pop("logits_to_keep", None)\n kwargs.pop("num_logits_to_keep", None)'
not in src
), "the v5 branch must not drop caller-supplied logits_to_keep unconditionally"
if __name__ == "__main__":

View file

@ -431,8 +431,7 @@ def unsloth_base_fast_generate(self, *args, **kwargs):
# (renamed away in v5), and logits_to_keep on the VLMs whose top-level
# forward does not take it.
for _logits_kwarg in ("logits_to_keep", "num_logits_to_keep"):
if _logits_kwarg in kwargs and \
not _unsloth_generate_accepts_kwarg(self, _logits_kwarg):
if _logits_kwarg in kwargs and not _unsloth_generate_accepts_kwarg(self, _logits_kwarg):
kwargs.pop(_logits_kwarg, None)
model_eos_token_id = getattr(self.config, "eos_token_id", None)