Skip to content

fix(api): validate and normalize request seeds - #1442

Merged
shihaobai merged 6 commits into
ModelTC:mainfrom
sufubao:fix/openai-seed-validation
Aug 6, 2026
Merged

fix(api): validate and normalize request seeds#1442
shihaobai merged 6 commits into
ModelTC:mainfrom
sufubao:fix/openai-seed-validation

Conversation

@sufubao

@sufubao sufubao commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • expose omitted or null request seeds as None in the OpenAI-compatible request models
  • normalize None to the internal -1 random-seed sentinel
  • accept only -1 or non-negative seeds through 2^63 - 1
  • validate before assigning to the signed ctypes.c_int64 field, preventing oversized Python integers from silently wrapping
  • keep seed normalization and validation helpers alongside SamplingParams

PyTorch accepts seeds through 2^64 - 1, but LightLLM stores request seeds in a signed c_int64; this PR uses the largest value that can be represented without conversion or wraparound.

Validation

  • pre-commit (black and flake8) on all modified production files
  • manual boundary smoke check for None, -1, 0, 2^63 - 1, underflow, overflow, and very large Python integers

@shihaobai
shihaobai merged commit 07d8896 into ModelTC:main Aug 6, 2026
1 check passed
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.

2 participants