Skip to content

test: skip Triton kernel tests when Triton is unavailable - #83

Merged
nosyndicate merged 1 commit into
mainfrom
phase4_35
Jul 18, 2026
Merged

test: skip Triton kernel tests when Triton is unavailable#83
nosyndicate merged 1 commit into
mainfrom
phase4_35

Conversation

@nosyndicate

@nosyndicate nosyndicate commented Jul 18, 2026

Copy link
Copy Markdown
Owner

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: guard store_kv_cache / store_kv_cache_batched imports.
  • tests/model/test_paged_attention_kernel.py: guard paged_attention_forward import.
  • tests/scripts/test_bench_paged_attention.py: guard scripts.bench_paged_attention imports.
  • Add # noqa: E402 to the now module-level-deferred imports to satisfy lint.

@nosyndicate nosyndicate changed the title fix the broken test when cuda is missing test: skip Triton kernel tests when Triton is unavailable Jul 18, 2026
@nosyndicate
nosyndicate marked this pull request as ready for review July 18, 2026 22:20
Copilot AI review requested due to automatic review settings July 18, 2026 22:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: E402 where 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
@nosyndicate
nosyndicate merged commit ef80797 into main Jul 18, 2026
1 check passed
@nosyndicate
nosyndicate deleted the phase4_35 branch July 18, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants