File size: 1,958 Bytes
621477d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# SPDX-FileCopyrightText: 2026 SZL Holdings
# SPDX-License-Identifier: Apache-2.0
"""Kernel-builder layout checks. These are not performance tests."""

from __future__ import annotations

import re
from pathlib import Path

import pytest

_ROOT = Path(__file__).resolve().parents[1]
_NAME_RE = re.compile(r"^[a-z][-a-z0-9]*[a-z0-9]$")


@pytest.mark.kernels_ci
def test_build_toml_edition_5_torch_noarch():
    text = (_ROOT / "build.toml").read_text(encoding="utf-8")
    assert "edition = 5" in text
    assert "[torch-noarch]" in text
    assert "[kernel." not in text
    assert 'name = "yarqa-attn"' in text
    assert _NAME_RE.match("yarqa-attn")
    assigned_triton = [
        line
        for line in text.splitlines()
        if "triton" in line.lower()
        and not line.lstrip().startswith("#")
        and "=" in line
    ]
    assert assigned_triton == []
    assert 'repo-id = "SZLHOLDINGS/YARQA-ATTN"' in text
    assert 'backends = ["cpu"]' in text


@pytest.mark.kernels_ci
def test_no_benchmarks_directory():
    """Honesty: this package does not ship fabricated benches."""
    assert not (_ROOT / "benchmarks").exists()


@pytest.mark.kernels_ci
def test_required_kernel_builder_files():
    for rel in (
        "build.toml",
        "CARD.md",
        "LICENSE",
        "README.md",
        "flake.nix",
        "torch-ext/yarqa_attn/__init__.py",
        "torch-ext/yarqa_attn/attn.py",
        "torch-ext/yarqa_attn/_chain.py",
        "tests/test_yarqa_attn.py",
    ):
        assert (_ROOT / rel).is_file(), rel


@pytest.mark.kernels_ci
def test_ops_py_not_authored():
    """kernel-builder generates _ops.py. Do not ship a handwritten one."""
    assert not (_ROOT / "torch-ext/yarqa_attn/_ops.py").exists()


@pytest.mark.kernels_ci
def test_flake_pytest_is_check_input_only():
    text = (_ROOT / "flake.nix").read_text(encoding="utf-8")
    assert "pythonCheckInputs" in text
    assert "pythonBuildInputs =" not in text