test: skip Triton kernel tests when Triton is unavailable - #83
Merged
Conversation
nosyndicate
marked this pull request as ready for review
July 18, 2026 22:20
There was a problem hiding this comment.
Pull request overview
This PR prevents pytest collection failures in environments without Triton by adding pytest.importorskip("triton") guards before importing Triton-backed kernels/scripts, turning hard import errors into clean test skips.
Changes:
- Add
pytest.importorskip("triton")to affected test modules to avoid collection-time ImportErrors. - Defer Triton-dependent imports and add
# noqa: E402where needed to satisfy linting.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/scripts/test_bench_paged_attention.py | Skips benchmark-table tests when Triton is unavailable to prevent collection errors from script imports. |
| tests/model/test_paged_attention_kernel.py | Skips Triton kernel unit tests when Triton is unavailable; defers kernel import to post-guard. |
| tests/model/test_kv_cache_kernels.py | Skips KV-cache Triton kernel tests when Triton is unavailable; defers kernel imports to post-guard. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+16
to
+19
| pytest.importorskip("triton") | ||
|
|
||
| from server.model.kernels.paged_attention import paged_attention_forward # noqa: E402 | ||
| from tests.model.utils import requires_cuda # noqa: E402 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Previously, three test modules imported Triton-backed kernels at module load time, causing pytest collection to error out on machines without Triton (e.g. CUDA-less environments) instead of cleanly skipping the tests.
This adds a
pytest.importorskip("triton")guard before those imports so the affected tests are skipped rather than failing collection.tests/model/test_kv_cache_kernels.py: guardstore_kv_cache/store_kv_cache_batchedimports.tests/model/test_paged_attention_kernel.py: guardpaged_attention_forwardimport.tests/scripts/test_bench_paged_attention.py: guardscripts.bench_paged_attentionimports.# noqa: E402to the now module-level-deferred imports to satisfy lint.