Skip to content

[Bugfix][EPD][Model Runner V2] Skip gather mm embeddings for encoder only instance - #51222

Merged
ywang96 merged 6 commits into
vllm-project:mainfrom
gty111:fix/ec-producer-cache-item
Aug 7, 2026
Merged

ywang96 merged 6 commits into
vllm-project:mainfrom
gty111:fix/ec-producer-cache-item

Conversation

@gty111

@gty111 gty111 commented Aug 6, 2026 •

Copy link
Copy Markdown
Collaborator

Purpose

An EPD encoder instance dies with RuntimeError: Encoder cache miss as soon as it
is handed a multi-modal item the EC connector already holds.

  gpu/model_runner.py:1392  → model_state.get_mm_embeddings(...)
  gpu/mm/encoder_runner.py:180 → raise RuntimeError(f"Encoder cache miss for {mm_hash}.")
ERROR core.py:1347  EngineCore encountered a fatal error.

The whole instance goes down, not just the request: everything after it gets a
connection error.

Root cause. When ec_connector.has_cache_item() is true the scheduler stops
scheduling that item for encoding (scheduler.py:1610) — correct, the embedding
is already published. But the V2 runner then calls get_mm_embeddings()
before its is_encoder_only early return, and the gather inside it raises for
any scheduled item missing from the local encoder cache.
The gather is pure waste here — an encoder instance runs no language model, so
the inputs_embeds it builds is discarded by the very next line. V1 never had
the bug because its producer path returns before the gather
(gpu_model_runner.py:4206).

Fix. Give the encoder instance the encode half only. No scheduler change, so
a producer still skips re-encoding what the connector already has.

if self.is_encoder_only:
    self.model_state.execute_mm_encoder(scheduled_encoder_inputs)
else:
    inputs_embeds = self.model_state.get_mm_embeddings(...)

Reproduce

Two encoder instances sharing one shared_storage_path — what
disagg_epd_proxy.py builds from several --encode-servers-urls, since it
round-robins across them:

# E1 and E2, both ec_producer, same shared_storage_path
curl -s -o /dev/null -w "%{http_code}\n" localhost:19614/v1/chat/completions -d "$IMAGE_REQ"  # 200
curl -s -o /dev/null -w "%{http_code}\n" localhost:19615/v1/chat/completions -d "$IMAGE_REQ"  # 500, E2 is dead

Also reached by any instance whose local encoder cache lacks an entry the
connector kept — e.g. a restart with warm shared storage.

Test

Two regression tests, each checked by reverting the behaviour it pins:

  • tests/v1/worker/test_encoder_runner.py — execute_mm_encoder caches encoder
    outputs and never gathers. Making it gather fails the test.
  • tests/v1/core/test_scheduler.py — neither role re-encodes an item the
    connector already holds. This pins the optimisation the obvious "make the
    producer encode anyway" fix would destroy.
.venv/bin/python -m pytest tests/v1/worker/test_encoder_runner.py -q   # 9 passed
.venv/bin/python -m pytest tests/v1/core/test_scheduler.py -q          # 141 passed
.venv/bin/python -m pytest tests/v1/ec_connector/unit -q               # 133 passed

End-to-end, Qwen2.5-VL-3B, the two-encoder repro above:

before after
E1 first sighting 200 200
E2, same image 500 200
E2 liveness 000 (process gone) 200
Encoder cache miss / fatal error in E2 log 2 / 1 0 / 0

save_caches does not fire on E2 in either arm, so the skip-re-encode
optimisation is untouched.


Essential Elements of an Effective PR Description Checklist
  • 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.

Signed-off-by: Tianyu Guo <guoty@inferact.ai>
Copilot AI lite review requested due to automatic review settings August 6, 2026 03:25

@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 added mrv2 Model Runner V2 specific bug Something isn't working labels Aug 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a crash in the V1 GPU Model Runner V2 path for encoder-only EPD instances by avoiding an unnecessary multimodal embedding gather that can raise Encoder cache miss when the EC connector already has the item. This keeps the encoder instance alive and preserves the scheduler optimization that skips redundant re-encoding.

Changes:

  • Add ModelState.encode_mm_inputs(...) as an “encode-only” helper (no gather) and refactor DefaultModelState.get_mm_embeddings(...) to use it.
  • Update ModelRunner.execute_model(...) to call encode_mm_inputs(...) and skip get_mm_embeddings(...) for is_encoder_only instances.
  • Add regression tests covering (a) encode-only behavior and (b) scheduler behavior when the connector already has the cache item.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vllm/v1/worker/gpu/model_states/interface.py Adds encode_mm_inputs helper to run the MM encoder and cache outputs without gathering.
vllm/v1/worker/gpu/model_states/default.py Refactors MM embedding path to reuse encode_mm_inputs before gathering.
vllm/v1/worker/gpu/model_runner.py Skips gather/get-mm-embeddings for encoder-only instances; only encodes + publishes via EC connector.
tests/v1/worker/test_encoder_runner.py Adds tests asserting encoder-only encode caches outputs and doesn’t gather.
tests/v1/core/test_scheduler.py Adds test ensuring scheduler skips encoder inputs when the connector already has the item (both roles).
Suppressed comments (1)

tests/v1/worker/test_encoder_runner.py:217

  • Same as above: prepare_mm_inputs returns (mm_hashes: list[str], mm_kwargs: list[tuple[str, MultiModalKwargsItem]]), so the empty case should be ([], []) rather than ([], {}).
    state.encoder_runner.prepare_mm_inputs.return_value = ([], {})

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/v1/worker/test_encoder_runner.py Resolved

@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, leave a nit

Signed-off-by: Tianyu Guo <guoty@inferact.ai>
@gty111 gty111 added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 6, 2026
@gty111

gty111 commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

/ci run

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

✅ Triggered Buildkite CI #82644 for commit 22421e76570f.

@gty111

gty111 commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

/ci retry

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

✅ Queued 1 failed job(s) for retry in Buildkite CI #82644.

@gty111

gty111 commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

/ci retry

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

✅ Triggered Buildkite CI #82745 for commit afc68ab85005, running 1 failed step(s) from Buildkite CI #82644.

@mergify

mergify Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Hi @gty111, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

gty111 added 2 commits August 6, 2026 23:59
markdownlint (MD032) rejects the lists introduced by vllm-project#51300, which fails
`pre-commit run --all-files` on every PR.

Signed-off-by: Tianyu Guo <guoty@inferact.ai>
@mergify

mergify Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

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

@mergify mergify Bot added the documentation Improvements or additions to documentation label Aug 7, 2026
@gty111

gty111 commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

/ci retry

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

✅ Buildkite CI #82745 failed during CI setup, so its test failure set is incomplete. Use /ci run for the new commit.

@gty111

gty111 commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

/ci run

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

✅ Triggered Buildkite CI #82753 for commit 7bafb55345bf.

@gty111

gty111 commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

/ci retry

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

✅ Queued 1 failed job(s) for retry in Buildkite CI #82753.

@ywang96
ywang96 merged commit dd856e4 into vllm-project:main Aug 7, 2026
95 checks passed
michael-gpu pushed a commit to practical-inference/vllm-ampere-extended that referenced this pull request Oct 20, 2026
…only instance (vllm-project#51222)

Signed-off-by: Tianyu Guo <guoty@inferact.ai>
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 mrv2 Model Runner V2 specific 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.

4 participants