This commit is contained in:
Jianwei Dong
2025-11-25 20:52:08 +08:00
committed by GitHub
parent 2cffdf7033
commit 51745a9ea1
14 changed files with 845 additions and 48 deletions

View File

@@ -0,0 +1,4 @@
"""Per-commit tests for KT-Kernel.
Tests in this directory are run on every commit in CI.
"""

View File

@@ -0,0 +1,36 @@
"""AMD/ROCm backend tests for KT-Kernel (Placeholder).
This file is a placeholder for future AMD/ROCm backend tests.
Currently, KT-Kernel focuses on CPU optimizations (Intel AMX/AVX512).
To implement AMD tests:
1. Add actual test functions with @pytest.mark.amd
2. Update the estimated time in register_amd_ci()
3. Implement AMD/ROCm-specific initialization and validation tests
"""
import os
import sys
# Add parent directory to path for CI registration
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from ci.ci_register import register_amd_ci
# Register this test for AMD CI (estimated time: 10 seconds, placeholder)
# Update suite name when implementing: currently using "stage-a-test-1"
register_amd_ci(est_time=10, suite="stage-a-test-1")
def test_amd_placeholder():
"""Placeholder test for AMD/ROCm backend.
TODO: Implement actual AMD/ROCm tests when AMD support is added to kt-kernel.
"""
# Currently a no-op placeholder
pass
if __name__ == "__main__":
# Allow running standalone (required by test runner)
print("⚠ AMD/ROCm tests are not yet implemented (placeholder)")
print("✓ Placeholder test passed")

View File

@@ -0,0 +1,80 @@
"""Basic CPU backend tests for KT-Kernel.
These tests verify basic functionality without requiring model files.
"""
import os
import sys
import pytest
# Add parent directory to path for CI registration
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from ci.ci_register import register_cpu_ci
# Register this test for CPU CI with estimated runtime of 30 seconds
register_cpu_ci(est_time=30, suite="default")
# Check if kt_kernel_ext is available
try:
import kt_kernel_ext
HAS_KT_KERNEL = True
except ImportError:
HAS_KT_KERNEL = False
kt_kernel_ext = None
@pytest.mark.cpu
def test_kt_kernel_import():
"""Test that kt_kernel_ext can be imported."""
if not HAS_KT_KERNEL:
pytest.skip("kt_kernel_ext not built or available")
assert kt_kernel_ext is not None, "kt_kernel_ext module should be importable"
@pytest.mark.cpu
def test_cpu_infer_initialization():
"""Test that CPUInfer can be initialized."""
if not HAS_KT_KERNEL:
pytest.skip("kt_kernel_ext not built or available")
# Initialize CPUInfer with 4 threads
cpuinfer = kt_kernel_ext.CPUInfer(4)
assert cpuinfer is not None, "CPUInfer should be initialized successfully"
@pytest.mark.cpu
def test_basic_module_attributes():
"""Test that kt_kernel_ext has expected attributes."""
if not HAS_KT_KERNEL:
pytest.skip("kt_kernel_ext not built or available")
# Check for key attributes/functions
assert hasattr(kt_kernel_ext, 'CPUInfer'), "kt_kernel_ext should have CPUInfer class"
def run_all_tests():
"""Run all tests in this file (for standalone execution)."""
if not HAS_KT_KERNEL:
print("⚠ kt_kernel_ext not available, skipping tests")
return
try:
test_kt_kernel_import()
print("✓ test_kt_kernel_import passed")
test_cpu_infer_initialization()
print("✓ test_cpu_infer_initialization passed")
test_basic_module_attributes()
print("✓ test_basic_module_attributes passed")
print("\n✓ All tests passed!")
except Exception as e:
print(f"\n✗ Test failed: {e}")
sys.exit(1)
if __name__ == "__main__":
# Allow running standalone (required by test runner)
run_all_tests()

View File

@@ -0,0 +1,36 @@
"""CUDA backend tests for KT-Kernel (Placeholder).
This file is a placeholder for future CUDA backend tests.
Currently, KT-Kernel focuses on CPU optimizations (Intel AMX/AVX512).
To implement CUDA tests:
1. Add actual test functions with @pytest.mark.cuda
2. Update the estimated time in register_cuda_ci()
3. Implement CUDA-specific initialization and validation tests
"""
import os
import sys
# Add parent directory to path for CI registration
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from ci.ci_register import register_cuda_ci
# Register this test for CUDA CI (estimated time: 10 seconds, placeholder)
# Update suite name when implementing: currently using "stage-a-test-1"
register_cuda_ci(est_time=10, suite="stage-a-test-1")
def test_cuda_placeholder():
"""Placeholder test for CUDA backend.
TODO: Implement actual CUDA tests when CUDA support is added to kt-kernel.
"""
# Currently a no-op placeholder
pass
if __name__ == "__main__":
# Allow running standalone (required by test runner)
print("⚠ CUDA tests are not yet implemented (placeholder)")
print("✓ Placeholder test passed")