Skip to content

Add grammar fields to GenerationConfig for constrained decoding#19616

Merged
meta-codesync[bot] merged 1 commit into
mainfrom
export-D105277261
May 15, 2026
Merged

Add grammar fields to GenerationConfig for constrained decoding#19616
meta-codesync[bot] merged 1 commit into
mainfrom
export-D105277261

Conversation

@kirklandsign
Copy link
Copy Markdown
Contributor

Summary:
Add grammar (string) and grammar_type (string) fields to GenerationConfig.
Empty-string defaults, no behavior change when empty. Prepares for
grammar-constrained decoding integration (e.g. JSON schema, regex).

Differential Revision: D105277261

Summary:
Add grammar (string) and grammar_type (string) fields to GenerationConfig.
Empty-string defaults, no behavior change when empty. Prepares for
grammar-constrained decoding integration (e.g. JSON schema, regex).

Differential Revision: D105277261
Copilot AI review requested due to automatic review settings May 15, 2026 18:28
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 15, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19616

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@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 15, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented May 15, 2026

@kirklandsign has exported this pull request. If you are a Meta employee, you can view the originating Diff in D105277261.

@github-actions
Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds grammar-related fields to the LLM runner GenerationConfig as groundwork for future constrained decoding support.

Changes:

  • Adds grammar for constrained decoding definitions.
  • Adds grammar_type to identify the grammar format.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +38 to +42
std::string grammar;

// Grammar format: "json_schema", "regex", "lark", or "gbnf".
// Only used when grammar is non-empty.
std::string grammar_type;
Comment on lines +38 to +42
std::string grammar;

// Grammar format: "json_schema", "regex", "lark", or "gbnf".
// Only used when grammar is non-empty.
std::string grammar_type;
@meta-codesync meta-codesync Bot merged commit 7355d7b into main May 15, 2026
170 of 191 checks passed
@meta-codesync meta-codesync Bot deleted the export-D105277261 branch May 15, 2026 19:26
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. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants