vllm - ✅(Solved) Fix [Bug]: [OOM] DeepSeek-R1 Out of Memory [1 pull requests, 1 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#37777Fetched 2026-04-08 01:12:56
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Author
Participants
Timeline (top)
added_to_project_v2 ×1commented ×1cross-referenced ×1labeled ×1

Error Message

vllm bench serve
--host localhost --port 8000
--tokenizer nvidia/DeepSeek-R1-0528-NVFP4
--trust-remote-code --dataset-name random
--random-input-len 2000 --random-output-len 1000
--ignore-eos --max-concurrency 128
--request-rate inf --num-prompts 640

Server crashes with: MemoryError: CUDA out of memory. Tried to allocate 3.94 GiB. GPU has 184.00 GiB total, 2.38 GiB free.

Root Cause

Likely caused by https://github.com/vllm-project/vllm/pull/37442#issuecomment-4104485267 Creating an issue in case someone is also searching for this

Fix Action

Fixed

PR fix notes

PR #37805: [Fix] Share decode output buffer across MLA layers to reduce memory

Description (problem / solution / changelog)

The NaN fix (PR #37442) allocated a persistent _decode_out buffer per attention layer. For DeepSeek-R1 (61 layers), this totals ~15 GiB of GPU memory that is not accounted for during profiling, causing OOM when KV cache + buffers exceed available memory.

This fix uses a single module-level buffer shared across all layers. Memory drops from ~15 GiB to ~256 MiB. The buffer is only written by one layer at a time (sequential forward pass), so sharing is safe.

Changes:

  • CUTLASS MLA: Add SM100DecodeOutBuffer class with shared buffer
  • FlashInfer MLA: Add FlashInferDecodeOutBuffer class with shared buffer
  • Both implementations now use g_*_decode_out global instance

Fixes #37777

Purpose

Test Plan

Test Result


<details> <summary> Essential Elements of an Effective PR Description Checklist </summary>
  • 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.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.
</details>

Changed files

  • vllm/v1/attention/backends/mla/cutlass_mla.py (modified, +37/-13)
  • vllm/v1/attention/backends/mla/flashinfer_mla.py (modified, +46/-17)

Code Example

export VLLM_USE_FLASHINFER_MOE_FP4=1
  export VLLM_USE_NCCL_SYMM_MEM=1
  export NCCL_NVLS_ENABLE=1
  export NCCL_CUMEM_ENABLE=1

  python3 -m vllm.entrypoints.openai.api_server \
    --host 0.0.0.0 --port 8000 \
    --model nvidia/DeepSeek-R1-0528-NVFP4 \
    --trust-remote-code --no-enable-prefix-caching \
    --dtype auto --kv-cache-dtype fp8 \
    --tensor-parallel-size 1 --data-parallel-size 4 \
    --max-num-seqs 1024 --max-model-len 10240 \
    --gpu-memory-utilization 0.9 \
    --max-num-batched-tokens 8192 \
    --enable-expert-parallel --async-scheduling \
    --compilation_config.max_cudagraph_capture_size 2048 \
    --compilation_config.cudagraph_mode FULL_DECODE_ONLY

---

vllm bench serve \
    --host localhost --port 8000 \
    --tokenizer nvidia/DeepSeek-R1-0528-NVFP4 \
    --trust-remote-code --dataset-name random \
    --random-input-len 2000 --random-output-len 1000 \
    --ignore-eos --max-concurrency 128 \
    --request-rate inf --num-prompts 640

Server crashes with:
  MemoryError: CUDA out of memory. Tried to allocate 3.94 GiB. GPU has 184.00 GiB total, 2.38 GiB free.
RAW_BUFFERClick to expand / collapse

Your current environment

4xGB200, vllm nightly, cu130

🐛 Describe the bug

Likely caused by https://github.com/vllm-project/vllm/pull/37442#issuecomment-4104485267 Creating an issue in case someone is also searching for this

  export VLLM_USE_FLASHINFER_MOE_FP4=1
  export VLLM_USE_NCCL_SYMM_MEM=1
  export NCCL_NVLS_ENABLE=1
  export NCCL_CUMEM_ENABLE=1

  python3 -m vllm.entrypoints.openai.api_server \
    --host 0.0.0.0 --port 8000 \
    --model nvidia/DeepSeek-R1-0528-NVFP4 \
    --trust-remote-code --no-enable-prefix-caching \
    --dtype auto --kv-cache-dtype fp8 \
    --tensor-parallel-size 1 --data-parallel-size 4 \
    --max-num-seqs 1024 --max-model-len 10240 \
    --gpu-memory-utilization 0.9 \
    --max-num-batched-tokens 8192 \
    --enable-expert-parallel --async-scheduling \
    --compilation_config.max_cudagraph_capture_size 2048 \
    --compilation_config.cudagraph_mode FULL_DECODE_ONLY
  vllm bench serve \
    --host localhost --port 8000 \
    --tokenizer nvidia/DeepSeek-R1-0528-NVFP4 \
    --trust-remote-code --dataset-name random \
    --random-input-len 2000 --random-output-len 1000 \
    --ignore-eos --max-concurrency 128 \
    --request-rate inf --num-prompts 640

Server crashes with:
  MemoryError: CUDA out of memory. Tried to allocate 3.94 GiB. GPU has 184.00 GiB total, 2.38 GiB free.

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 resolve the MemoryError: CUDA out of memory issue, we need to optimize the memory utilization of the VLLM server. Here are the steps:

  • Reduce the --max-num-seqs and --max-num-batched-tokens parameters to decrease the memory requirements:
    • --max-num-seqs 512
    • --max-num-batched-tokens 4096
  • Decrease the --gpu-memory-utilization to prevent over-allocation of GPU memory:
    • --gpu-memory-utilization 0.7
  • Consider reducing the --random-input-len and --random-output-len parameters in the benchmarking command to reduce memory usage:
    • --random-input-len 1000
    • --random-output-len 500
  • Update the compilation_config to reduce the max_cudagraph_capture_size:
    • --compilation_config.max_cudagraph_capture_size 1024

Example updated command:

python3 -m vllm.entrypoints.openai.api_server \
  --host 0.0.0.0 --port 8000 \
  --model nvidia/DeepSeek-R1-0528-NVFP4 \
  --trust-remote-code --no-enable-prefix-caching \
  --dtype auto --kv-cache-dtype fp8 \
  --tensor-parallel-size 1 --data-parallel-size 4 \
  --max-num-seqs 512 --max-model-len 10240 \
  --gpu-memory-utilization 0.7 \
  --max-num-batched-tokens 4096 \
  --enable-expert-parallel --async-scheduling \
  --compilation_config.max_cudagraph_capture_size 1024 \
  --compilation_config.cudagraph_mode FULL_DECODE_ONLY

Verification

Run the updated command and monitor the GPU memory usage to ensure it does not exceed the available memory. You can use tools like nvidia-smi to monitor the GPU memory usage.

Extra Tips

  • Regularly monitor the GPU memory usage and adjust the parameters as needed to prevent out-of-memory errors.
  • Consider using a more efficient model or optimizing the model architecture to reduce memory requirements.
  • If the issue persists, try reducing the --num-prompts parameter in the benchmarking command to decrease the load on the server.

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

vllm - ✅(Solved) Fix [Bug]: [OOM] DeepSeek-R1 Out of Memory [1 pull requests, 1 comments, 2 participants]