Skip to content

Commit 430983d

Browse files
committed
test(v4): conftest pins Path A for functional tests — stops SIGABRT mid-sweep
After commit 9854e55 wired LinearAttentionBlock / KimiDeltaAttentionBlock through the path dispatch, functional tests started SIGABRT'ing mid-suite: at ~330 tests deep, the per-process Metal kernel cache + tilelang JIT state can't keep up with auto-mode JIT-compiling fresh kernels per unique shape combination. Path A (FLA naive) is deterministic and shape-independent — perfect default for functional tests. The new autouse fixture in tests/v4/conftest.py pins both CPPMEGA_V4_KERNEL_PATH__LINEAR_ATTENTION and __KDA to 'path_a' for every test file EXCEPT the explicit backend/perf test files that opt out (test_path_dispatch.py, test_block_dispatch_env_override.py, test_path_b_bwd.py, test_kda_path_b_bwd.py, test_benchmark_*, test_linear_attention_path_{b,c,d,e}.py, test_path_e_training.py). Full v4 sweep: 332 passed / 2 skipped (was: aborts at test #330+).
1 parent e3926e8 commit 430983d

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

tests/v4/conftest.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
"""Shared pytest config for the v4 test suite.
2+
3+
Default-pins both kernel-path env vars to "path_a" for tests that
4+
exercise functional invariants (shapes, parity, doc-id propagation).
5+
Tests that explicitly want a non-Path-A backend opt-in via
6+
`monkeypatch.setenv(...)` and the autouse fixture detects that case
7+
by checking whether the test function's own body sets the var.
8+
9+
Without this default, the block-level dispatch wired in commit
10+
9854e55 routes through Path B/C/E whenever they're available, which
11+
compiles fresh Metal/TileLang kernels per shape — at hundreds of
12+
tests' worth of distinct shapes, the per-process Metal kernel cache
13+
+ tilelang JIT state can SIGABRT mid-suite. Path A (FLA naive) is
14+
the reference; perf tests live in dedicated files that opt out.
15+
16+
Opt-out files (run their own backend selection via monkeypatch):
17+
- test_block_dispatch_env_override.py — covers all 5 paths
18+
- test_path_dispatch.py — env-override tests
19+
- test_benchmark_matrix.py — matrix runner
20+
- test_linear_attention_path_b.py / _c.py / _e_*.py / _d.py
21+
- test_kda_paths.py
22+
- test_path_b_bwd.py / test_kda_path_b_bwd.py — bwd kernels
23+
- test_path_e_training.py
24+
"""
25+
26+
from __future__ import annotations
27+
28+
import pytest
29+
30+
31+
_OPT_OUT_FILES = {
32+
"test_block_dispatch_env_override.py",
33+
"test_path_dispatch.py",
34+
"test_benchmark_matrix.py",
35+
"test_linear_attention_path_b.py",
36+
"test_linear_attention_path_c.py",
37+
"test_linear_attention_path_d.py",
38+
"test_linear_attention_path_e.py",
39+
"test_kda_paths.py",
40+
"test_path_b_bwd.py",
41+
"test_kda_path_b_bwd.py",
42+
"test_path_e_training.py",
43+
"test_benchmark_receipt.py",
44+
}
45+
46+
47+
@pytest.fixture(autouse=True)
48+
def _pin_path_a_by_default(request, monkeypatch):
49+
"""Pin both v4 path env vars to path_a unless the test file opts out.
50+
51+
Functional tests (shape, parity, doc-id) want the deterministic
52+
Path A reference. Backend-specific tests opt out and set their
53+
own env vars.
54+
"""
55+
fname = request.node.fspath.basename
56+
if fname not in _OPT_OUT_FILES:
57+
monkeypatch.setenv("CPPMEGA_V4_KERNEL_PATH__LINEAR_ATTENTION", "path_a")
58+
monkeypatch.setenv("CPPMEGA_V4_KERNEL_PATH__KDA", "path_a")
59+
yield

0 commit comments

Comments
 (0)