Skip to content

[Bugfix] Restore engine memory budget after IPC fallback - #63488

Open
tryryry wants to merge 3 commits into
vllm-project:mainfrom
tryryry:fix/ipc-fallback-memory-budget
Open

tryryry wants to merge 3 commits into
vllm-project:mainfrom
tryryry:fix/ipc-fallback-memory-budget

Conversation

@tryryry

@tryryry tryryry commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Overview

Fix reduced KV cache capacity when IPC weight loading falls back to disk after external weights have already been charged against the engine's memory budget.

Follow-up to #62583.

Claims

  • Restore the engine budget after disk fallback.
  • Remove only the external weight charge for the model that falls back to disk, then recheck the engine’s memory budget.

Validation

Qwen3-0.6B on NVIDIA B300, TP1, eager mode, gpu_memory_utilization=0.1, maximum length 1024, and FlashInfer autotune disabled.

The daemon uses BF16; both engines use FP16. The dtype mismatch triggers IPC fallback. The same daemon remains running during both disk and fallback runs.

Metric Direct disk load Fallback before Fallback after
Engine memory budget 26.77 GiB 25.65 GiB 26.77 GiB
Available KV cache 25.50 GiB 24.38 GiB 25.50 GiB
Generated output Reference Identical Identical

The regression test fails without the fix:

AssertionError: Disk fallback retained the external weight charge
assert 27539026292 == 28741612340

With the fix:

  • Focused regression and accounting tests: 6 passed.
  • MRV1 regression: 1 passed; the default MRV2 path also passes.
  • Related worker and weight-cache tests: 41 passed, 1 skipped.
  • Separate disk, zero-copy, absent-daemon fallback, and copy-mode runs completed with identical eight-token outputs and expected accounting.
  • All pre-commit checks passed.

Reproduce the regression:

CUDA_VISIBLE_DEVICES=7 OMP_NUM_THREADS=1 \
VLLM_WORKER_MULTIPROC_METHOD=spawn \
.venv/bin/python -m pytest \
  tests/model_executor/model_loader/test_weight_cache.py::test_ipc_fallback_restores_memory_budget \
  -v -s

Repeat with VLLM_USE_V2_MODEL_RUNNER=0 for MRV1.

The regression extends the existing weight-cache suite selected by Model Executor CI. Partial target/draft fallback is covered by accounting unit tests; mixed-role end-to-end validation has not been performed.

Details

The worker queries external weight memory before loading the model. If IPC loading later falls back to disk, the original external charge remains while locally loaded weights are included in profiling, unnecessarily reducing KV capacity.

A scoped accounting object records charges by daemon socket and role. After disk loading succeeds, the IPC loader removes that source's charge once. The worker then recalculates its budget before KV profiling, retaining the original memory snapshot and capacity checks.

gpu_worker.py changes are limited to querying the accounting object, activating it during loading, and applying an updated budget. The KV profiling formula and daemon lifecycle are unchanged. The preload documentation describes the corrected behavior.

Duplicate-work searches found no equivalent budget fix. Related #59813 restores model state after IPC construction failures; this change corrects memory accounting after successful fallback.

AI assistance was used for implementation, review, and validation.

———

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.

BEFORE SUBMITTING, PLEASE READ https://docs.vllm.ai/en/latest/contributing (anything written below this line will be removed by GitHub Actions)

@tryryry
tryryry requested a review from njhill as a code owner October 24, 2026 15:16

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

@mergify

mergify Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

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

@mergify mergify Bot added documentation Improvements or additions to documentation bug Something isn't working labels Oct 24, 2026
@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 26, 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 26, 2026
@tryryry
tryryry force-pushed the fix/ipc-fallback-memory-budget branch from ce66d58 to 53a32bc Compare October 26, 2026 06:20
@mergify mergify Bot removed the needs-rebase label Oct 26, 2026
@mergify

mergify Bot commented Oct 31, 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 31, 2026
Track external weight charges during startup and remove the corresponding
charge after a successful disk fallback. Recheck the engine budget before
KV cache profiling, preserving charges for other daemon roles.

Co-authored-by: Codex
Signed-off-by: lichongmin <chongminli.cn@gmail.com>
Initialize empty accounting in the shared worker constructor so CPU and
XPU workers can inherit load_model without depending on GPU device setup.
Add a regression using the real worker constructor.

Validation: constructor regression fails before and passes after; related
tests report 42 passed and 1 skipped; Qwen3-0.6B GPU fallback passes.
CPU Qwen3-0.6B reproduces the missing-field error before the fix, then
loads and generates successfully with both MRV1 and MRV2 after the fix.
The two CPU runners produce identical tokens. Pre-commit checks pass.
XPU hardware validation remains unavailable.

Co-authored-by: Codex
Signed-off-by: lichongmin <chongminli.cn@gmail.com>
@tryryry
tryryry force-pushed the fix/ipc-fallback-memory-budget branch from 53a32bc to 17d29a6 Compare October 31, 2026 08:02
@mergify mergify Bot removed the needs-rebase label Oct 31, 2026
Replace the deprecated Iterator return annotation on track_load with
Generator[None, None, None], preserving its runtime behavior.

Validation: 65 regression tests passed, including Qwen3-0.6B IPC fallback;
8 integration cases were deselected. An unrelated D2D shutdown thread
warning remains in seed.py. Ruff checks and formatting passed.

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

This branch has not been deployed

No deployments
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant