Skip to content

Text generation default unlimited limit passes an invalid max_tokens value #268

Description

@sylvesterkaczmarek

Summary

gpt_oss.generate documents --limit 0 as unlimited and uses 0 as the CLI default, but main() converts that sentinel to None before calling the selected token generator:

max_tokens = None if args.limit == 0 else args.limit
...
generator.generate(..., max_tokens=max_tokens, ...)

All three reference token generators define max_tokens: int = 0. Torch and Triton implement unlimited generation with:

while max_tokens == 0 or num_generated_tokens < max_tokens:

so passing None makes the first comparison false and then attempts num_generated_tokens < None, which raises TypeError. The vLLM generator also expects the integer 0 sentinel and converts it to None internally for vLLM.

Impact

The default gpt_oss.generate limit value can break the Torch and Triton generation backends instead of disabling the token limit as documented.

Proposed resolution

Pass the CLI's integer limit through unchanged. A value of 0 should reach each backend as 0 so every generator can apply its own documented unlimited behavior.

Add a regression around main() with a stub generator verifying the default/unlimited path passes max_tokens=0.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions