[BugFix] Correct max_model_len derivation from config.json for Mistral format #17937
[BugFix] Correct max_model_len derivation from config.json for Mistral format #17937DarkLight1337 merged 8 commits intovllm-project:mainfrom
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. |
tjohnson31415
left a comment
There was a problem hiding this comment.
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. |
tjohnson31415
left a comment
There was a problem hiding this comment.
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.
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.
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
There was a problem hiding this comment.
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.
…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>
tjohnson31415
left a comment
There was a problem hiding this comment.
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.