Skip to content

[Model] vllm v1 support mlp_speculator #21276

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

skylee-01
Copy link
Contributor

@skylee-01 skylee-01 commented Jul 21, 2025

Essential Elements of an Effective PR Description Checklist

  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

Purpose

vllm v1 support mlp_speculator

Test Plan

Test Result

(Optional) Documentation Update

Signed-off-by: skylee-01 <497627264@qq.com>
Signed-off-by: skylee-01 <497627264@qq.com>
Signed-off-by: skylee-01 <497627264@qq.com>
Signed-off-by: skylee-01 <497627264@qq.com>
Signed-off-by: skylee-01 <497627264@qq.com>
Signed-off-by: skylee-01 <497627264@qq.com>
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.

🚀

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for the mlp_speculator speculative decoding method in vLLM's v1 architecture. The changes include a new proposer implementation for v1, modifications to the core MLPSpeculator model to support being used as a draft model, and integration into the GPUModelRunner. My review has identified several critical issues in the new implementation related to incorrect logic for processing proposal tokens, a crash in the dummy_run due to a missing argument, and flawed logic in the modified MLPSpeculator model. These issues need to be addressed to ensure correctness and prevent runtime errors.

Signed-off-by: lisiqi23 <lisiqi23@xiaomi.com>
@skylee-01 skylee-01 requested a review from DarkLight1337 as a code owner July 21, 2025 04:30
@mergify mergify bot added the new-model Requests to new models label Jul 21, 2025
@skylee-01
Copy link
Contributor Author

The content is updated to the new PR, and the old PR is discarded.
#20655

Signed-off-by: skylee-01 <497627264@qq.com>
@skylee-01
Copy link
Contributor Author

Use the following script to test:
Base model: 39.80 s
mlp_speculator: 30.03 s
The acceleration of speculative sampling is obvious.

# -*- coding: utf-8 -*-
import sys
import os

os.environ["VLLM_USE_V1"] = "1" 

custom_vllm_path = '/path/to/your/vllm' 
if custom_vllm_path not in sys.path:
   sys.path.insert(0, custom_vllm_path)


 
from vllm import LLM, SamplingParams

prompts = [
 "1+1= ",
]

sampling_params = SamplingParams(temperature=0, max_tokens=20)

model = "/path/to/your/model/Meta-Llama-3.1-8B-Instruct"  # Please replace with your model path

llm = LLM(
    model=model,
    enforce_eager=True,
    max_model_len=3000,
    gpu_memory_utilization=0.9,
    tensor_parallel_size=1,
    speculative_config={
        "method": "mlp_speculator",
        "model": "/path/to/your/speculative/model/llama3-8b-accelerator/",  # Please replace with your speculative model path
        "draft_tensor_parallel_size": 1,
        "num_speculative_tokens": 2,
    },
)

import time
t1 = time.time()
for i in range(100):
    print("************************************************")    
    outputs = llm.generate(prompts, sampling_params)
    for output in outputs:
        answer = output.outputs[0].text
        print(f"answer:{answer}")
print("time:", time.time() - t1)

@skylee-01
Copy link
Contributor Author

I've increased the tests and updated the code to the latest vllm version.
@WoosukKwon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant