fix(inference): reject non-positive max_out_tokens at config validation - #8454
Open
chakshu-dhannawat wants to merge 1 commit into
Open
Conversation
Values <= 0 for max_out_tokens were accepted during config parsing and only failed at generation time with a confusing 'input size exceeds maximum length of -1' error. Add a field validator so DeepSpeedInferenceConfig raises a clear ValueError immediately. Signed-off-by: Chakshu Dhannawat <chakshu.dhannawat1@gmail.com>
chakshu-dhannawat
requested review from
hwchen2017,
loadams,
tjruwase and
tohtana
as code owners
September 8, 2026 05:17
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.
Fixes #8339
DeepSpeed currently accepts a negative (or zero) value for
max_out_tokensduring inference config parsing. The failure only surfaces later at generation time with a confusing "Input with size N exceeds maximum length of -1" message.This PR adds a small pydantic field validator on
max_out_tokensso that non-positive values raise a clearValueErrorwhen the config is constructed.Changes:
deepspeed/inference/config.py: addvalidate_max_out_tokensfield validator.tests/unit/inference/test_inference_config.py: add CPU-only regression tests for -1, 0, and positive values.Verified:
CUDA_VISIBLE_DEVICES="" python -m pytest tests/unit/inference/test_inference_config.py -m inference -k TestInferenceConfigValidation -vpasses (3/3).pre-commit run --files deepspeed/inference/config.py tests/unit/inference/test_inference_config.pypasses (yapf, flake8, license, codespell, check-torchdist, etc.).