Skip to content

Commit 5d7f9fc

Browse files
authored
Merge branch 'master' into masked_select
2 parents 471ebf5 + 31abbd3 commit 5d7f9fc

194 files changed

Lines changed: 6063 additions & 705 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/gems-cpp-extension.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ name: gems-cpp-extension
33
on:
44
push:
55
branches: [ "master" ]
6+
paths:
7+
- '**.py'
8+
- '**.cpp'
9+
- '**.cu'
10+
- '**.h'
11+
- '**.hpp'
12+
- '**.cc'
13+
- 'CMakeLists.txt'
14+
- '**/*.cmake'
15+
- '**/*.mk'
16+
- 'Makefile'
617
pull_request:
718
branches: [ "master" ]
819
paths:

.github/workflows/gems-test-on-hopper.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,30 @@ name: flag-gems-test-on-hopper
33
on:
44
push:
55
branches: [ "master" ]
6+
paths:
7+
- '**.py'
8+
- '**.cpp'
9+
- '**.cu'
10+
- '**.h'
11+
- '**.hpp'
12+
- '**.cc'
13+
- 'CMakeLists.txt'
14+
- '**/*.cmake'
15+
- '**/*.mk'
16+
- 'Makefile'
617
pull_request:
718
branches: [ "master" ]
19+
paths:
20+
- '**.py'
21+
- '**.cpp'
22+
- '**.cu'
23+
- '**.h'
24+
- '**.hpp'
25+
- '**.cc'
26+
- 'CMakeLists.txt'
27+
- '**/*.cmake'
28+
- '**/*.mk'
29+
- 'Makefile'
830

931
jobs:
1032
op-test-on-hopper:

.github/workflows/gems-test-on-metax.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,30 @@ name: flag-gems-test-on-metax
33
on:
44
push:
55
branches: [ "master" ]
6+
paths:
7+
- '**.py'
8+
- '**.cpp'
9+
- '**.cu'
10+
- '**.h'
11+
- '**.hpp'
12+
- '**.cc'
13+
- 'CMakeLists.txt'
14+
- '**/*.cmake'
15+
- '**/*.mk'
16+
- 'Makefile'
617
pull_request:
718
branches: [ "master" ]
19+
paths:
20+
- '**.py'
21+
- '**.cpp'
22+
- '**.cu'
23+
- '**.h'
24+
- '**.hpp'
25+
- '**.cc'
26+
- 'CMakeLists.txt'
27+
- '**/*.cmake'
28+
- '**/*.mk'
29+
- 'Makefile'
830

931
jobs:
1032
op-test-on-metax:

.github/workflows/python-coverage.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,30 @@ name: python-coverage
33
on:
44
push:
55
branches: [ "master" ]
6+
paths:
7+
- '**.py'
8+
- '**.cpp'
9+
- '**.cu'
10+
- '**.h'
11+
- '**.hpp'
12+
- '**.cc'
13+
- 'CMakeLists.txt'
14+
- '**/*.cmake'
15+
- '**/*.mk'
16+
- 'Makefile'
617
pull_request:
718
branches: [ "master" ]
19+
paths:
20+
- '**.py'
21+
- '**.cpp'
22+
- '**.cu'
23+
- '**.h'
24+
- '**.hpp'
25+
- '**.cc'
26+
- 'CMakeLists.txt'
27+
- '**/*.cmake'
28+
- '**/*.mk'
29+
- 'Makefile'
830

931
jobs:
1032
blas-op-test:

benchmark/core_shapes.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ ConvBenchmark:
187187

188188
AttentionBenchmark:
189189
shapes:
190-
- [4, 8, 512, 128]
191-
- [4, 8, 1024, 128]
192-
- [4, 8, 2048, 128]
193-
- [4, 8, 3072, 128]
194-
- [4, 8, 4096, 128]
190+
- [4, 32, 1024, 64]
191+
- [4, 32, 1024, 128]
192+
- [4, 32, 2048, 128]
193+
- [4, 32, 4096, 128]
194+
- [4, 32, 8192, 128]
195195

196196
KronBenchmark:
197197
shapes:

