Skip to content

Validate positive inference min output tokens - #8370

Open
AmirF194 wants to merge 1 commit into
deepspeedai:masterfrom
AmirF194:fix/min-out-tokens-positivity
Open

Validate positive inference min output tokens#8370
AmirF194 wants to merge 1 commit into
deepspeedai:masterfrom
AmirF194:fix/min-out-tokens-positivity

Conversation

@AmirF194

Copy link
Copy Markdown

Description

DeepSpeedInferenceConfig.min_out_tokens has no lower-bound validation, so a negative or
zero value passes Pydantic construction and is only ever caught later, deep in
GenWorkSpace's C++ workspace allocation (inference_context.h), which takes it as an
unsigned parameter. #8343 added the same gt=0 constraint to the architecturally
identical sibling field max_out_tokens; this completes it on min_out_tokens, which
that PR does not touch.

Refs #8339 (reports the max_out_tokens half of this gap, already being fixed by #8343).

Testing

Verified with a plain Pydantic construction check, no model or GPU required:

  • Before: DeepSpeedInferenceConfig(min_out_tokens=-1) and DeepSpeedInferenceConfig(min_out_tokens=0) both construct without error.
  • After: both raise ValidationError, and min_out_tokens=50 (or the default 1) still constructs normally.
  • New parametrized test in tests/unit/inference/test_inference_config.py (mirrors Validate positive inference max output tokens #8343's shape for max_out_tokens) fails on unmodified master and passes on this branch; ran with pytest -m inference tests/unit/inference/test_inference_config.py.
  • pre-commit run --files deepspeed/inference/config.py tests/unit/inference/test_inference_config.py: all hooks pass.
  • Not run: the CUDA/ROCm GenWorkSpace path itself, since this VPS has no GPU. The C++ guard at inference_context.h:150 is untouched and stays as a defense in depth; this PR only stops the invalid value earlier, at config time.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ed1163963d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"""

min_out_tokens: int = Field(1, alias="min_tokens")
min_out_tokens: int = Field(1, alias="min_tokens", gt=0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add the required sign-off trailer

This is a non-merge commit, but its commit message contains no Signed-off-by trailer, so it violates the repository's mandatory commit/CI requirement and may be rejected by the corresponding compliance check. Recreate the commit with --signoff using the configured Git identity.

AGENTS.md reference: AGENTS.md:L6-L8

Useful? React with 👍 / 👎.

min_out_tokens has no lower-bound validation, so a negative or zero value
passes config construction and is only caught later inside GenWorkSpace's
C++ workspace allocation. Add the same gt=0 constraint deepspeedai#8343 gave the
sibling max_out_tokens field.

Refs deepspeedai#8339

Signed-off-by: Amir Fathi <amirfathi.me@gmail.com>
@AmirF194
AmirF194 force-pushed the fix/min-out-tokens-positivity branch from ed11639 to e5542cf Compare September 2, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant