Skip to content

[Bugfix] Release cached cuBLAS workspaces after daemon warmup - #63451

Merged
Isotr0py merged 5 commits into
vllm-project:mainfrom
tryryry:fix/daemon-cublas-workspace-cleanup
Oct 25, 2026
Merged

Isotr0py merged 5 commits into
vllm-project:mainfrom
tryryry:fix/daemon-cublas-workspace-cleanup

Conversation

@tryryry

@tryryry tryryry commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Release cached cuBLAS/cuBLASLt workspaces after weight-cache daemon warmup, before accepting engine connections.

Follow-up to #62583: communication teardown leaves PyTorch-owned BLAS workspaces resident even though the daemon no longer performs inference.

Claims

  • Release cached BLAS workspaces after daemon warmup while preserving CUDA IPC weights, allowing unused allocator segments to be returned to the GPU driver.

Validation

Memory comparison

nvidia/Qwen3-30B-A3B-NVFP4, B300, TP=4, gpu_memory_utilization=0.1, max_model_len=8192, max_num_batched_tokens=16384, max_num_seqs=1024.

“Before” includes #62583. Memory figures are per GPU / daemon process.

Metric Disk load Daemon before Daemon after
Available KV cache 18.90 GiB / 1,651,280 tokens 18.92 GiB / 1,653,488 tokens 18.92 GiB / 1,653,488 tokens
Loaded / exported weights 4,357.92 MiB loaded 4,340.77 MiB exported 4,340.77 MiB exported
PyTorch allocated memory, cold cache — 4,419.98 MiB 4,387.98 MiB (−32)
PyTorch allocated memory, warm cache — 4,419.80 MiB 4,387.80 MiB (−32)
Daemon NVML memory, cold cache — 5,674 MiB 5,674 MiB
Daemon NVML memory, warm cache — 5,694 MiB 5,566 MiB (−128)

Workspace allocations decreased by 32 MiB per daemon. NVML savings depend on allocator fragmentation; KV capacity and exported weights remained unchanged.

These development measurements used different B300 GPU sets and base revisions (c569393ed2 / 404c2b510e, with unchanged daemon code). Externally disturbed baseline runs were excluded from the KV comparison. Results are individual observations, not repeated-run averages.

Final implementation validation

Qwen/Qwen3.5-0.8B, B300, TP=4, compilation enabled, utilization=0.06, maximum length=8192, batched tokens=2048, maximum sequences=32.

Metric Disk load Cold daemon + IPC Warm restarted daemon + IPC
Available KV cache 13.82 GiB / 1,766,663 tokens 13.85 GiB / 1,769,706 tokens 13.85 GiB / 1,769,706 tokens
Daemon NVML memory — 1,638 MiB 1,604 MiB
Daemon ranks ready — 4/4 4/4
Generated tokens Reference Identical Identical

All five runs—cold/warm disk, cold IPC, warm IPC with the existing daemon, and warm IPC after daemon restart—completed successfully with identical 32-token outputs. Exported weight sizes remained unchanged. This is targeted correctness validation, not a broad accuracy evaluation; the disk/IPC KV difference is not attributed to this fix.

Tests

CUDA_VISIBLE_DEVICES=5 OMP_NUM_THREADS=1 \
VLLM_WORKER_MULTIPROC_METHOD=spawn \
.venv/bin/python -m pytest \
  tests/model_executor/model_loader/test_weight_cache.py::test_daemon_releases_cublas_workspaces \
  'tests/model_executor/model_loader/test_weight_cache.py::test_ipc_cache_cold_start_and_warm_restart[qwen3.5]' \
  -v -s

2 passed. The development reproducer failed without the fix with daemon retained BLAS workspaces. A separate two-stream probe released 16 MiB with GPU work pending at cleanup entry and preserved correct outputs.

.venv/bin/pre-commit run --files \
  vllm/model_executor/model_loader/weight_cache/daemon.py \
  tests/model_executor/model_loader/test_weight_cache.py \
  docs/features/preload.md

All checks passed.

Details

PyTorch caches BLAS workspaces independently of model tensors, so garbage collection and empty_cache() cannot release them while those caches retain ownership.

This change clears the caches after communication teardown and before the existing empty_cache(). Cleanup is CUDA-only and uses getattr to skip gracefully when the private PyTorch API is unavailable. No additional explicit device synchronization is introduced.

Duplicate-work searches found no equivalent open fix. Related #52553 addresses workspace address stability during graph execution; this PR releases caches after daemon warmup has finished.

AI assistance was used for implementation, investigation, validation, and this description.


Pull Request Checklist
  • I used vLLM's /pr-checklist skill. (Mandatory for agents, optional for humans).

  • AI assistance was used during the creation of this PR.

  • Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.

  • Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.

  • Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.

  • Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.

tryryry and others added 2 commits October 24, 2026 04:21
Release PyTorch BLAS workspace caches before empty_cache so warmup scratch does not remain resident in the weight cache daemon. Add a regression using the existing Qwen model and document the cleanup behavior.

Co-authored-by: Codex
Signed-off-by: lichongmin <chongminli.cn@gmail.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions

Copy link
Copy Markdown

👋 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.

PRs do not trigger a full CI run by default. Reviewers with write access and configured trusted contributors can comment /ci run for upstream CI or /amd-ci run for AMD CI only whenever CI signals are needed.

Once the PR is approved or has the ready label, the PR author can also use the corresponding /ci run, /ci retry, and /ci cancel commands, or their /amd-ci variants. New commits do not start upstream CI automatically.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

Agent Guidelines

IMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban.

🚀

@mergify

mergify Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Documentation preview: https://vllm--63451.org.readthedocs.build/en/63451/

@mergify mergify Bot added the documentation Improvements or additions to documentation label Oct 24, 2026
@tryryry tryryry changed the title Fix/daemon cublas workspace cleanup [Bugfix] Release cached cuBLAS workspaces after daemon warmup Oct 24, 2026
@mergify mergify Bot added the bug Something isn't working label Oct 24, 2026

@Isotr0py Isotr0py left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

@Isotr0py Isotr0py added the ready ONLY add when PR is ready to merge/full CI is needed label Oct 24, 2026
@Isotr0py

Copy link
Copy Markdown
Member

/ci run

@github-actions

Copy link
Copy Markdown

✅ @tryryry, CI is now available for this PR.

  • /ci run starts upstream CI; /amd-ci run starts AMD CI only.
  • Run commands test your branch with every commit currently on its upstream target branch. If it is behind, the bot merges the target branch into it first (pull before pushing again). Append --allow-stale to a run command to test an outdated branch as is, at your own risk.
  • /ci retry retries failed jobs in the CI build for the current PR head. If the current head has no CI build, it starts a new CI build for the current head containing only jobs that failed in the latest earlier CI build for this PR.
  • /amd-ci retry retries failed jobs in AMD CI for the current PR head. Use /amd-ci run when the current head has no AMD CI build.
  • /ci cancel cancels scheduled or running CI builds for this PR branch; /amd-ci cancel does the same for AMD CI only.

@Isotr0py
Isotr0py enabled auto-merge (squash) October 24, 2026 06:50
@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #97024 for commit e319eacef271.

ℹ️ This PR is 5 commits behind upstream main. Merged upstream main into this branch as e319eacef271 before starting CI. Pull the branch before pushing more changes.

@Isotr0py

Copy link
Copy Markdown
Member

/ci retry

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #97047 for commit 5c05d69b0638, running 1 failed step(s) from Buildkite CI #97024.

@mergify

mergify Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

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

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 Oct 25, 2026
Resolve the preload documentation conflict by retaining both the BLAS workspace cleanup description and D2D warmup cache seeding instructions.

Co-authored-by: Codex

Signed-off-by: lichongmin <chongminli.cn@gmail.com>
auto-merge was automatically disabled October 25, 2026 14:16

Head branch was pushed to by a user without write access

@mergify mergify Bot removed the needs-rebase label Oct 25, 2026
@Isotr0py
Isotr0py enabled auto-merge (squash) October 25, 2026 14:33
@Isotr0py

Copy link
Copy Markdown
Member

/ci retry

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #97138 for commit 61d2b9980d73, running 1 failed step(s) from Buildkite CI #97047.

@Isotr0py
Isotr0py merged commit b346636 into vllm-project:main Oct 25, 2026
16 checks passed
gaby added a commit to gaby/vllm that referenced this pull request Oct 25, 2026
…s usage