benchmark/test_attention_perf.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,33 @@ def set_more_shapes(self):
2222
flag_gems.device == "musa" or vendor_name == "hygon", reason="RuntimeError"
2323
)
2424
@pytest.mark.attention
25-
def test_perf_scaled_dot_product_attention():
25+
@pytest.mark.parametrize("dropout_p", [0.0, 0.25])
26+
@pytest.mark.parametrize("is_causal", [True, False])
27+
def test_perf_scaled_dot_product_attention(dropout_p, is_causal):
2628
def scaled_dot_product_attention_kwargs(shape, dtype, device):
2729
query = torch.randn(shape, device=device, dtype=dtype)
2830
key = torch.randn(shape, device=device, dtype=dtype)
2931
value = torch.randn(shape, device=device, dtype=dtype)
30-
yield query, key, value, None, 0.0, True
32+
yield query, key, value, dropout_p, is_causal
33+
34+
def sdpa_flash(query, key, value, dropout_p=dropout_p, is_causal=is_causal):
35+
from torch.nn.attention import SDPBackend, sdpa_kernel
36+
37+
with sdpa_kernel(backends=[SDPBackend.FLASH_ATTENTION]):
38+
torch.nn.functional.scaled_dot_product_attention(
39+
query,
40+
key,
41+
value,
42+
attn_mask=None,
43+
dropout_p=dropout_p,
44+
is_causal=is_causal,
45+
)
3146

3247
bench = AttentionBenchmark(
3348
op_name="scaled_dot_product_attention",
3449
input_fn=scaled_dot_product_attention_kwargs,
35-
torch_op=torch.nn.functional.scaled_dot_product_attention,
50+
# torch_op=torch.nn.functional.scaled_dot_product_attention,
51+
torch_op=sdpa_flash,
3652
dtypes=[
3753
torch.float16,
3854
torch.bfloat16,

benchmark/test_special_perf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def unique_input_fn(shape, dtype, device):
118118
def test_perf_sort():
119119
class SortBenchmark(GenericBenchmark2DOnly):
120120
def set_more_shapes(self):
121-
return [(1024, 1), (1024, 512)]
121+
return [(1024, 1), (1024, 512), (16, 128 * 1024), (8, 256 * 1024)]
122122

123123
def sort_input_fn(shape, dtype, device):
124124
inp = generate_tensor_input(shape, dtype, device)

benchmark/test_tensor_concat_perf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ def repeat_interleave_tensor_input_fn(shape, dtype, device):
197197
def test_tensor_repeat_benchmark(op_name, torch_op, input_fn, dtypes):
198198
if vendor_name == "kunlunxin" and op_name in [
199199
"repeat_interleave_self_tensor",
200-
"repeat_interleave_tensor",
201200
]:
202201
pytest.skip("RUNTIME TODOFIX")
203202
bench = TensorRepeatBenchmark(

benchmark/test_unary_pointwise_perf.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
FLOAT_DTYPES,
1313
INT_DTYPES,
1414
)
15-
from .performance_utils import Benchmark, generate_tensor_input, vendor_name
15+
from .performance_utils import Benchmark, generate_tensor_input
1616

1717

1818
class UnaryPointwiseBenchmark(Benchmark):
@@ -94,8 +94,6 @@ def get_tflops(self, op, *args, **kwargs):
9494
],
9595
)
9696
def test_general_unary_pointwise_perf(op_name, torch_op, dtypes):
97-
if vendor_name == "kunlunxin" and op_name == "elu":
98-
pytest.skip("RUNTIME TODOFIX")
9997
bench = UnaryPointwiseBenchmark(op_name=op_name, torch_op=torch_op, dtypes=dtypes)
10098
bench.run()
10199

ctests/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,13 @@ add_executable(test_triton_norm test_triton_norm.cpp)
1616
target_link_libraries(test_triton_norm
1717
PRIVATE Torch::Torch operators GTest::gtest GTest::gtest_main)
1818
add_test(NAME test_triton_norm COMMAND test_triton_norm)
19+
20+
add_executable(test_triton_rope test_triton_rope.cpp)
21+
target_link_libraries(test_triton_rope
22+
PRIVATE Torch::Torch operators GTest::gtest GTest::gtest_main)
23+
add_test(NAME test_triton_rope COMMAND test_triton_rope)
24+
25+
add_executable(test_triton_bmm test_triton_bmm.cpp)
26+
target_link_libraries(test_triton_bmm
27+
PRIVATE Torch::Torch operators GTest::gtest GTest::gtest_main)
28+
add_test(NAME test_triton_bmm COMMAND test_triton_bmm)

0 commit comments

Comments
 (0)