init v0.23.0

Signed-off-by: Sun Ruoxi <sunruoxi@4paradigm.com>
This commit is contained in:
2026-08-27 15:11:51 +08:00
parent b582a8e7d1
commit 7f8a1b1f7a
2849 changed files with 712887 additions and 22001 deletions

View File

View File

@@ -0,0 +1,36 @@
import unittest
import torch
from vllm_ascend.eplb.core.eplb_worker import EplbWorker
from vllm_ascend.eplb.core.policy.policy_factory import PolicyFactory
from vllm_ascend.eplb.core.policy.policy_flashlb import generate_layered_experts
class TestEplbRebalancePolicies(unittest.TestCase):
def setUp(self):
torch.manual_seed(42)
self.current_expert_table = generate_layered_experts()
x = torch.rand(100, 58, 32, 9)
x = x**10
self.expert_workload = (x * 999 + 1).long()
self.hotness = EplbWorker._calculate_hotness(self.current_expert_table, self.expert_workload.sum(0))
@unittest.mock.patch("torch.npu.device_count", return_value=16)
def test_swift_balance_rebalance_experts(self, mock_count):
swift_policy = PolicyFactory.generate_policy(2)
_, _, new_placement = swift_policy.rebalance_experts(self.current_expert_table, self.expert_workload.sum(0))
update_mean, _ = EplbWorker._compute_imbalance(new_placement, self.hotness)
self.assertLessEqual(update_mean, 1.08)
def test_flashlb_rebalance_experts(self):
flashlb_policy = PolicyFactory.generate_policy(3)
_, _, new_placement = flashlb_policy.rebalance_experts(self.current_expert_table, self.expert_workload)
update_mean, _ = EplbWorker._compute_imbalance(new_placement, self.hotness)
self.assertLessEqual(update_mean, 1.1)
if __name__ == "__main__":
unittest.main(verbosity=2)