test_example_flash_attention.py 2.71 KB
Newer Older
1
2
3
import tilelang.testing

import example_gqa_bwd
4
import example_gqa_bwd_wgmma_pipelined
5
import example_mha_bwd_bshd
6
import example_mha_bwd_bhsd
7
8
9
10
11
12
import example_mha_fwd_bhsd_wgmma_pipelined
import example_gqa_fwd_bshd
import example_mha_fwd_bshd
import example_gqa_fwd_bshd_wgmma_pipelined
import example_mha_fwd_bshd_wgmma_pipelined
import example_mha_fwd_varlen
13
import example_mha_bwd_bshd_wgmma_pipelined
14
import example_mha_fwd_bhsd
15
16
17
18
19
20
import example_gqa_bwd_tma_reduce_varlen


@tilelang.testing.requires_cuda
def test_example_gqa_bwd_tma_reduce_varlen():
    example_gqa_bwd_tma_reduce_varlen.main()
21
22
23
24
25
26
27


@tilelang.testing.requires_cuda
def test_example_gqa_bwd():
    example_gqa_bwd.main()


28
29
30
31
32
33
@tilelang.testing.requires_cuda
@tilelang.testing.requires_cuda_compute_version_ge(9, 0)
def test_example_gqa_bwd_wgmma_pipelined():
    example_gqa_bwd_wgmma_pipelined.main()


34
35
@tilelang.testing.requires_cuda
def test_example_mha_bwd():
36
    example_mha_bwd_bshd.main(
37
38
39
40
41
42
        BATCH=1,
        H=16,
        N_CTX=512,
        D_HEAD=64,
        causal=False,
    )
43
44


45
46
@tilelang.testing.requires_cuda
def test_example_mha_bwd_bhsd():
47
48
49
50
51
52
53
    example_mha_bwd_bhsd.main(
        BATCH=1,
        H=16,
        N_CTX=512,
        D_HEAD=64,
        causal=False,
    )
54
55


56
57
58
@tilelang.testing.requires_cuda
@tilelang.testing.requires_cuda_compute_version_ge(9, 0)
def test_example_mha_bwd_wgmma_pipelined():
59
    example_mha_bwd_bshd_wgmma_pipelined.main(BATCH=1, H=32, N_CTX=256, D_HEAD=64, causal=False)
60
61
62


@tilelang.testing.requires_cuda
63
@tilelang.testing.requires_cuda_compute_version_ge(9, 0)
64
def test_example_gqa_fwd_bshd_wgmma_pipelined():
65
66
    example_gqa_fwd_bshd_wgmma_pipelined.main(
        batch=1, heads=16, seq_len=1024, dim=128, is_causal=False, groups=16, tune=False)
67
68
69
70


@tilelang.testing.requires_cuda
def test_example_gqa_fwd_bshd():
71
72
    example_gqa_fwd_bshd.main(
        batch=1, heads=16, seq_len=1024, dim=128, is_causal=False, groups=16, tune=False)
73
74
75


@tilelang.testing.requires_cuda
76
@tilelang.testing.requires_cuda_compute_version_ge(9, 0)
77
78
79
80
81
82
83
84
85
86
def test_example_mha_fwd_bhsd_wgmma_pipelined():
    example_mha_fwd_bhsd_wgmma_pipelined.main()


@tilelang.testing.requires_cuda
def test_example_mha_fwd_bhsd():
    example_mha_fwd_bhsd.main()


@tilelang.testing.requires_cuda
87
@tilelang.testing.requires_cuda_compute_version_ge(9, 0)
88
def test_example_mha_fwd_bshd_wgmma_pipelined():
89
    example_mha_fwd_bshd_wgmma_pipelined.main(batch=1, heads=32, seq_len=256)
90
91
92
93


@tilelang.testing.requires_cuda
def test_example_mha_fwd_bshd():
94
    example_mha_fwd_bshd.main(batch=1, seq_len=256)
95
96
97
98


@tilelang.testing.requires_cuda
def test_example_mha_fwd_varlen():
99
    example_mha_fwd_varlen.main(batch=4, heads=16, seq_len=512, dim=64)
100
101
102
103


if __name__ == "__main__":
    tilelang.testing.main()