Skip to content

Gemma 3 generate test: find the non-flex scope by call, not by its exact text - #17497

Merged
danielhanchen merged 1 commit into
mainfrom
tests-nonflex-generate-scope
Nov 11, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
tests-nonflex-generate-scope

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Repo tests (CPU, rest) fails on main since #17329, and on every PR based on it (seen on #17479):

FAILED tests/test_gemma3_generate_off_flex.py::test_generate_enters_the_scope
E   assert '_NonFlexGenerate(self)' in 'def unsloth_base_fast_generate(self, *args, **kwargs): ...

The test checks that unsloth_base_fast_generate enters the _NonFlexGenerate scope for the model it generates with. It did that by looking for the literal text _NonFlexGenerate(self). #17329 (flex attention decode steps) still enters the scope, now with a keyword argument:

_NonFlexGenerate(self, flex_decode = not _wants_attentions(self, kwargs)),

So the code is right and the test is too strict: any added argument or reflow breaks it without the behaviour changing.

Change

test_generate_enters_the_scope now parses the function and requires a _NonFlexGenerate(...) call whose first argument is self. Keyword arguments and formatting no longer matter, but the scope still has to be entered for the model itself: a comment or string that mentions it, or the scope built for another object, does not count. A new test_the_scope_check_reads_calls_not_text covers those cases.

Testing

  • tests/test_gemma3_generate_off_flex.py: fails on main (1 failed, 18 passed), 20 passed here.
  • With the _NonFlexGenerate(...) entry in unsloth_base_fast_generate replaced by contextlib.nullcontext(), test_generate_enters_the_scope fails.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T09:10:37.812924Z f911f16 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: f911f1627e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 714073e into main Nov 11, 2026
@danielhanchen
danielhanchen deleted the tests-nonflex-generate-scope branch November 11, 2026 10:34
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