Skip to content

Commit 9629da2

Browse files
committed
update pd cases
Signed-off-by: songyang <songyang719@163.com>
1 parent 2cd1d41 commit 9629da2

11 files changed

Lines changed: 280 additions & 28 deletions

File tree

‎release_notes/fragments/23195.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pr: 23195
2+
entries:
3+
- category: bugfix
4+
text: Fixed incorrect answers on external KV cache hits when the V2 model runner synchronously reloads a prefix into newly allocated blocks.

‎tests/SIT/cases/features/kv_pool/DSv41-Flash-PD-KVPool.yaml‎

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
#
55
# Engine flags follow the local dsv41-pd P/D scripts, including the layerwise
66
# push path for the P->D link (MooncakeConnectorV2 use_layerwise=true). The
7-
# pool-watch limits stay local: max-model-len 131204 keeps the 131,076-token
8-
# prompt with a small tail headroom, and the prefill max-num-batched-tokens of
9-
# 16384 equals one lcm block, so every prefill chunk is a whole pool block and
10-
# hit counts stay exact. The layerwise push path needs the layerwise
7+
# pool-watch limits stay local: max-model-len 132096 leaves headroom for both
8+
# the 131,076-token secret prompt and the 128K prefix90 perf dataset (up to
9+
# ~131,219 tokens); the prefill max-num-batched-tokens of 16384 equals one lcm
10+
# block, so every prefill chunk is a whole pool block and hit counts stay exact.
11+
# The layerwise push path needs the layerwise
1112
# load-balance proxy: the proxy sends the decode first, D publishes its block
1213
# metadata to /v1/metaserver, and only then does the proxy dispatch P so P can
1314
# push the KV layer by layer. The AscendStore pool connector keeps its own
@@ -16,7 +17,7 @@
1617
# CI runs resolve the two nodes through LWS DNS and LWS_WORKER_INDEX.
1718
# Local A3 runs (non-Kubernetes): set cluster_hosts to the two node IPs in
1819
# rank order (P first, D second), then point CONFIG_YAML_PATH at this file.
19-
cluster_hosts: [172.27.5.133, 172.27.5.135]
20+
# cluster_hosts: [<prefill_ip>, <decode_ip>]
2021
test_name: "DSv41-Flash-PD-KVPool"
2122
model: "Eco-Tech/DeepSeek-V4.1-Flash-w8a8"
2223
num_nodes: 2
@@ -74,6 +75,20 @@ pool_ab:
7475
control_port: 19555
7576
perf_gate: true
7677
check_output: false
78+
perf_aisbench:
79+
dataset_path: vllm-ascend/GSM8K-in128k-bs512-prefix90-ds
80+
dataset_conf: gsm8k/gsm8k_gen_0_shot_cot_str_perf
81+
request_conf: vllm_api_stream_chat
82+
num_prompts: 128
83+
batch_size: 32
84+
max_out_len: 1
85+
request_rate: 0
86+
seed: 1024
87+
hit_rate_target: 0.9
88+
hit_rate_tolerance: 0.03
89+
warmup:
90+
num_prompts: 4
91+
batch_size: 4
7792

7893
env_common: &env_common
7994
VLLM_USE_V2_MODEL_RUNNER: "1"
@@ -120,7 +135,7 @@ templates:
120135
- --served-model-name
121136
- "dsv41"
122137
- --max-model-len
123-
- "131204"
138+
- "132096"
124139
- --max-num-batched-tokens
125140
- "16384"
126141
- --max-num-seqs
@@ -179,7 +194,7 @@ templates:
179194
- --served-model-name
180195
- "dsv41"
181196
- --max-model-len
182-
- "131204"
197+
- "132096"
183198
- --max-num-batched-tokens
184199
- "512"
185200
- --max-num-seqs
@@ -212,7 +227,7 @@ templates:
212227
- --additional-config
213228
- '{"ascend_compilation_config": {"enable_npugraph_ex": true, "enable_static_kernel": false}, "enable_cpu_binding": true, "multistream_overlap_shared_expert": true, "recompute_scheduler_enable": true}'
214229
- --kv-transfer-config
215-
- '{"kv_connector": "MultiConnector", "kv_role": "kv_consumer", "kv_port": "30100", "kv_connector_extra_config": {"connectors": [{"kv_connector": "MooncakeConnectorV2", "kv_role": "kv_consumer", "kv_port": "30100", "kv_connector_extra_config": {"use_layerwise": true}}, {"kv_connector": "AscendStoreConnector", "kv_role": "kv_consumer", "kv_connector_extra_config": {"backend": "memcache", "lookup_rpc_port": "0", "use_layerwise": false}}]}}'
230+
- '{"kv_connector": "MultiConnector", "kv_role": "kv_consumer", "kv_port": "31100", "kv_connector_extra_config": {"connectors": [{"kv_connector": "MooncakeConnectorV2", "kv_role": "kv_consumer", "kv_port": "31100", "kv_connector_extra_config": {"use_layerwise": true}}, {"kv_connector": "AscendStoreConnector", "kv_role": "kv_consumer", "kv_connector_extra_config": {"backend": "memcache", "lookup_rpc_port": "0", "use_layerwise": false}}]}}'
216231

217232
benchmarks: {}
218233

‎tests/SIT/cases/features/kv_pool/DSv41-Flash-PD-Mooncake-KVPool.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# CI runs resolve the two nodes through LWS DNS and LWS_WORKER_INDEX.
2020
# Local A3 runs (non-Kubernetes): set cluster_hosts to the two node IPs in
2121
# rank order (P first, D second), then point CONFIG_YAML_PATH at this file.
22-
# # cluster_hosts: [172.27.5.133, 172.27.5.135]
22+
# cluster_hosts: [<prefill_ip>, <decode_ip>]
2323
test_name: "DSv41-Flash-PD-Mooncake-KVPool"
2424
model: "Eco-Tech/DeepSeek-V4.1-Flash-w8a8"
2525
num_nodes: 2

‎tests/SIT/cases/features/kv_pool/GLM53-Flash-PD-Mooncake-KVPool.yaml‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# CI runs resolve the two nodes through LWS DNS and LWS_WORKER_INDEX.
1010
# Local A3 runs (non-Kubernetes): set cluster_hosts to the two node IPs in
1111
# rank order (P first, D second), then point CONFIG_YAML_PATH at this file.
12-
# cluster_hosts: [172.27.5.133, 172.27.5.135]
12+
# cluster_hosts: [<prefill_ip>, <decode_ip>]
1313
test_name: "GLM53-Flash-PD-Mooncake-KVPool"
1414
model: "Eco-Tech/GLM-5.3-Flash-w8a8"
1515
num_nodes: 2
@@ -61,6 +61,20 @@ pool_ab:
6161
control_port: 19557
6262
perf_gate: true
6363
check_output: true
64+
perf_aisbench:
65+
dataset_path: vllm-ascend/GSM8K-in128k-bs512-prefix90-ds
66+
dataset_conf: gsm8k/gsm8k_gen_0_shot_cot_str_perf
67+
request_conf: vllm_api_stream_chat
68+
num_prompts: 128
69+
batch_size: 32
70+
max_out_len: 1
71+
request_rate: 0
72+
seed: 1024
73+
hit_rate_target: 0.9
74+
hit_rate_tolerance: 0.03
75+
warmup:
76+
num_prompts: 4
77+
batch_size: 4
6478

6579
env_common: &env_common
6680
VLLM_USE_V2_MODEL_RUNNER: "1"
@@ -115,7 +129,7 @@ templates:
115129
- --max-num-seqs
116130
- "32"
117131
- --max-model-len
118-
- "130308"
132+
- "132096"
119133
# 14 x lcm(1152): aligned prefill chunks keep the cold/hit outputs identical.
120134
- --max-num-batched-tokens
121135
- "16128"
@@ -174,7 +188,7 @@ templates:
174188
- --max-num-seqs
175189
- "40"
176190
- --max-model-len
177-
- "130308"
191+
- "132096"
178192
- --max-num-batched-tokens
179193
- "240"
180194
- --trust-remote-code

‎tests/SIT/cases/features/kv_pool/GLM53-W8A8C8-PD-KVPool.yaml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,23 @@ pool_ab:
112112
control_port: 19558
113113
perf_gate: false
114114
check_output: true
115+
# Aligned with N1: the perf phase reads the 128K prefix90 dataset at
116+
# 128 requests / 32 concurrency. This four-node shortened PP-PD case keeps
117+
# perf_gate=false, so throughput is recorded without gating.
118+
perf_aisbench:
119+
dataset_path: vllm-ascend/GSM8K-in128k-bs512-prefix90-ds
120+
dataset_conf: gsm8k/gsm8k_gen_0_shot_cot_str_perf
121+
request_conf: vllm_api_stream_chat
122+
num_prompts: 128
123+
batch_size: 32
124+
max_out_len: 1
125+
request_rate: 0
126+
seed: 1024
127+
hit_rate_target: 0.9
128+
hit_rate_tolerance: 0.03
129+
warmup:
130+
num_prompts: 4
131+
batch_size: 4
115132

116133
env_common: &env_common
117134
VLLM_USE_V2_MODEL_RUNNER: "1"

‎tests/SIT/cases/features/kv_pool/test_pool_nightly.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
build_pool_accuracy_prompt,
3939
build_pool_prompts,
4040
extract_pool_answer,
41+
resolve_model_path,
4142
run_pool_ab,
4243
run_pool_hit_sequence,
4344
)
@@ -260,7 +261,7 @@ def _dsv4_memcache_64k_leg(use_pool: bool, case_name: str):
260261
def test_dsv4_memcache_colocation_64k() -> None:
261262
_diag_model("n3", DSV4_DSPARK_MODEL)
262263
tokenizer = AutoTokenizer.from_pretrained(
263-
DSV4_DSPARK_MODEL, trust_remote_code=True
264+
resolve_model_path(DSV4_DSPARK_MODEL), trust_remote_code=True
264265
)
265266
prefix_a = build_pool_accuracy_prompt(
266267
tokenizer, N3_POOL_PROMPT_TOKENS, N3_POOL_MAX_MODEL_LEN, secret="7391"
@@ -377,7 +378,9 @@ def _dsv4_dp4_mooncake_leg(use_pool: bool, case_name: str):
377378
@wait_until_npu_memory_free(target_free_percentage=0.8)
378379
def test_dsv4_mooncake_dp4_colocation() -> None:
379380
_diag_model("dp4", DSV4_0731_MODEL)
380-
tokenizer = AutoTokenizer.from_pretrained(DSV4_0731_MODEL, trust_remote_code=True)
381+
tokenizer = AutoTokenizer.from_pretrained(
382+
resolve_model_path(DSV4_0731_MODEL), trust_remote_code=True
383+
)
381384
prefix_a = build_pool_accuracy_prompt(
382385
tokenizer, DSV4_DP4_POOL_PROMPT_TOKENS, DSV4_DP4_POOL_MAX_MODEL_LEN, secret="7391"
383386
)
@@ -493,7 +496,9 @@ def _qwen_leg(use_pool: bool, case_name: str):
493496
@wait_until_npu_memory_free(target_free_percentage=0.8)
494497
def test_qwen38_memcache_mtp_align() -> None:
495498
_diag_model("qwen38", QWEN38_MODEL)
496-
tokenizer = AutoTokenizer.from_pretrained(QWEN38_MODEL, trust_remote_code=True)
499+
tokenizer = AutoTokenizer.from_pretrained(
500+
resolve_model_path(QWEN38_MODEL), trust_remote_code=True
501+
)
497502
prompt_ids = build_pool_accuracy_prompt(
498503
tokenizer, QWEN_POOL_PROMPT_TOKENS, QWEN_POOL_MAX_MODEL_LEN
499504
)

‎tests/e2e/common/multi_node/external_dp/pool_ab.py‎

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,12 @@
6262
QUERIES_METRIC,
6363
build_pool_accuracy_prompt,
6464
extract_pool_answer,
65+
resolve_model_path,
6566
run_pool_ab,
6667
run_pool_hit_sequence,
68+
snapshot_metrics,
6769
)
70+
from tools.aisbench import run_aisbench_cases
6871

6972
BLOCK_SIZE = 128
7073
POOL_SECRET = "7391"
@@ -118,6 +121,7 @@ class PoolABCase:
118121
perf_batch_requests: int = 8
119122
perf_sample_count: int = 3
120123
perf_warmup_count: int = 1
124+
perf_aisbench: dict[str, Any] | None = None
121125
token_identity: bool = False
122126
acceptance_ratio: float | None = None
123127

