Skip to content

fix: validate empty generation batches - #1428

Open
danyalahmed1995 wants to merge 1 commit into
meta-llama:mainfrom
danyalahmed1995:fix/validate-empty-generation-batches
Open

fix: validate empty generation batches#1428
danyalahmed1995 wants to merge 1 commit into
meta-llama:mainfrom
danyalahmed1995:fix/validate-empty-generation-batches

Conversation

@danyalahmed1995

Copy link
Copy Markdown

Summary

Adds explicit handling for empty completion batches in the generation APIs.

text_completion([]) and chat_completion([]) previously reached lower-level generation logic and raised ValueError: min() arg is an empty sequence. chat_completion([[]]) could also fail with an IndexError when accessing the first dialog message.

This makes empty request batches return an empty result and raises a clearer ValueError for empty dialogs inside a chat batch.

Test Plan

  • Ran python -m py_compile example_chat_completion.py example_text_completion.py
  • Ran explicit py_compile validation for files under llama/
  • Ran a no-weights validation snippet with a fake model/tokenizer for empty batch inputs

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 10, 2026

@jdasilvareis123-lab jdasilvareis123-lab left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

José da Silva Reis

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants