Skip to content

Conversation

qthequartermasterman
Copy link
Contributor

@qthequartermasterman qthequartermasterman commented Mar 25, 2025

Note

This PR is just #11684, but rebased onto main and then with pre-commit errors fixed, since it has been some time since @Bryce1010 has updated that PR.

Adds support for passing prompt_embeds to LLM.generate as

llm.generate({"prompt_embeds": input_embeds}, sampling_params)

or

llm.generate(
    [{"prompt_embeds": input_embeds} for input_embeds in inputs_embeds], sampling_params
)

this enables use cases when only the embedding layer is finetuned, and have the same model backend support multiple custom tuned embedding layers

FIX #416
FIX #8323
FIX #14621

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.

🚀

@liangwythu
Copy link

our project need this feature,Would love to see this one merged!

@DarkLight1337
Copy link
Member

Can you also update this PR with the unit tests in #6869 to see whether this solution works correctly?

@qthequartermasterman qthequartermasterman force-pushed the feature/vllm/add-input-embedding branch from 5024f08 to 01cbc0b Compare March 25, 2025 22:16
@DarkLight1337 DarkLight1337 reopened this Mar 26, 2025
@DarkLight1337
Copy link
Member

Oops I accidentally closed the PR, reopened it now

@yukang2017
Copy link

yukang2017 commented Mar 27, 2025

Hi,

I set inputs_embeds as (num_tokens, embed_dim) and get the following issues. Are there any advice? Thanks.

image

@lzl-mt
Copy link

lzl-mt commented Mar 27, 2025

Hi,

I set inputs_embeds as (num_tokens, embed_dim) and get the following issues. Are there any advice? Thanks.

image

@DarkLight1337 I also meet this issue. When my input is (T, V), I get the error:
*** IndexError: index 14 is out of bounds for axis 0 with size 14

When my input is (B, T, V), I get the error:
RuntimeError: query, key, and positions must have the same number of tokens.

Copy link

mergify bot commented Apr 1, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @qthequartermasterman.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Apr 1, 2025
临景 and others added 5 commits April 2, 2025 14:37
Signed-off-by: Andrew Sansom <[email protected]>
Signed-off-by: Andrew Sansom <[email protected]>
Signed-off-by: Andrew Sansom <[email protected]>
Signed-off-by: Andrew Sansom <[email protected]>
Signed-off-by: Andrew Sansom <[email protected]>
@mergify mergify bot removed the needs-rebase label May 1, 2025
@qthequartermasterman
Copy link
Contributor Author

qthequartermasterman commented May 2, 2025

@DarkLight1337

There are three tests still failing in CI.

Async Engine Inputs: test_mp_crash_detection has a subtle bug in it. It is supposed to be testing how long error recovery takes after LLMEngine failes to initialize. But since LLMEngine is being initialized in a different process, the mock which raises an exception is not applied properly. So the actual initialization process is what is being timed here. Because there are more cudagraphs to compile, this takes longer than the 60 seconds defined in the test. The "easy" answer is to bump up the threshold in the test. Another "easy" option is to enforce eager mode to avoid compilation. But the "correct" answer is to refactor the test to cause a failure within the LLMEngine so it actually tests what it claims to be testing. Using mocks directly would be difficult because of the fact that LLMEngine is being initialized in another process. I'm not 100% certain how to do it cleanly, to be honest, without a refactor of the source code for the MQLLMEngine and/or the build_async_engine_client_from_engine_args to be able to pass in a function that raises an error (maybe a fake executor_class?)

How would you like to proceed with this?

Both the speculative decoding and v1 tests are failing on main locally for me. 🤷 I see the same v1-test is failing on main an hour ago: https://buildkite.com/vllm/ci/builds/19179#01968e82-8601-44f0-8825-816c8f31a236. The speculative decoding tests seem not to have run in that build, so I don't know for certain if they're failing on main in CI. For the life of me I cannot figure out how those speculative decoding tests would have been affected by any of the changes in this PR.

@DarkLight1337
Copy link
Member

I can help force merge if the test failures are unrelated

Signed-off-by: DarkLight1337 <[email protected]>
@vllm-bot vllm-bot merged commit cc2a77d into vllm-project:main May 2, 2025
3 of 6 checks passed
@KyleMylonakisProtopia
Copy link

Super happy to see this in. Thank you everyone for all the hard work!

@qthequartermasterman
Copy link
Contributor Author

Thanks @DarkLight1337 for the patient review and iteration process!

radeksm pushed a commit to radeksm/vllm that referenced this pull request May 2, 2025
Signed-off-by: Andrew Sansom <[email protected]>
Signed-off-by: DarkLight1337 <[email protected]>
Co-authored-by: 临景 <[email protected]>
Co-authored-by: Bryce1010 <[email protected]>
Co-authored-by: Nan2018 <[email protected]>
Co-authored-by: Cyrus Leung <[email protected]>
Co-authored-by: DarkLight1337 <[email protected]>
@njhill
Copy link
Member

njhill commented May 3, 2025

I'm not sure we want to double the graph compilation time during startup in all cases, even when inputs_embeds aren't being used. This is the reason for at least one of the test failures and likely others too.

@DarkLight1337
Copy link
Member

DarkLight1337 commented May 3, 2025

My bad for merging this. I have opened #17607 to fix this problem by disabling input embeddings by default.

if not prompt_ids:
if prompt_type == "encoder" and model_config.is_multimodal_model:
pass # Mllama may have empty encoder inputs for text-only data
if prompt_inputs["type"] == "embeds":
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be elif? The way it is now it'll raise on mllama with empty encoder input

RichardoMrMu pushed a commit to RichardoMrMu/vllm that referenced this pull request May 12, 2025
Signed-off-by: Andrew Sansom <[email protected]>
Signed-off-by: DarkLight1337 <[email protected]>
Co-authored-by: 临景 <[email protected]>
Co-authored-by: Bryce1010 <[email protected]>
Co-authored-by: Nan2018 <[email protected]>
Co-authored-by: Cyrus Leung <[email protected]>
Co-authored-by: DarkLight1337 <[email protected]>
Signed-off-by: Mu Huai <[email protected]>
mawong-amd pushed a commit to ROCm/vllm that referenced this pull request May 14, 2025
Signed-off-by: Andrew Sansom <[email protected]>
Signed-off-by: DarkLight1337 <[email protected]>
Co-authored-by: 临景 <[email protected]>
Co-authored-by: Bryce1010 <[email protected]>
Co-authored-by: Nan2018 <[email protected]>
Co-authored-by: Cyrus Leung <[email protected]>
Co-authored-by: DarkLight1337 <[email protected]>
zzzyq pushed a commit to zzzyq/vllm that referenced this pull request May 24, 2025
Signed-off-by: Andrew Sansom <[email protected]>
Signed-off-by: DarkLight1337 <[email protected]>
Co-authored-by: 临景 <[email protected]>
Co-authored-by: Bryce1010 <[email protected]>
Co-authored-by: Nan2018 <[email protected]>
Co-authored-by: Cyrus Leung <[email protected]>
Co-authored-by: DarkLight1337 <[email protected]>
Signed-off-by: Yuqi Zhang <[email protected]>
@roadr roadr mentioned this pull request Jun 19, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend ready ONLY add when PR is ready to merge/full CI is needed speculative-decoding v0

Projects

None yet