Skip to content

Commit c5aafff

Browse files
authored
Kernels unittest fix ljl (#61)
* feat(tests): replace manual sp_group retrieval with module attribute Replace calls to `_get_sp_group_from_device_mesh` with direct access to `sequence_parallel._sp_group` in sequence parallel attention tests. This simplifies the test setup by using the already initialized group stored in the module, improving code clarity and reducing redundancy. * feat(tests): improve kernel availability check in test_function_kernel Add additional imports and a try-except block to verify that the 'kernels-test/flattened-build' kernel can be successfully loaded in the current environment before proceeding with the test. This prevents test failures due to environment-specific loading issues and provides a more informative skip message.
1 parent 3ed9edd commit c5aafff

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/kernel/test_function_kernel.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,21 @@ def test_flattened_build_replaces_function(self):
5454
self.skipTest(f'HuggingFace unreachable: {e}')
5555
try:
5656
from kernels import has_kernel
57+
from kernels._versions import select_revision_or_version
58+
from kernels.utils import get_kernel
5759
except Exception:
5860
self.skipTest('kernels package missing has_kernel.')
5961
if not has_kernel('kernels-test/flattened-build'):
6062
self.skipTest('kernels-test/flattened-build not available.')
63+
try:
64+
revision = select_revision_or_version(
65+
'kernels-test/flattened-build',
66+
revision=None,
67+
version=None,
68+
)
69+
get_kernel('kernels-test/flattened-build', revision=revision)
70+
except Exception as exc:
71+
self.skipTest(f'kernels-test/flattened-build cannot be loaded in this env: {exc}')
6172

6273
_ensure_test_packages()
6374
module_name = 'tests.kernel._tmp_flattened_build_module'

0 commit comments

Comments
 (0)