-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Migrate Intel CPU cases to the test/registered. #22670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import itertools | ||
| import unittest | ||
|
|
||
| import torch | ||
| from utils import GeluAndMul, SiluAndMul, precision | ||
|
|
||
| from sglang.srt.server_args import ServerArgs, set_global_server_args_for_scheduler | ||
| from sglang.test.ci.ci_register import register_cpu_ci | ||
| from sglang.test.test_utils import CustomTestCase | ||
|
|
||
| register_cpu_ci(est_time=10, suite="stage-b-test-cpu") | ||
|
|
||
| torch.manual_seed(1234) | ||
|
|
||
|
|
||
| class TestActivation(CustomTestCase): | ||
| M = [128, 129, 257] | ||
| N = [22016, 22018] | ||
| dtype = [torch.float16, torch.bfloat16] | ||
|
|
||
| def _silu_and_mul_test(self, m, n, dtype): | ||
| set_global_server_args_for_scheduler(ServerArgs(model_path="dummy")) | ||
|
|
||
| x = torch.randn([m, n], dtype=dtype) | ||
|
|
||
| out = torch.ops.sgl_kernel.silu_and_mul_cpu(x) | ||
| ref_out = SiluAndMul(x) | ||
|
|
||
| atol = rtol = precision[ref_out.dtype] | ||
| torch.testing.assert_close(ref_out, out, atol=atol, rtol=rtol) | ||
|
|
||
| def _gelu_and_mul_test(self, m, n, dtype): | ||
| x = torch.randn([m, n], dtype=dtype) | ||
|
|
||
| out = torch.ops.sgl_kernel.gelu_and_mul_cpu(x) | ||
| ref_out = GeluAndMul(x, approximate="none") | ||
|
|
||
| atol = rtol = precision[ref_out.dtype] | ||
| torch.testing.assert_close(ref_out, out, atol=atol, rtol=rtol) | ||
|
|
||
| def _gelu_tanh_and_mul_test(self, m, n, dtype): | ||
| x = torch.randn([m, n], dtype=dtype) | ||
|
|
||
| out = torch.ops.sgl_kernel.gelu_tanh_and_mul_cpu(x) | ||
| ref_out = GeluAndMul(x, approximate="tanh") | ||
|
|
||
| atol = rtol = precision[ref_out.dtype] | ||
| torch.testing.assert_close(ref_out, out, atol=atol, rtol=rtol) | ||
|
|
||
| def test_activation(self): | ||
| for params in itertools.product(self.M, self.N, self.dtype): | ||
| with self.subTest(m=params[0], n=params[1], dtype=params[2]): | ||
| self._silu_and_mul_test(*params) | ||
| self._gelu_and_mul_test(*params) | ||
| self._gelu_tanh_and_mul_test(*params) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import re | ||
| import unittest | ||
|
|
||
| import torch | ||
|
|
||
| kernel = torch.ops.sgl_kernel | ||
|
|
||
| from sglang.test.ci.ci_register import register_cpu_ci | ||
| from sglang.test.test_utils import CustomTestCase | ||
|
|
||
| register_cpu_ci(est_time=10, suite="stage-b-test-cpu") | ||
|
|
||
|
|
||
| class TestBinding(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() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling
set_global_server_args_for_schedulerinside_silu_and_mul_testis redundant and inefficient because it is executed for every parameter combination in thetest_activationloop. It should be called once at the beginning oftest_activationor in asetUpmethod.