vllm - 💡(How to fix) Fix [Bug]: chunked prefill can't be disabled. maybe due to race condition in scheduler [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vllm-project/vllm#38348Fetched 2026-04-08 01:41:55
View on GitHub
Comments
2
Participants
2
Timeline
4
Reactions
0
Timeline (top)
commented ×2closed ×1labeled ×1

Code Example

import os

// if use VLLM_ENABLE_V1_MULTIPROCESSING will cause chunked prefill can't be disabled
// only add this environment variable can make sure chunked prefill is disabled.

//os.environ["VLLM_ENABLE_V1_MULTIPROCESSING"] = "0"

os.environ["VLLM_LOGGING_LEVEL"] = "DEBUG"

import argparse
from datetime import datetime

import torch
from vllm import LLM, SamplingParams


def main():
    parser = argparse.ArgumentParser()

    // some args parse here

    args = parser.parse_args()

    timestamp = datetime.now().strftime("%m%d%H%M%S")
    profile_dir = os.path.abspath(f"profile_{timestamp}")
    os.makedirs(profile_dir, exist_ok=True)

    max_model_len = args.seqlen + args.max_tokens

    llm = LLM(
        model=args.model,
        tensor_parallel_size=args.tp,
        load_format="dummy",
        dtype="bfloat16",
        enforce_eager=True,
        max_model_len=max_model_len,
        max_num_seqs=args.bs,
        max_num_batched_tokens=args.bs * max_model_len,
        enable_chunked_prefill=False,
        enable_prefix_caching=False,
        profiler_config={
            "profiler": "torch",
            "torch_profiler_dir": profile_dir,
            "torch_profiler_with_stack": True,
            "torch_profiler_record_shapes": True,
        },
    )

    vocab_size = llm.llm_engine.model_config.get_vocab_size()
    input_ids = torch.randint(0, vocab_size, (args.seqlen,)).tolist()
    sampling_params = SamplingParams(max_tokens=args.max_tokens)
    prompts = [{"prompt_token_ids": input_ids} for _ in range(args.bs)]

    # Warmup
    for i in range(args.warmup):
        print(f"Warmup {i + 1}/{args.warmup}")
        llm.generate(prompts=prompts, sampling_params=sampling_params)
    torch.cuda.synchronize()

    # Profile
    print(f"Profiling batch size {args.bs}... traces will be saved to {profile_dir}")
    llm.start_profile(profile_prefix=f"mixed_precision_{timestamp}")
    llm.generate(prompts=prompts, sampling_params=sampling_params)
    torch.cuda.synchronize()
    llm.stop_profile()
    print(f"Profile saved to {profile_dir}")


if __name__ == "__main__":
    main()
RAW_BUFFERClick to expand / collapse

Your current environment

vLLM 0.17.0 python 3.12

🐛 Describe the bug

I want to disable chunked prefill. so i set the max_model_length to (seqlen + max_tokens), max_num_seqs to batch size, max_num_batched_tokens to (batch size * max_model_len)。However I still find the req chunked when i look at the log. But When set the os.environ["VLLM_ENABLE_V1_MULTIPROCESSING"] = "0" chunked prefill will be disabled. looks like a bug to me.

import os

// if use VLLM_ENABLE_V1_MULTIPROCESSING will cause chunked prefill can't be disabled
// only add this environment variable can make sure chunked prefill is disabled.

//os.environ["VLLM_ENABLE_V1_MULTIPROCESSING"] = "0"

os.environ["VLLM_LOGGING_LEVEL"] = "DEBUG"

import argparse
from datetime import datetime

import torch
from vllm import LLM, SamplingParams


def main():
    parser = argparse.ArgumentParser()

    // some args parse here

    args = parser.parse_args()

    timestamp = datetime.now().strftime("%m%d%H%M%S")
    profile_dir = os.path.abspath(f"profile_{timestamp}")
    os.makedirs(profile_dir, exist_ok=True)

    max_model_len = args.seqlen + args.max_tokens

    llm = LLM(
        model=args.model,
        tensor_parallel_size=args.tp,
        load_format="dummy",
        dtype="bfloat16",
        enforce_eager=True,
        max_model_len=max_model_len,
        max_num_seqs=args.bs,
        max_num_batched_tokens=args.bs * max_model_len,
        enable_chunked_prefill=False,
        enable_prefix_caching=False,
        profiler_config={
            "profiler": "torch",
            "torch_profiler_dir": profile_dir,
            "torch_profiler_with_stack": True,
            "torch_profiler_record_shapes": True,
        },
    )

    vocab_size = llm.llm_engine.model_config.get_vocab_size()
    input_ids = torch.randint(0, vocab_size, (args.seqlen,)).tolist()
    sampling_params = SamplingParams(max_tokens=args.max_tokens)
    prompts = [{"prompt_token_ids": input_ids} for _ in range(args.bs)]

    # Warmup
    for i in range(args.warmup):
        print(f"Warmup {i + 1}/{args.warmup}")
        llm.generate(prompts=prompts, sampling_params=sampling_params)
    torch.cuda.synchronize()

    # Profile
    print(f"Profiling batch size {args.bs}... traces will be saved to {profile_dir}")
    llm.start_profile(profile_prefix=f"mixed_precision_{timestamp}")
    llm.generate(prompts=prompts, sampling_params=sampling_params)
    torch.cuda.synchronize()
    llm.stop_profile()
    print(f"Profile saved to {profile_dir}")


if __name__ == "__main__":
    main()

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

extent analysis

Fix Plan

To disable chunked prefill, you need to set the environment variable VLLM_ENABLE_V1_MULTIPROCESSING to "0" before creating the LLM object.

Here are the steps:

  • Set the environment variable VLLM_ENABLE_V1_MULTIPROCESSING to "0":

os.environ["VLLM_ENABLE_V1_MULTIPROCESSING"] = "0"

* Ensure that `enable_chunked_prefill` is set to `False` when creating the `LLM` object:
  ```python
llm = LLM(
    # ... other arguments ...
    enable_chunked_prefill=False,
    # ... other arguments ...
)
  • Verify that the max_model_len, max_num_seqs, and max_num_batched_tokens are set correctly:

max_model_len = args.seqlen + args.max_tokens llm = LLM( # ... other arguments ... max_model_len=max_model_len, max_num_seqs=args.bs, max_num_batched_tokens=args.bs * max_model_len, # ... other arguments ... )


### Verification
To verify that chunked prefill is disabled, check the logs for any indications of chunking. You can also add additional logging or debugging statements to confirm that the `LLM` object is not using chunked prefill.

### Extra Tips
* Make sure to set the environment variable `VLLM_ENABLE_V1_MULTIPROCESSING` to `"0"` before creating the `LLM` object, as setting it afterwards may not have the desired effect.
* If you are still experiencing issues, try setting the logging level to `DEBUG` to get more detailed logs:
  ```python
os.environ["VLLM_LOGGING_LEVEL"] = "DEBUG"

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING