[CPU] add c++ kernel to bind CPU cores and memory node (#7524)
This commit is contained in:
28
test/srt/cpu/test_binding.py
Normal file
28
test/srt/cpu/test_binding.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import re
|
||||
import unittest
|
||||
|
||||
import sgl_kernel
|
||||
import torch
|
||||
|
||||
kernel = torch.ops.sgl_kernel
|
||||
|
||||
from sglang.test.test_utils import CustomTestCase
|
||||
|
||||
|
||||
class TestGemm(CustomTestCase):
|
||||
def test_binding(self):
|
||||
start_id = 1
|
||||
n_cpu = 6
|
||||
|
||||
expected_cores = list(map(str, range(start_id, start_id + n_cpu)))
|
||||
cpu_ids = ",".join(expected_cores)
|
||||
output = kernel.init_cpu_threads_env(cpu_ids)
|
||||
|
||||
bindings = re.findall(r"OMP tid: \d+, core (\d+)", output)
|
||||
self.assertEqual(len(bindings), n_cpu)
|
||||
|
||||
self.assertEqual(bindings, expected_cores)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -183,6 +183,7 @@ suites = {
|
||||
],
|
||||
"per-commit-cpu": [
|
||||
TestFile("cpu/test_activation.py"),
|
||||
TestFile("cpu/test_binding.py"),
|
||||
TestFile("cpu/test_decode.py"),
|
||||
TestFile("cpu/test_extend.py"),
|
||||
TestFile("cpu/test_gemm.py"),
|
||||
@@ -192,6 +193,7 @@ suites = {
|
||||
TestFile("cpu/test_qkv_proj_with_rope.py"),
|
||||
TestFile("cpu/test_rope.py"),
|
||||
TestFile("cpu/test_shared_expert.py"),
|
||||
TestFile("cpu/test_topk.py"),
|
||||
],
|
||||
"nightly": [
|
||||
TestFile("test_nightly_gsm8k_eval.py"),
|
||||
|
||||
Reference in New Issue
Block a user