Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Bugfix] Fix spec decoding when seed is none in a batch #10863

Merged
merged 2 commits into from
Dec 20, 2024

Conversation

wallashss
Copy link
Contributor

@wallashss wallashss commented Dec 3, 2024

The issue was in the rejection_sampler in a custom _multinomial function. When a batch contains a seed as None, the calculation fails because the access with non-spec indices does not change in place. So, I changed to every request to be calculated the same way as seeded using ranges.

Concise script to repro the bug
from vllm import EngineArgs, LLMEngine
from vllm.sampling_params import SamplingParams
from vllm.platforms import current_platform

model='meta-llama/Llama-3.1-8B-Instruct'
speculative_model='ibm-fms/llama3-8b-accelerator'

current_platform.seed_everything(0)
engine_args = EngineArgs(model=model,
                            gpu_memory_utilization=0.95, 
                            use_v2_block_manager=True,
                            enforce_eager=True,
                            speculative_model=speculative_model, 
                            num_speculative_tokens=4
                            )
engine = LLMEngine.from_engine_args(engine_args)

prompts = [
    # Expected: "I will never miss any tokens."...
    # Wrong: "I!!!!!!!! will"...
    ('Write the following phrase exactly 20 times: I will never miss any tokens.\n1: I will never miss any tokens.\n2: ', 
     SamplingParams(temperature=0.1, stop=['20:'], seed=None, min_tokens=10, max_tokens=10, logprobs=1)),
    ('How to make pizza??? ', 
     SamplingParams(temperature=0.1, seed=1, logprobs=1)),
]
for i, (prompt, params) in enumerate(prompts):
    engine.add_request(
        f"request-id-{i}",
        prompt,
        params,
    )

while engine.has_unfinished_requests():
    res = engine.step()
    if not res:
        continue
    for r in res:
        if r.finished:
            print(r.outputs[0].text)


print('_______')
current_platform.seed_everything(0)
# Patch to all request be seed None
prompts[1][1].seed = None 
for i, (prompt, params) in enumerate(prompts):
    engine.add_request(
        f"request-id-{i+2}",
        prompt,
        params,
    )
    
while engine.has_unfinished_requests():
    res = engine.step()
    if not res:
        continue
    for r in res:
        if r.finished:
            print(r.outputs[0].text)

FIX #9441 (link existing issues this PR will resolve)

Signed-off-by: Wallas Santos <wallashss@ibm.com>
Copy link

github-actions bot commented Dec 3, 2024

👋 Hi! Thank you for contributing to the vLLM project.
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 do one of these:

  • Add ready label to the PR
  • Enable auto-merge.

🚀

@DarkLight1337 DarkLight1337 requested a review from njhill December 3, 2024 14:53
@wallashss wallashss changed the title Fix spec decoding when seed is none in a batch [Bugfix] Fix spec decoding when seed is none in a batch Dec 3, 2024
@joerunde
Copy link
Collaborator

joerunde commented Dec 6, 2024

Looks like a network timeout on the tests :(

Signed-off-by: Wallas Santos <wallashss@ibm.com>
Copy link
Member

@mgoin mgoin left a comment

Choose a reason for hiding this comment

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

I retried the failing builds, let's see if they can be green this far back

@mgoin mgoin added the ready ONLY add when PR is ready to merge/full CI is needed label Dec 20, 2024
@mgoin mgoin enabled auto-merge (squash) December 20, 2024 00:10
@mgoin mgoin merged commit 86c2d8f into vllm-project:main Dec 20, 2024
63 checks passed
@wallashss
Copy link
Contributor Author

Thank you very much @mgoin !

lucas-tucker pushed a commit to lucas-tucker/vllm-lucas-tucker that referenced this pull request Dec 21, 2024
…#10863)

Signed-off-by: Wallas Santos <wallashss@ibm.com>
Signed-off-by: lucast2021 <lucast2021@headroyce.org>
BKitor pushed a commit to BKitor/vllm that referenced this pull request Dec 30, 2024
joennlae pushed a commit to 44ai-labs/vllm that referenced this pull request Jan 19, 2025
joennlae pushed a commit to 44ai-labs/vllm that referenced this pull request Jan 19, 2025
abmfy pushed a commit to abmfy/vllm-flashinfer that referenced this pull request Jan 24, 2025
…#10863)

Signed-off-by: Wallas Santos <wallashss@ibm.com>
Signed-off-by: Bowen Wang <abmfy@icloud.com>
abmfy pushed a commit to abmfy/vllm-flashinfer that referenced this pull request Jan 24, 2025
mzusman pushed a commit to mzusman/vllm that referenced this pull request Mar 12, 2025
# for free to join this conversation on GitHub. Already have an account? # 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]: Speculative decoding generate gibberish when receiving parallel requests with different seeds
3 participants