-
Notifications
You must be signed in to change notification settings - Fork 59
[RHOAIENG-34594] Add test case for singlenode with estimated prefix cache #907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
threcc
merged 16 commits into
opendatahub-io:main
from
threcc:singlenode-precise-prefix
Dec 10, 2025
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
56ea9e6
Add new test for llm-d
threcc 0f41208
fix precommit errors
threcc c741dc7
move fixture in conftest.py
threcc 1d9cef6
address pr comments
threcc 54e62f3
improve naming
threcc 94e255f
rename constant
threcc 2cdf65c
add missing router config parameter
threcc 429ad5f
rename "precise prefix" to "estimated prefix"
threcc 196e218
refactor the test to use metrics instead of reading from vllm logs
threcc f2cff47
address pr comments
threcc cbcc5ae
address pr comments
threcc 4d58233
address pr comments
threcc cab8064
Use retry instead of time.sleep
threcc ef5ec9f
Merge branch 'main' into singlenode-precise-prefix
threcc dc0a37d
Merge branch 'main' into singlenode-precise-prefix
mwaykole 5dd5460
Merge branch 'main' into singlenode-precise-prefix
threcc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Liveness probe for single-node configurations | ||
| LLMD_LIVENESS_PROBE = { | ||
| "httpGet": {"path": "/health", "port": 8000, "scheme": "HTTPS"}, | ||
| "initialDelaySeconds": 120, | ||
| "periodSeconds": 30, | ||
| "timeoutSeconds": 30, | ||
| "failureThreshold": 5, | ||
| } | ||
|
|
||
| # Common parameters for vLLM and llm-d scheduler | ||
| PREFIX_CACHE_BLOCK_SIZE = 64 | ||
| PREFIX_CACHE_HASH_ALGO = "sha256" | ||
| PREFIX_CACHE_HASH_SEED = "42" | ||
|
|
||
| # Scheduler configuration for single-node with estimated prefix cache | ||
| ROUTER_SCHEDULER_CONFIG_ESTIMATED_PREFIX_CACHE = { | ||
| "apiVersion": "inference.networking.x-k8s.io/v1alpha1", | ||
| "kind": "EndpointPickerConfig", | ||
| "plugins": [ | ||
| { | ||
| "type": "prefix-cache-scorer", | ||
| "parameters": { | ||
| "indexerConfig": { | ||
| "tokenProcessorConfig": { | ||
| "blockSize": PREFIX_CACHE_BLOCK_SIZE, | ||
| "hashAlgo": PREFIX_CACHE_HASH_ALGO, | ||
| "hashSeed": PREFIX_CACHE_HASH_SEED, | ||
| } | ||
| } | ||
| }, | ||
pierDipi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| ], | ||
| "schedulingProfiles": [ | ||
| { | ||
| "name": "default", | ||
| "plugins": [ | ||
| { | ||
| "pluginRef": "prefix-cache-scorer", | ||
| "weight": 5.0, | ||
| } | ||
| ], | ||
| } | ||
| ], | ||
| } | ||
94 changes: 94 additions & 0 deletions
94
tests/model_serving/model_server/llmd/test_singlenode_estimated_prefix_cache.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| """ | ||
| Test Single-Node Estimated Prefix Caching. | ||
|
|
||
| This test verifies that the LLM-D router correctly routes inference requests | ||
| based on cache state, maximizing prefix cache hits. | ||
|
|
||
| Test configuration: | ||
| - LLMInferenceService with 2 replicas and router enabled | ||
| - Authentication enabled | ||
| - Verify router pod and vLLM pods are running | ||
| - Send multiple requests with shared prefixes and size greater than PREFIX_CACHE_BLOCK_SIZE | ||
| """ | ||
|
|
||
| import pytest | ||
| from kubernetes.dynamic import DynamicClient | ||
| from ocp_resources.gateway import Gateway | ||
| from ocp_resources.llm_inference_service import LLMInferenceService | ||
| from ocp_resources.prometheus import Prometheus | ||
|
|
||
| from tests.model_serving.model_server.llmd.utils import ( | ||
| get_llmd_router_scheduler_pod, | ||
| get_llmd_workload_pods, | ||
| send_prefix_cache_test_requests, | ||
| verify_estimated_prefix_cache_metrics, | ||
| verify_gateway_status, | ||
| verify_llm_service_status, | ||
| ) | ||
| from simple_logger.logger import get_logger | ||
|
|
||
| LOGGER = get_logger(name=__name__) | ||
|
|
||
| # Number of requests to send for prefix cache testing | ||
| NUM_REQUESTS = 20 | ||
|
|
||
| pytestmark = [pytest.mark.llmd_gpu] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "unprivileged_model_namespace, authenticated_llmisvc_token", | ||
| [ | ||
| pytest.param( | ||
| {"name": "llmd-singlenode-prefix-cache-test"}, | ||
| { | ||
| "service_account_fixture": "llmd_s3_service_account", | ||
| "llmisvc_fixture": "singlenode_estimated_prefix_cache", | ||
| }, | ||
| ) | ||
| ], | ||
| indirect=True, | ||
| ) | ||
| @pytest.mark.usefixtures("valid_aws_config", "user_workload_monitoring_config_map") | ||
| class TestSingleNodeEstimatedPrefixCache: | ||
| """Test class for singlenode estimated prefix cache routing.""" | ||
|
|
||
| def test_singlenode_estimated_prefix_cache( | ||
| self, | ||
| unprivileged_client: DynamicClient, | ||
| llmd_gateway: Gateway, | ||
| singlenode_estimated_prefix_cache: LLMInferenceService, | ||
| authenticated_llmisvc_token: str, | ||
| gpu_count_on_cluster: int, | ||
| prometheus: Prometheus, | ||
| ): | ||
| """Test single-node estimated prefix cache routing.""" | ||
| if gpu_count_on_cluster < 2: | ||
| pytest.skip(f"Test requires at least 2 GPUs (found {gpu_count_on_cluster})") | ||
|
|
||
| # Verify infrastructure is ready before testing routing | ||
| assert verify_gateway_status(llmd_gateway), "Gateway should be ready" | ||
| assert verify_llm_service_status(singlenode_estimated_prefix_cache), "LLMInferenceService should be ready" | ||
|
|
||
| router_scheduler_pod = get_llmd_router_scheduler_pod( | ||
| client=unprivileged_client, llmisvc=singlenode_estimated_prefix_cache | ||
| ) | ||
| assert router_scheduler_pod is not None, "Router-scheduler pod should exist" | ||
| assert router_scheduler_pod.instance.status.phase == "Running", "Router-scheduler pod should be running" | ||
|
|
||
| workload_pods = get_llmd_workload_pods(client=unprivileged_client, llmisvc=singlenode_estimated_prefix_cache) | ||
| assert len(workload_pods) == 2, f"Expected 2 workload pods, found {len(workload_pods)}" | ||
|
|
||
| # Send N identical requests to test prefix cache | ||
| num_successful_requests = send_prefix_cache_test_requests( | ||
| llmisvc=singlenode_estimated_prefix_cache, | ||
| token=authenticated_llmisvc_token, | ||
| num_requests=NUM_REQUESTS, | ||
| ) | ||
|
|
||
| # Verify estimated prefix cache routing using Prometheus metrics | ||
| verify_estimated_prefix_cache_metrics( | ||
| prometheus=prometheus, | ||
| llmisvc=singlenode_estimated_prefix_cache, | ||
| workload_pods=workload_pods, | ||
| expected_requests=num_successful_requests, | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.