[pd]: (Bug Fix) Incorrect out_cache_loc slicing in prepare_for_prebuilt (#24230)
Co-authored-by: Shangming Cai <csmthu@gmail.com>
This commit is contained in:
co-authored by
Shangming Cai
parent
2bfc5d3bb1
commit
44ca2d01fc
@@ -42,9 +42,10 @@ class ScheduleBatchDisaggregationDecodeMixin:
|
|||||||
offset = 0
|
offset = 0
|
||||||
for i, req in enumerate(reqs):
|
for i, req in enumerate(reqs):
|
||||||
req_pool_indices.append(req.req_pool_idx)
|
req_pool_indices.append(req.req_pool_idx)
|
||||||
|
pre_len = len(req.prefix_indices)
|
||||||
|
|
||||||
chunk = self.req_to_token_pool.req_to_token[req.req_pool_idx][
|
chunk = self.req_to_token_pool.req_to_token[req.req_pool_idx][
|
||||||
: req.extend_input_len
|
pre_len : pre_len + req.extend_input_len
|
||||||
]
|
]
|
||||||
assert (
|
assert (
|
||||||
offset + req.extend_input_len <= total_size
|
offset + req.extend_input_len <= total_size
|
||||||
@@ -52,7 +53,6 @@ class ScheduleBatchDisaggregationDecodeMixin:
|
|||||||
out_cache_loc[offset : offset + req.extend_input_len] = chunk
|
out_cache_loc[offset : offset + req.extend_input_len] = chunk
|
||||||
offset += req.extend_input_len
|
offset += req.extend_input_len
|
||||||
|
|
||||||
pre_len = len(req.prefix_indices)
|
|
||||||
seq_len = len(req.origin_input_ids) + max(0, len(req.output_ids) - 1)
|
seq_len = len(req.origin_input_ids) + max(0, len(req.output_ids) - 1)
|
||||||
seq_lens.append(seq_len)
|
seq_lens.append(seq_len)
|
||||||
if len(req.output_ids) == 0:
|
if len(req.output_ids) == 0:
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import time
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
|
from types import SimpleNamespace
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from sglang.test.ci.ci_register import register_cuda_ci
|
from sglang.test.ci.ci_register import register_cuda_ci
|
||||||
from sglang.test.kits.cache_hit_kit import run_multiturn_cache_hit_test
|
from sglang.test.kits.cache_hit_kit import run_multiturn_cache_hit_test
|
||||||
|
from sglang.test.run_eval import run_eval
|
||||||
from sglang.test.server_fixtures.disaggregation_fixture import (
|
from sglang.test.server_fixtures.disaggregation_fixture import (
|
||||||
PDDisaggregationServerBase,
|
PDDisaggregationServerBase,
|
||||||
)
|
)
|
||||||
@@ -78,6 +80,39 @@ class TestDisaggregationDecodeRadixCache(PDDisaggregationServerBase):
|
|||||||
self._assert_process_healthy("prefill", self.process_prefill, self.prefill_url)
|
self._assert_process_healthy("prefill", self.process_prefill, self.prefill_url)
|
||||||
self._assert_process_healthy("decode", self.process_decode, self.decode_url)
|
self._assert_process_healthy("decode", self.process_decode, self.decode_url)
|
||||||
|
|
||||||
|
def test_gsm8k_accuracy_two_passes(self):
|
||||||
|
"""Run GSM8K twice to verify decode radix cache does not degrade accuracy."""
|
||||||
|
args = SimpleNamespace(
|
||||||
|
base_url=self.base_url,
|
||||||
|
model=self.model,
|
||||||
|
eval_name="gsm8k",
|
||||||
|
api="completion",
|
||||||
|
max_tokens=512,
|
||||||
|
num_examples=500,
|
||||||
|
num_threads=100,
|
||||||
|
num_shots=6,
|
||||||
|
)
|
||||||
|
|
||||||
|
metrics_first = run_eval(args)
|
||||||
|
print(f"First run metrics: {metrics_first}")
|
||||||
|
|
||||||
|
metrics_second = run_eval(args)
|
||||||
|
print(f"Second run metrics: {metrics_second}")
|
||||||
|
|
||||||
|
# Both runs should have reasonable accuracy
|
||||||
|
self.assertGreater(metrics_first["score"], 0.80)
|
||||||
|
self.assertGreater(metrics_second["score"], 0.80)
|
||||||
|
|
||||||
|
# Second run accuracy should not drop more than 3% compared to first run
|
||||||
|
accuracy_drop = metrics_first["score"] - metrics_second["score"]
|
||||||
|
self.assertLessEqual(
|
||||||
|
accuracy_drop,
|
||||||
|
0.03,
|
||||||
|
f"Second run accuracy dropped by {accuracy_drop:.4f} "
|
||||||
|
f"(first={metrics_first['score']:.4f}, second={metrics_second['score']:.4f}), "
|
||||||
|
f"exceeds 3% threshold",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user