Skip to content

Commit d72e21f

Browse files
authored
Merge branch 'master' into pr/linalg-lstsq-metax2
2 parents 417c394 + bfeca79 commit d72e21f

111 files changed

Lines changed: 14518 additions & 1961 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/CODEOWNERS

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@
2020
/src/flag_gems/* @0x45f @huangyiqun @103yiran @douxetpur @bin913 @w1120029931-bit @hellojack163 @Caeruleann @tengqm
2121
/src/flag_gems/runtime/backend/*
2222

23-
/tests/* @0x45f @huangyiqun @103yiran @douxetpur @bin913 @w1120029931-bit @hellojack163 @Caeruleann @tengqm
23+
/benchmark/* @0x45f @huangyiqun @103yiran @douxetpur @bin913 @w1120029931-bit @hellojack163 @Caeruleann
24+
/tests/* @0x45f @huangyiqun @103yiran @douxetpur @bin913 @w1120029931-bit @hellojack163 @Caeruleann
2425
/modules_tests/* @0x45f @huangyiqun @103yiran @douxetpur @bin913 @w1120029931-bit @hellojack163 @Caeruleann
25-
/benchmark/* @0x45f @huangyiqun @103yiran @douxetpur @bin913 @w1120029931-bit @hellojack163 @Caeruleann @tengqm
26-
/docs/* @0x45f @huangyiqun @103yiran @tengqm
27-
/container/* @0x45f @huangyiqun @103yiran @tengqm
26+
/docs/* @0x45f @huangyiqun @103yiran
27+
/tools/* @0x45f @huangyiqun @103yiran
2828

29-
/lib/* @0x45f @huangyiqun @103yiran @douxetpur @bin913 @w1120029931-bit @hellojack163 @Caeruleann
30-
/ctests/* @0x45f @huangyiqun @103yiran @douxetpur @bin913 @w1120029931-bit @hellojack163 @Caeruleann
31-
/include/* @0x45f @huangyiqun @103yiran @douxetpur @bin913 @w1120029931-bit @hellojack163 @Caeruleann
29+
/cpp/* @0x45f @huangyiqun @103yiran @douxetpur @bin913 @w1120029931-bit @hellojack163 @Caeruleann
30+
/triton_src/* @0x45f @huangyiqun @103yiran @douxetpur @bin913 @w1120029931-bit @hellojack163 @Caeruleann

.github/workflows/command.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,19 @@ jobs:
4444
skip_reviews: "true"
4545
fork_review_bypass: "true"
4646
permissions: "write,admin"
47+
param_separator: " "
4748

4849
- id: parse-command
4950
if: ${{ steps.check.outputs.continue == 'true' }}
5051
env:
5152
PULL_NUMBER: ${{ github.event.issue.number }}
53+
COMMENT_BODY: ${{ steps.check.outputs.comment_body }}
5254
run: |
5355
# Parse command arguments
54-
params=${{ steps.check.outputs.params }}
55-
op=$(echo $params | cut -d ':' -f 1)
56-
runner=$(echo $params | cut -d ':' -f 2)
56+
# Comment format: "/test <op>:<runner>", e.g. "/test constant_pad_nd:mthreads"
57+
params="${COMMENT_BODY#/test }"
58+
op="${params%%:*}"
59+
runner="${params##*:}"
5760
echo "OP_ID=${op}" >> $GITHUB_OUTPUT
5861
echo "RUNNER=${runner}" >> $GITHUB_OUTPUT
5962
echo "PR_NUMBER=${PULL_NUMBER}" >> $GITHUB_OUTPUT

benchmark/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,9 @@ def get_latency(self, op, *args, **kwargs):
310310
do_bench = triton.backends.ascend.testing.do_bench_npu
311311
latency = do_bench(
312312
fn,
313-
warmup=Config.warm_up,
314-
active=Config.repetition,
313+
# do_bench_npu requires iterations, rather than duration
314+
# warmup=Config.warm_up,
315+
# active=Config.repetition,
315316
)
316317
else:
317318
do_bench = triton.testing.do_bench

benchmark/core_shapes.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,38 @@ grouped_mm:
272272
- [64, 2048, 128]
273273
shape_desc: "Groups, N, K" # shapes are defined as (Groups, N, K)
274274

275+
sparse_sampled_addmm:
276+
shapes:
277+
- [2, 128, 128, 128]
278+
- [4, 256, 256, 256]
279+
- [8, 512, 512, 512]
280+
- [16, 512, 512, 512]
281+
- [4, 1024, 1024, 1024]
282+
- [16, 1024, 1024, 1024]
283+
- [8, 2048, 2048, 64]
284+
- [2, 2048, 2048, 128]
285+
- [4, 4096, 4096, 128]
286+
- [1, 4096, 4096, 64]
287+
- [2, 4096, 1024, 512]
288+
- [2, 1024, 1000, 384]
289+
shape_desc: "B, M, N, K"
290+
291+
sparse_sampled_addmm_out:
292+
shapes:
293+
- [2, 128, 128, 128]
294+
- [4, 256, 256, 256]
295+
- [8, 512, 512, 512]
296+
- [16, 512, 512, 512]
297+
- [4, 1024, 1024, 1024]
298+
- [16, 1024, 1024, 1024]
299+
- [8, 2048, 2048, 64]
300+
- [2, 2048, 2048, 128]
301+
- [4, 4096, 4096, 128]
302+
- [1, 4096, 4096, 64]
303+
- [2, 4096, 1024, 512]
304+
- [2, 1024, 1000, 384]
305+
shape_desc: "B, M, N, K"
306+
275307
MvAndOuterBenchmark:
276308
shapes:
277309
- [384, 384]
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Copyright 2026 FlagOS Contributors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import pytest
16+
import torch
17+
import torch.nn.functional as F
18+
19+
from . import base, consts
20+
21+
22+
class NormBenchmark(base.GenericBenchmark):
23+
def set_more_shapes(self):
24+
return [
25+
# 3D shapes represented as [batch_size, channels, hidden_size]
26+
(16, 16, 64),
27+
(16, 16, 1024),
28+
(16, 16, 4098),
29+
# 4D shapes represented as [batch_size, channels, H, W]
30+
(1, 8, 4, 4),
31+
(16, 8, 128, 128),
32+
]
33+
34+
35+
def native_batch_norm_legit_no_training_input_fn(shape, dtype, device):
36+
C = shape[1]
37+
inp = torch.randn(shape, dtype=dtype, device=device)
38+
weight = torch.randn((C,), dtype=dtype, device=device)
39+
bias = torch.randn((C,), dtype=dtype, device=device)
40+
running_mean = torch.randn((C,), dtype=dtype, device=device)
41+
running_var = torch.abs(torch.randn((C,), dtype=dtype, device=device)) + 0.1
42+
momentum = 0.1
43+
eps = 1e-5
44+
yield inp, weight, bias, running_mean, running_var, momentum, eps
45+
46+
47+
def torch_native_batch_norm_legit_no_training(
48+
inp, weight, bias, running_mean, running_var, momentum, eps
49+
):
50+
return F.batch_norm(
51+
inp, running_mean, running_var, weight, bias, training=False, eps=eps
52+
)
53+
54+
55+
@pytest.mark.native_batch_norm_legit_no_training
56+
def test_native_batch_norm_legit_no_training():
57+
bench = NormBenchmark(
58+
input_fn=native_batch_norm_legit_no_training_input_fn,
59+
op_name="native_batch_norm_legit_no_training",
60+
torch_op=torch_native_batch_norm_legit_no_training,
61+
dtypes=consts.FLOAT_DTYPES,
62+
)
63+
bench.run()

benchmark/test_absolute.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,14 @@ def test_absolute():
2424
op_name="absolute", torch_op=torch.absolute, dtypes=consts.FLOAT_DTYPES
2525
)
2626
bench.run()
27+
28+
29+
@pytest.mark.absolute_
30+
def test_absolute_inplace():
31+
bench = base.UnaryPointwiseBenchmark(
32+
op_name="absolute_",
33+
torch_op=lambda x: x.absolute_(),
34+
dtypes=consts.FLOAT_DTYPES,
35+
is_inplace=True,
36+
)
37+
bench.run()

benchmark/test_arctanh.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,26 @@
1313
# limitations under the License.
1414

1515
import pytest
16+
import torch
1617

1718
import flag_gems
1819

1920
from . import base, consts
2021

2122

23+
@pytest.mark.arctanh
24+
@pytest.mark.skipif(
25+
flag_gems.vendor_name == "tsingmicro", reason="Issue #4131: not working"
26+
)
27+
def test_arctanh():
28+
bench = base.UnaryPointwiseBenchmark(
29+
op_name="arctanh",
30+
torch_op=torch.arctanh,
31+
dtypes=consts.FLOAT_DTYPES,
32+
)
33+
bench.run()
34+
35+
2236
@pytest.mark.arctanh_
2337
@pytest.mark.skipif(
2438
flag_gems.vendor_name == "tsingmicro", reason="Issue #4131: not working"
@@ -31,3 +45,16 @@ def test_arctanh_inplace():
3145
is_inplace=True,
3246
)
3347
bench.run()
48+
49+
50+
@pytest.mark.arctanh_out
51+
@pytest.mark.skipif(
52+
flag_gems.vendor_name == "tsingmicro", reason="Issue #4131: not working"
53+
)
54+
def test_arctanh_out():
55+
bench = base.UnaryPointwiseOutBenchmark(
56+
op_name="arctanh_out",
57+
torch_op=torch.arctanh,
58+
dtypes=consts.FLOAT_DTYPES,
59+
)
60+
bench.run()

0 commit comments

Comments
 (0)