[NPU] Adapt hicache for K3 hybrid models (#39415)
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import unittest
|
||||
|
||||
from sglang.test.ascend.gsm8k_ascend_mixin import GSM8KAscendMixin
|
||||
from sglang.test.ascend.test_ascend_utils import KIMI_K3_W4A8_INT_MOE_WEIGHTS_PATH
|
||||
from sglang.test.test_utils import CustomTestCase
|
||||
|
||||
|
||||
class TestKimiK3MixedWithHiCacheL2(GSM8KAscendMixin, CustomTestCase):
|
||||
"""Testcase: Verify the inference accuracy of Kimi-K3 (MLA + KDA hybrid) on GSM8K
|
||||
with mixed (non-PD) serving and HiCache L2 cache on NPU.
|
||||
|
||||
[Test Category] HiCache
|
||||
[Test Target] Kimi-K3 (MLA + KDA hybrid, mamba layers)
|
||||
[Test Config] Mixed deployment, NPU, HiCache L2 (kernel_ascend IO backend)
|
||||
"""
|
||||
|
||||
model = KIMI_K3_W4A8_INT_MOE_WEIGHTS_PATH
|
||||
accuracy = 0.9
|
||||
other_args = [
|
||||
"--trust-remote-code",
|
||||
"--device",
|
||||
"npu",
|
||||
"--attention-backend",
|
||||
"ascend",
|
||||
"--quantization",
|
||||
"modelslim",
|
||||
"--dtype",
|
||||
"bfloat16",
|
||||
"--tp-size",
|
||||
"64",
|
||||
"--enable-dp-attention",
|
||||
"--dp-size",
|
||||
"4",
|
||||
"--enable-dp-lm-head",
|
||||
"--moe-a2a-backend",
|
||||
"deepep",
|
||||
"--deepep-mode",
|
||||
"auto",
|
||||
"--mem-fraction-static",
|
||||
"0.75",
|
||||
"--max-mamba-cache-size",
|
||||
"240",
|
||||
"--enable-hierarchical-cache",
|
||||
"--hicache-io-backend",
|
||||
"kernel_ascend",
|
||||
"--enable-cache-report",
|
||||
"--hicache-ratio",
|
||||
"4.0",
|
||||
]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -236,6 +236,10 @@ class TestDecodeQueueCleanup(CustomTestCase):
|
||||
queue._pre_alloc = MagicMock()
|
||||
queue.req_to_token_pool = MagicMock()
|
||||
queue.req_to_token_pool.available_size.return_value = 1
|
||||
# Non-hybrid pools have no mamba allocator; MagicMock would otherwise
|
||||
# auto-create one and break the `available_size() <= 0` comparison in
|
||||
# pop_preallocated.
|
||||
queue.req_to_token_pool.mamba_allocator = None
|
||||
queue.req_to_metadata_buffer_idx_allocator = MagicMock()
|
||||
queue.req_to_metadata_buffer_idx_allocator.available_size.return_value = 1
|
||||
|
||||
|
||||
@@ -148,6 +148,10 @@ class TestDecodePreallocQueuePriority(unittest.TestCase):
|
||||
|
||||
queue.req_to_token_pool = MagicMock()
|
||||
queue.req_to_token_pool.available_size.return_value = 100
|
||||
# Non-hybrid pools have no mamba allocator; MagicMock would otherwise
|
||||
# auto-create one and break the `available_size() <= 0` comparison in
|
||||
# pop_preallocated.
|
||||
queue.req_to_token_pool.mamba_allocator = None
|
||||
queue.req_to_token_pool.req_to_token = torch.arange(
|
||||
8 * 16, dtype=torch.int64
|
||||
).reshape(8, 16)
|
||||
|
||||
@@ -442,6 +442,10 @@ class TestDecodeLockRefScenarios(CustomTestCase):
|
||||
queue.tree_cache.dec_lock_ref = MagicMock()
|
||||
queue.req_to_token_pool = MagicMock()
|
||||
queue.req_to_token_pool.available_size.return_value = 1
|
||||
# Non-hybrid pools have no mamba allocator; MagicMock would otherwise
|
||||
# auto-create one and break the `available_size() <= 0` comparison in
|
||||
# pop_preallocated.
|
||||
queue.req_to_token_pool.mamba_allocator = None
|
||||
queue.req_to_metadata_buffer_idx_allocator = MagicMock()
|
||||
queue.req_to_metadata_buffer_idx_allocator.available_size.return_value = 1
|
||||
queue.token_to_kv_pool = MagicMock()
|
||||
|
||||
@@ -156,6 +156,7 @@ class TestNPUMambaAsyncConfig(unittest.TestCase):
|
||||
MambaPoolHost.__dict__["_copy_tensor_all_layers_lf_pf"], staticmethod
|
||||
)
|
||||
|
||||
@patch.object(mamba_pool_host, "transfer_mamba_state", None)
|
||||
def test_conv_only_load_skips_empty_temporal_component(self):
|
||||
pool = MambaPoolHost.__new__(MambaPoolHost)
|
||||
pool.layout = "page_first_direct"
|
||||
|
||||
Reference in New Issue
Block a user