Skip to content

Conversation

@princepride
Copy link
Contributor

@princepride princepride commented May 10, 2025

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.

@github-actions
Copy link

👋 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 fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

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 ready label to the PR or enable auto-merge.

🚀

@princepride
Copy link
Contributor Author

@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.

@DarkLight1337
Copy link
Member

cc @tjohnson31415

Copy link
Contributor

@tjohnson31415 tjohnson31415 left a 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

@princepride
Copy link
Contributor Author

@tjohnson31415 Thanks for your patience; I've already changed the code as you directed.

Copy link
Contributor

@tjohnson31415 tjohnson31415 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 quick iteration!
I had a couple more thoughts, but do let me know if you disagree with the suggestions!

Copy link
Contributor

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.

Copy link
Contributor Author

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

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
to initialize hf_config. This approach could help ensure better configuration support for models that are supported in vLLM but not in Transformers, aligning with the goal of having the fallback use a consistent configuration.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your suggestions. I followed your advice, and it successfully ran while also making the code simpler. As a newcomer, I cannot express in words my gratitude for your patience.
Screenshot 2025-05-15 100345

tracelogfb and others added 8 commits May 15, 2025 10:25
…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>
Copy link
Contributor

@tjohnson31415 tjohnson31415 left a 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!

@DarkLight1337 DarkLight1337 enabled auto-merge (squash) May 17, 2025 02:30
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label May 17, 2025
@DarkLight1337 DarkLight1337 merged commit 4ee4826 into vllm-project:main May 17, 2025
67 checks passed
@princepride princepride deleted the patch-2 branch May 17, 2025 06:18
zzzyq pushed a commit to zzzyq/vllm that referenced this pull request May 24, 2025
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Issues with max_model_len and config_format mistral

4 participants