vllm icon indicating copy to clipboard operation
vllm copied to clipboard

[Frontend][Core] passing hf_config args through openai server

Open KrishnaM251 opened this issue 1 year ago • 3 comments

FIX #2547

PR Title and Classification

[Frontend] [Core]

Notes

  • While I believe the implementation is almost complete, the test I wrote only checks if the new Optional[dict] parameter hf_kwargs is succesfully set in ModelConfig.
  • I would like to write a test that detects a change in the LLMEngine output when kf_kwargs is added as a EngineArgs parameter.
  • But I have two questions:
    • How can I write another test that runs hf_kwargs through an OpenAI compatible server? I wanted to repurpose a test in test_openai_server.py, however the EngineArgs params are set before all tests are run.
    • What are some test values that I can set in hf_kwargs which will generate output detectable in a function like: completion = client.completions.create(...) (motivating example). If this is not the best approach for testing, then any recommendations?

BEFORE SUBMITTING, PLEASE READ THE CHECKLIST BELOW AND FILL IN THE DESCRIPTION ABOVE


PR Checklist (Click to Expand)

Thank you for your contribution to vLLM! Before submitting the pull request, please ensure the PR meets the following criteria. This helps vLLM maintain the code quality and improve the efficiency of the review process.

PR Title and Classification

Only specific types of PRs will be reviewed. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:

  • [Bugfix] for bug fixes.
  • [CI/Build] for build or continuous integration improvements.
  • [Doc] for documentation fixes and improvements.
  • [Model] for adding a new model or improving an existing model. Model name should appear in the title.
  • [Frontend] For changes on the vLLM frontend (e.g., OpenAI API server, LLM class, etc.)
  • [Kernel] for changes affecting CUDA kernels or other compute kernels.
  • [Core] for changes in the core vLLM logic (e.g., LLMEngine, AsyncLLMEngine, Scheduler, etc.)
  • [Hardware][Vendor] for hardware-specific changes. Vendor name should appear in the prefix (e.g., [Hardware][AMD]).
  • [Misc] for PRs that do not fit the above categories. Please use this sparingly.

Note: If the PR spans more than one category, please include all relevant prefixes.

Code Quality

The PR need to meet the following code quality standards:

  • We adhere to Google Python style guide and Google C++ style guide.
  • Pass all linter checks. Please use format.sh to format your code.
  • The code need to be well-documented to ensure future contributors can easily understand the code.
  • Include sufficient tests to ensure the project to stay correct and robust. This includes both unit tests and integration tests.
  • Please add documentation to docs/source/ if the PR modifies the user-facing behaviors of vLLM. It helps vLLM user understand and utilize the new features or changes.

Notes for Large Changes

Please keep the changes as concise as possible. For major architectural changes (>500 LOC excluding kernel/data/config/test), we would expect a GitHub issue (RFC) discussing the technical design and justification. Otherwise, we will tag it with rfc-required and might not go through the PR.

What to Expect for the Reviews

The goal of the vLLM team is to be a transparent reviewing machine. We would like to make the review process transparent and efficient and make sure no contributor feel confused or frustrated. However, the vLLM team is small, so we need to prioritize some PRs over others. Here is what you can expect from the review process:

  • After the PR is submitted, the PR will be assigned to a reviewer. Every reviewer will pick up the PRs based on their expertise and availability.
  • After the PR is assigned, the reviewer will provide status update every 2-3 days. If the PR is not reviewed within 7 days, please feel free to ping the reviewer or the vLLM team.
  • After the review, the reviewer will put an action-required label on the PR if there are changes required. The contributor should address the comments and ping the reviewer to re-review the PR.
  • Please respond to all comments within a reasonable time frame. If a comment isn't clear or you disagree with a suggestion, feel free to ask for clarification or discuss the suggestion.

Thank You

Finally, thank you for taking the time to read these guidelines and for your interest in contributing to vLLM. Your contributions make vLLM a great tool for everyone!

KrishnaM251 avatar Jun 25 '24 20:06 KrishnaM251

@DarkLight1337 can you help answer the question since you recently touched the testing harness.

Additionally, there might be other places we want override including tokenizer or generation config. Addressing those will be nice to have.

simon-mo avatar Jun 26 '24 05:06 simon-mo

Thanks for picking this up! To answer your questions:

  • How can I write another test that runs hf_kwargs through an OpenAI compatible server? I wanted to repurpose a test in test_openai_server.py, however the EngineArgs params are set before all tests are run.

You should launch a new instance of the server. Each RemoteOpenAIServer instance creates a new subprocess that invokes the OpenAI entrypoint through the command line, so you can't change the hf_config after instantiating it.

You can add pytest fixtures to use a different server for your tests.

  • What are some test values that I can set in hf_kwargs which will generate output detectable in a function like: completion = client.completions.create(...) (motivating example). If this is not the best approach for testing, then any recommendations?

~~Maybe you can set the attention implementation to eager, which from my understanding would cause some numerical inaccuracies compared to the default one.~~ Actually, this may not work since we are running the vLLM model rather than the HF model.

Perhaps you can ask the author of the original issue what they want to accomplish using this feature that cannot otherwise be done via vLLM args. (If we don't have any situation that results in different vLLM output, what is the point of enabling this?)

DarkLight1337 avatar Jun 26 '24 06:06 DarkLight1337

@DarkLight1337 I appreciate the response. I will do as you suggested.

KrishnaM251 avatar Jun 27 '24 22:06 KrishnaM251

Hi @KrishnaM251,

Any news on this?

I have a specific use case in which I'd like to deploy a Phi3.5-vision model on a vLLM openai server entrypoint ; but i'd like to specify the argument num_crops=16 (which is by default 4 in the preprocessor config file).

vpellegrain avatar Sep 16 '24 08:09 vpellegrain

Hi @KrishnaM251,

Any news on this?

I have a specific use case in which I'd like to deploy a Phi3.5-vision model on a vLLM openai server entrypoint ; but i'd like to specify the argument num_crops=16 (which is by default 4 in the preprocessor config file).

@alex-jw-brooks is currently working on a PR that lets you pass options to the HF processor on demand instead of at startup time (the latter is what this PR focuses on). Stay tuned!

DarkLight1337 avatar Sep 16 '24 10:09 DarkLight1337

Hi @vpellegrain - thought I would link this PR if you'd like to track it, this exposes num_crops as an processor kwarg for phi3v, and can be used or both offline inference and in the CLI when starting the server entry point.

Happy to add a follow-up to make this configurable per-request later on, but as it was already turning into a lot of code to correctly handle processor kwargs for memory profiling etc, the current PR sets it up for init time 😄

alex-jw-brooks avatar Sep 20 '24 08:09 alex-jw-brooks

This pull request has merge conflicts that must be resolved before it can be merged. @KrishnaM251 please rebase it. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

mergify[bot] avatar Nov 02 '24 07:11 mergify[bot]

Sorry for forgetting about this! I think we now have a valid use case which is to patch out incorrect HF configs. cc @K-Mistele

DarkLight1337 avatar Nov 02 '24 07:11 DarkLight1337

right, would be good to be able to adjust RoPE/YARN configurations in config.json at startup-time. I left comments about this on some other issues I just can't seem to find them right this second

K-Mistele avatar Nov 02 '24 18:11 K-Mistele

I have updated this PR and also changed the tests to check overriding rope_scaling and rope_theta.

DarkLight1337 avatar Nov 09 '24 14:11 DarkLight1337