Add validation for input data#2220
Open
apsonawane wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to harden JSON configuration parsing for integer-valued fields and to prevent overflow-related issues in beam search buffer sizing, improving robustness of generation configuration and runtime stability.
Changes:
- Switched selected JSON numeric-to-int conversions in
src/config.cppfrom direct casts toSafeDoubleToInt. - Updated the beam search intermediate buffer sizing math in
src/beam_search_scorer.cppto usesize_tarithmetic.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/config.cpp |
Uses a safer conversion helper for several integer-valued JSON fields during config parsing. |
src/beam_search_scorer.cpp |
Adjusts per_beam sizing computation to avoid signed overflow during buffer allocation. |
kunal-vaishnavi
approved these changes
Jun 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request focuses on improving type safety and robustness when converting JSON configuration values to integers, and fixes a potential overflow bug in the beam search scorer. The most important changes are:
Type Safety and Robustness in Configuration Parsing:
static_cast<int>conversions withSafeDoubleToIntfor several configuration parameters insrc/config.cpp, includingcontext_length,max_length,batch_size, andnum_beams, to prevent unsafe casts and handle errors more gracefully. [1] [2]Bug Fix in Beam Search Scorer:
per_beamby explicitly castingmax_length_tosize_tbefore multiplication insrc/beam_search_scorer.cpp.