Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check user-specified model_max_len with hf derived max_model_len #1778

Merged
merged 4 commits into from
Oct 24, 2024

Conversation

BBuf
Copy link
Contributor

@BBuf BBuf commented Oct 24, 2024

Motivation

This PR aims to improve the handling of context length in the ModelConfig class. It addresses potential issues when users specify a context length exceeding the model's derived maximum, enhances error messaging, and introduces a controlled override mechanism. These changes will prevent decoding nan errors, which I have met recently.

Modifications

The ModelConfig class in model_config.py has been updated to include a check comparing user-specified context_length against the model's derived_context_len. It now handles the SGLANG_ALLOW_LONG_MAX_MODEL_LEN environment variable, allowing controlled overrides of maximum context length. The changes include logic to raise a ValueError or print a warning based on the specified length and override settings, with improved error and warning messages for clear user guidance.

Checklist

  • Format your code according to the Contributor Guide.
  • Add unit tests as outlined in the Contributor Guide.
  • Update documentation as needed, including docstrings or example tutorials.

Copy link
Contributor

@merrymercy merrymercy left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution. Please fix the lint errors and my comments.

python/sglang/srt/configs/model_config.py Outdated Show resolved Hide resolved
python/sglang/srt/configs/model_config.py Outdated Show resolved Hide resolved
python/sglang/srt/configs/model_config.py Outdated Show resolved Hide resolved
@merrymercy
Copy link
Contributor

@merrymercy merrymercy enabled auto-merge (squash) October 24, 2024 10:43
auto-merge was automatically disabled October 24, 2024 13:51

Head branch was pushed to by a user without write access

@BBuf
Copy link
Contributor Author

BBuf commented Oct 24, 2024

@merrymercy merrymercy merged commit 6059721 into sgl-project:main Oct 24, 2024
11 checks 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