[Diffusion][HunyuanImage3] Add request paged prefix caching (#7719)

Signed-off-by: zwhzzz0821 <2831474076@qq.com>
This commit is contained in:
Yukim1 authored and GitHub committed 2026-09-23 15:34:56 +00:00
1 parent 9a1a05facd
commit 205aa01c7b
49 files changed
+2889 -127

No files matched your search

+48 -1
View File
@@ -4,8 +4,10 @@
import pytest
import torch
import vllm.v1.core.single_type_kv_cache_manager as native_kv_managers
from vllm.multimodal.inputs import MultiModalFeatureSpec, PlaceholderRange
from vllm.utils.hashing import get_hash_fn_by_name
from vllm.v1.core.kv_cache_manager import KVCacheManager
from vllm.v1.core.kv_cache_utils import BlockHash
from vllm.v1.core.kv_cache_utils import BlockHash, init_none_hash
from vllm.v1.kv_cache_interface import (
FullAttentionSpec,
KVCacheConfig,
@@ -49,6 +51,51 @@ def test_request_exposes_native_request_and_diffusion_semantics() -> None:
assert request.status is RequestStatus.WAITING
def test_request_builds_only_full_prefix_block_hashes() -> None:
hash_function = get_hash_fn_by_name("sha256")
init_none_hash(hash_function)
request = _request(
prefix_len=6,
target_len=2,
cache_token_ids=range(6),
mm_features=[
MultiModalFeatureSpec(
data=None,
modality="image",
identifier="tail",
mm_position=PlaceholderRange(offset=4, length=2),
)
],
)
request.build_block_hashes(BLOCK_SIZE, hash_function)
assert len(request.block_hashes) == 1
assert request.skip_reading_prefix_cache is False
def test_changed_multimodal_identity_changes_the_block_hash() -> None:
hash_function = get_hash_fn_by_name("sha256")
init_none_hash(hash_function)
first = _request(cache_token_ids=range(4))
second = _request(
cache_token_ids=range(4),
mm_features=[
MultiModalFeatureSpec(
data=None,
modality="image",
identifier="image-a",
mm_position=PlaceholderRange(offset=2, length=2),
)
],
)
first.build_block_hashes(BLOCK_SIZE, hash_function)
second.build_block_hashes(BLOCK_SIZE, hash_function)
assert first.block_hashes != second.block_hashes
@pytest.mark.parametrize(
("overrides", "message"),
[