Restructure docs/features/preload.md around operating the weight cache
daemon and add the missing deployment documentation.

- Add Docker, Docker Compose and Kubernetes deployment: running the
  daemon and the engine as separate containers, the IPC and PID namespace
  requirements, the shared volume for the sockets and the FlashInfer
  autotune cache, and the probes.
- Document the /health endpoint, the loader and daemon configuration
  tables, the start order, GPU memory accounting and troubleshooting.
- Integrate the FlashInfer autotune preloading from vllm-project#60085. Readiness now
  includes tuning, and the engine finds the tuned configs through the
  autotune cache location.
- Integrate the daemon-to-daemon warmup cache seeding from vllm-project#63088: the
  seeding flags, the start order, the Docker ports, and what a mirror
  logs when it falls back to local tuning.
- Describe the daemon memory handling from vllm-project#62583 and vllm-project#63451: the engine
  counts only the exported weights, and the daemon releases its process
  groups and cached cuBLAS workspaces after loading and tuning.
- Update the fingerprint description for the RoPE parameters, expert
  parallelism, KV cache dtype settings and dense data parallel keying,
  and document that EPLB is not supported.
- Correct statements that did not match the code: pipeline parallelism is
  supported, copy mode releases the daemon's cache after the first
  handoff, and the quantization support list now follows the code.
- Add pointers from the Docker deployment guide, the faster-startup list
  and the CLI reference.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MZTcfM8JsFUMWPHCsoLsuE
Signed-off-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
Micador pushed a commit to Micador/vllm that referenced this pull request Oct 27, 2026
…roject#63451)

Signed-off-by: lichongmin <chongminli.cn@gmail.com>
Co-authored-by: vllm-agent <claw@inferact.ai>
Signed-off-by: Christopher Mackenzie <christopher.mackenzie.software@gmail.com>
Micador pushed a commit to Micador/vllm that referenced this pull request Oct 27, 2026
…roject#63451)

Signed-off-by: lichongmin <chongminli.cn@gmail.com>
Co-authored-by: vllm-agent <claw@inferact.ai>
Signed-off-by: Christopher Mackenzie <christopher.mackenzie.software@gmail.com>
Micador pushed a commit to Micador/vllm that referenced this pull request Oct 27, 2026
…roject#63451)

Signed-off-by: lichongmin <chongminli.cn@gmail.com>
Co-authored-by: vllm-agent <claw@inferact.ai>
Signed-off-by: Christopher Mackenzie <christopher.mackenzie.software@gmail.com>
gaby added a commit to gaby/vllm that referenced this pull request Oct 30, 2026
…s usage

Restructure docs/features/preload.md around operating the weight cache
daemon and add the missing deployment documentation.

- Add Docker, Docker Compose and Kubernetes deployment: running the
  daemon and the engine as separate containers, the IPC and PID namespace
  requirements, the shared volume for the sockets and the FlashInfer
  autotune cache, and the probes.
- Document the /health endpoint, the loader and daemon configuration
  tables, the start order, GPU memory accounting and troubleshooting.
- Integrate the FlashInfer autotune preloading from vllm-project#60085. Readiness now
  includes tuning, and the engine finds the tuned configs through the
  autotune cache location.
- Integrate the daemon-to-daemon warmup cache seeding from vllm-project#63088: the
  seeding flags, the start order, the Docker ports, and what a mirror
  logs when it falls back to local tuning.
- Describe the daemon memory handling from vllm-project#62583 and vllm-project#63451: the engine
  counts only the exported weights, and the daemon releases its process
  groups and cached cuBLAS workspaces after loading and tuning.
- Describe how `vllm preload` stops every rank when one exits (vllm-project#63692),
  what a zero-copy engine does when its daemon exits (vllm-project#62734), and the
  kernel backends that vllm-project#63506 added to the fingerprint.
- Update the fingerprint description for the RoPE parameters, expert
  parallelism, KV cache dtype settings and dense data parallel keying,
  and document that EPLB is not supported.
- Correct statements that did not match the code: pipeline parallelism is
  supported, copy mode releases the daemon's cache after the first
  handoff, and the quantization support list now follows the code.
- Add pointers from the Docker deployment guide, the faster-startup list
  and the CLI reference.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MZTcfM8JsFUMWPHCsoLsuE
Signed-off-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation 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.

3 participants