vllm - ✅(Solved) Fix [Bug]: prefix_caching_hash_algo="xxhash" silently returns empty outputs when xxhash not installed [1 pull requests, 1 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#39785Fetched 2026-04-16 06:36:39
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1

Error Message

When prefix_caching_hash_algo is set to "xxhash" or "xxhash_cbor" but the xxhash package is not installed, LLM.generate() silently returns empty outputs for requests that trigger prefix caching — no exception is raised to the caller.

Root Cause

Root cause: The ModuleNotFoundError in vllm/utils/hashing.py is raised at hash-computation time during request preprocessing, where it gets caught as a preprocessing failure and silently converted to an empty output.

Fix Action

Fixed

PR fix notes

PR #39786: [Bugfix] Raise ImportError early when xxhash is unavailable for prefix caching

Description (problem / solution / changelog)

Summary

Fixes #39785 (originally #39338).

When prefix_caching_hash_algo is set to "xxhash" or "xxhash_cbor" but the xxhash package is not installed, LLM.generate() silently returns empty outputs for requests that trigger prefix caching — no exception is raised.

Root cause: The ModuleNotFoundError in vllm/utils/hashing.py is raised at hash-computation time during request preprocessing, where it gets caught as a preprocessing failure and silently converted to an empty output.

Fix: Validate xxhash availability in CacheConfig.__post_init__ so the error surfaces immediately at engine construction time, consistent with how other optional-dependency configs (e.g. mamba stochastic rounding) are validated.

Uses ModuleNotFoundError with e.name == "xxhash" check to avoid masking broken/outdated installations that raise different ImportError subclasses.

Changes

  • vllm/config/cache.py: Add xxhash import check in __post_init__ (+13 LOC)
  • tests/v1/engine/test_xxhash_validation.py: Parametrized test that mocks xxhash absence and verifies ImportError is raised (+25 LOC)

Test plan

  • New unit test: test_xxhash_missing_raises_import_error (parametrized for both xxhash and xxhash_cbor)
  • Verify manually: pip uninstall xxhash && python -c "from vllm.config.cache import CacheConfig; CacheConfig(prefix_caching_hash_algo='xxhash')"ImportError

Changed files

  • tests/v1/engine/test_xxhash_validation.py (added, +60/-0)
  • vllm/config/cache.py (modified, +22/-0)

Code Example

pip uninstall xxhash -y
python -c "
from vllm import LLM
llm = LLM(model='facebook/opt-125m', prefix_caching_hash_algo='xxhash')
print(llm.generate(['Hello world']))  # silently returns empty
"
RAW_BUFFERClick to expand / collapse

$(cat <<'EOF'

Your current environment

vLLM main branch (latest)

🐛 Describe the bug

When prefix_caching_hash_algo is set to "xxhash" or "xxhash_cbor" but the xxhash package is not installed, LLM.generate() silently returns empty outputs for requests that trigger prefix caching — no exception is raised to the caller.

Root cause: The ModuleNotFoundError in vllm/utils/hashing.py is raised at hash-computation time during request preprocessing, where it gets caught as a preprocessing failure and silently converted to an empty output.

Expected behavior: An ImportError should be raised at engine construction time (in CacheConfig.__post_init__) when xxhash is required but not installed, consistent with how other optional-dependency configs (e.g. mamba stochastic rounding) are validated.

How to reproduce

pip uninstall xxhash -y
python -c "
from vllm import LLM
llm = LLM(model='facebook/opt-125m', prefix_caching_hash_algo='xxhash')
print(llm.generate(['Hello world']))  # silently returns empty
"

Originally reported as #39338. EOF )

extent analysis

TL;DR

To fix the issue, ensure the xxhash package is installed when using xxhash or xxhash_cbor as the prefix_caching_hash_algo.

Guidance

  • Verify that the xxhash package is installed by running pip show xxhash in your terminal.
  • If xxhash is not installed, install it using pip install xxhash.
  • To prevent similar issues in the future, consider adding a check in your code to ensure that all required packages are installed before initializing the LLM object.
  • Modify the CacheConfig.__post_init__ method to raise an ImportError when xxhash is required but not installed, as described in the expected behavior.

Example

import importlib.util
if prefix_caching_hash_algo in ["xxhash", "xxhash_cbor"]:
    if not importlib.util.find_spec("xxhash"):
        raise ImportError("xxhash is required but not installed")

Notes

This solution assumes that the xxhash package is the only missing dependency. If other dependencies are also required, additional checks may be necessary.

Recommendation

Apply workaround: Install the xxhash package using pip install xxhash to ensure that it is available when needed. This is a straightforward solution that addresses the immediate issue.

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