-
-
Couldn't load subscription status.
- Fork 10.9k
[BugFix] Correct max_model_len derivation from config.json for Mistral format #17937
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
Conversation
|
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add 🚀 |
|
@DarkLight1337 Please excuse my being a newbie. I accidentally messed up the original branch, so I closed this pull request: #17777. Therefore, after modifying the code, I submitted it again. Could you please re-assign @tjohnson31415 as the reviewer for this bug fix? Thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another round of simplification suggestions 😅
I think we should be able to get it down to something like this mock code:
# If max_position_embeddings is not in params.json
if config_dict.get("max_position_embeddings") is None:
# try to get it from the HF config, but default to 128_000
max_position_embeddings = 128_000
try:
hf_config = get_config(
model,
revision=revision,
config_format=ConfigFormat.HF,
<<other args>>,
)
if hf_value := hf_config.get_text_config().max_position_embeddings:
max_position_embeddings = hf_value
except Exception as e:
logger.warning('Useful warning message...')
config_dict["max_position_embeddings"] = max_position_embeddings
|
@tjohnson31415 Thanks for your patience; I've already changed the code as you directed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick iteration!
I had a couple more thoughts, but do let me know if you disagree with the suggestions!
vllm/transformers_utils/config.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using AutoConfig directly instead of calling back through get_config means that we don't get the check for the "custom model class" in the registry, i.e. this code.
If we can use get_config() here, it would ensure that this fallback uses the same configuration that would be used with --config-format=hf, e.g. for models that are supported in vLLM but not transformers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. Unfortunately, we can't use get_config() here as it would lead to a circular call.Perhaps I could refer to the code block from
vllm/vllm/transformers_utils/config.py
Lines 308 to 349 in 0189a65
| config_dict, _ = PretrainedConfig.get_config_dict( | |
| model, | |
| revision=revision, | |
| code_revision=code_revision, | |
| token=HF_TOKEN, | |
| **kwargs, | |
| ) | |
| # Use custom model class if it's in our registry | |
| model_type = config_dict.get("model_type") | |
| if model_type in _CONFIG_REGISTRY: | |
| config_class = _CONFIG_REGISTRY[model_type] | |
| config = config_class.from_pretrained( | |
| model, | |
| revision=revision, | |
| code_revision=code_revision, | |
| token=HF_TOKEN, | |
| **kwargs, | |
| ) | |
| else: | |
| try: | |
| config = AutoConfig.from_pretrained( | |
| model, | |
| trust_remote_code=trust_remote_code, | |
| revision=revision, | |
| code_revision=code_revision, | |
| token=HF_TOKEN, | |
| **kwargs, | |
| ) | |
| except ValueError as e: | |
| if (not trust_remote_code | |
| and "requires you to execute the configuration file" | |
| in str(e)): | |
| err_msg = ( | |
| "Failed to load the model config. If the model " | |
| "is a custom model not yet available in the " | |
| "HuggingFace transformers library, consider setting " | |
| "`trust_remote_code=True` in LLM or using the " | |
| "`--trust-remote-code` flag in the CLI.") | |
| raise RuntimeError(err_msg) from e | |
| else: | |
| raise e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can set an explicit config_format=ConfigFormat.HF to avoid it being circular. I think that should work to get the functionality without having to copy the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…flash_attn (vllm-project#17873) Co-authored-by: Stephen Chen <tracelog@meta.com> Signed-off-by: 汪志鹏 <wangzhipeng628@gmail.com>
Signed-off-by: 汪志鹏 <wangzhipeng628@gmail.com>
This reverts commit 14c9116eb24cd25aa44369cedaeba8d2521f8916. Signed-off-by: 汪志鹏 <wangzhipeng628@gmail.com>
…y::test_flash_attn (vllm-project#17873)" This reverts commit bed409e0ce8ec3f2fec70d1cd9ffb029d80b16f4. Signed-off-by: 汪志鹏 <wangzhipeng628@gmail.com>
Signed-off-by: 汪志鹏 <wangzhipeng628@gmail.com>
Signed-off-by: 汪志鹏 <wangzhipeng628@gmail.com>
Signed-off-by: 汪志鹏 <wangzhipeng628@gmail.com>
Signed-off-by: 汪志鹏 <wangzhipeng628@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for picking up this bugfix @princepride!
…l format (vllm-project#17937) Signed-off-by: 汪志鹏 <wangzhipeng628@gmail.com> Co-authored-by: tracelogfb <48808670+tracelogfb@users.noreply.github.com> Co-authored-by: Stephen Chen <tracelog@meta.com> Signed-off-by: Yuqi Zhang <yuqizhang@google.com>

FIX #17747
@tjohnson31415
Thank you for your patience and suggestions.
I've reverted the code to its original version first before applying modifications.
I have removed all logic related to max_seq_len.
The subsequent logic (to fetch from standard Hugging Face config) will only be triggered if max_position_embeddings cannot be obtained from params.json.
I am referencing the configuration loaded from config.json as it's done for ConfigFormat.HF (i.e., using AutoConfig.from_pretrained).
Something went wrong, and I accidentally caused issues in the original branch, so I've opened a new PR to merge the code.