@@ -617,6 +621,50 @@ def _run_follower_legs(
617621
channel.close()
618622

619623

624+
def _aisbench_perf_case(
625+
config: ExternalDPConfig,
626+
spec: dict[str, Any],
627+
*,
628+
name: str,
629+
num_prompts: int,
630+
batch_size: int,
631+
) -> dict[str, Any]:
632+
"""Build one AISBench performance case that reads the 128K prefix90 dataset."""
633+
case = {
634+
"benchmark_name": name,
635+
"case_type": "performance",
636+
"dataset_path": spec["dataset_path"],
637+
"dataset_conf": spec["dataset_conf"],
638+
"request_conf": spec["request_conf"],
639+
"model_path": spec.get("model_path") or config.model,
640+
"num_prompts": int(num_prompts),
641+
"batch_size": int(batch_size),
642+
"max_out_len": int(spec.get("max_out_len", 1)),
643+
"request_rate": int(spec.get("request_rate", 0)),
644+
}
645+
if spec.get("seed") is not None:
646+
case["seed"] = int(spec["seed"])
647+
# CI has no shared dataset mount: only pin dataset_path_local when the case
648+
# YAML provides one, otherwise AISBench downloads the ModelScope dataset.
649+
local_path = spec.get("dataset_path_local") or os.environ.get("KV_POOL_PERF_DATASET_LOCAL")
650+
if local_path:
651+
case["dataset_path_local"] = local_path
652+
return case
653+
654+
655+
def _aisbench_input_throughput(result: Any) -> float:
656+
"""Extract the input token throughput (token/s) from an AISBench perf result."""
657+
payload = result[1] if isinstance(result, (list, tuple)) and len(result) > 1 else result
658+
if not isinstance(payload, dict):
659+
raise RuntimeError(f"unexpected AISBench perf result: {type(result).__name__}")
660+
value: Any = payload.get("Input Token Throughput")
661+
if isinstance(value, dict):
662+
value = value.get("total") or next(iter(value.values()), None)
663+
if value is None:
664+
raise RuntimeError(f"Input Token Throughput missing in AISBench result: {list(payload)}")
665+
return float(str(value).replace("token/s", "").strip())
666+
667+
620668
def run_pool_ab_case() -> None:
621669
"""Run the pool A/B watch described by ``CONFIG_YAML_PATH``."""
622670
config, case = load_case()
@@ -634,7 +682,9 @@ def run_pool_ab_case() -> None:
634682
return
635683

636684
max_model_len = _max_model_len(config)
637-
tokenizer = AutoTokenizer.from_pretrained(config.model, trust_remote_code=True)
685+
tokenizer = AutoTokenizer.from_pretrained(
686+
resolve_model_path(config.model), trust_remote_code=True
687+
)
638688
prefix = build_pool_accuracy_prompt(
639689
tokenizer, case.prompt_tokens, max_model_len, secret=case.secret
640690
)
@@ -673,6 +723,59 @@ def hit(runner: Any) -> dict[str, Any]:
673723
summary["hit_outputs"] = summary["hit_outputs"][:1]
674724
return summary
675725

726+
def perf(runner: Any, use_pool: bool) -> float:
727+
spec = case.perf_aisbench
728+
if not spec:
729+
raise RuntimeError("pool_ab.perf_aisbench is required for the AISBench perf phase")
730+
warmup = spec.get("warmup") or {}
731+
if warmup:
732+
run_aisbench_cases(
733+
model=runner.served_model_name,
734+
port=runner.proxy_port,
735+
host_ip=runner.proxy_host,
736+
aisbench_cases=[
737+
_aisbench_perf_case(
738+
config,
739+
spec,
740+
name="kv_pool_prefix90_warmup",
741+
num_prompts=int(warmup.get("num_prompts", 4)),
742+
batch_size=int(warmup.get("batch_size", 4)),
743+
)
744+
],
745+
)
746+
before = snapshot_metrics(runner) if use_pool else None
747+
results = run_aisbench_cases(
748+
model=runner.served_model_name,
749+
port=runner.proxy_port,
750+
host_ip=runner.proxy_host,
751+
aisbench_cases=[
752+
_aisbench_perf_case(
753+
config,
754+
spec,
755+
name="kv_pool_prefix90",
756+
num_prompts=int(spec["num_prompts"]),
757+
batch_size=int(spec["batch_size"]),
758+
)
759+
],
760+
)
761+
if use_pool and before is not None:
762+
after = snapshot_metrics(runner)
763+
queries = after.queries - before.queries
764+
hits = after.hits - before.hits
765+
ratio = hits / queries if queries > 0 else 0.0
766+
target = float(spec.get("hit_rate_target") or 0.0)
767+
tolerance = float(spec.get("hit_rate_tolerance", 0.03))
768+
print(
769+
f"[kv_pool_hitrate] leg=a hit_tokens={hits:.0f} query_tokens={queries:.0f} "
770+
f"ratio={ratio:.4f} target={target:.4f}",
771+
flush=True,
772+
)
773+
if target and abs(ratio - target) > tolerance:
774+
raise AssertionError(
775+
f"perf hit ratio {ratio:.4f} outside {target:.4f}±{tolerance:.4f}"
776+
)
777+
return _aisbench_input_throughput(results[-1])
778+
676779
with _ControlServer(case.control_port, expected_clients=config.num_nodes - 1) as control:
677780

678781
def build_leg(use_pool: bool, case_name: str):
@@ -701,5 +804,7 @@ def build_leg(use_pool: bool, case_name: str):
701804
perf_batch_requests=case.perf_batch_requests,
702805
perf_sample_count=case.perf_sample_count,
703806
perf_warmup_count=case.perf_warmup_count,
807+
# Cases without pool_ab.perf_aisbench keep the legacy local sampling.
808+
perf_fn=perf if case.perf_aisbench else None,
704809
perf_gate=case.perf_gate,
705810
)

0 commit comments

Comments
 (0)