Skip to content

Commit 5ed8cac

Browse files
authored
Tune test script for mthreads (#2429)
1 parent 0f9a6c7 commit 5ed8cac

2 files changed

Lines changed: 67 additions & 62 deletions

File tree

tools/run_backend_tests_iluvatar.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
#!/bin/bash
22

3-
# TODO(Qiming): Drop this ... this script is only for Iluvatar.
4-
VENDOR=${1:?"Usage: bash tools/run_backend_tests_iluvatar.sh <vendor>"}
5-
export GEMS_VENDOR=$VENDOR
3+
VENDOR=${1:-iluvatar}
64

7-
# Common setup
5+
#=== Common setup ===
86
export PYENV_ROOT="$HOME/.pyenv"
97
export PATH="$PYENV_ROOT/bin:$PATH"
108
eval "$(pyenv init - bash)"
@@ -66,3 +64,8 @@ TEST_FILES=(
6664
"tests/test_FLA/test_fla_utils_input_guard.py"
6765
"tests/test_FLA/test_fused_recurrent_gated_delta_rule.py"
6866
)
67+
68+
for testcase in "${TEST_FILES[@]}"; do
69+
echo "Testing $testcase"
70+
pytest -s --tb=line $testcase --ref cpu
71+
done
Lines changed: 60 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,78 @@
11
#!/bin/bash
22

3-
VENDOR=${1}
4-
echo "Running FlagGems tests with GEMS_VENDOR=$VENDOR"
5-
6-
export MUSA_HOME=/usr/local/musa
7-
export PATH=$MUSA_HOME/bin:$PATH
8-
export LD_LIBRARY_PATH=$MUSA_HOME/lib:$LD_LIBRARY_PATH
3+
VENDOR=${1:-mthreads}
94

10-
# PyEnv settings
5+
#=== Common setup ===
116
export PYENV_ROOT="$HOME/.pyenv"
127
export PATH="$PYENV_ROOT/bin:$PATH"
138
eval "$(pyenv init - bash)"
14-
15-
# Preamble
169
pip install -U pip
1710
pip install uv
1811
uv venv
1912
source .venv/bin/activate
2013

14+
echo "Running FlagGems tests with GEMS_VENDOR=$VENDOR"
15+
16+
#=== Install ===
17+
18+
export FLAGOS_PYPI=https://resource.flagos.net/repository/flagos-pypi-${VENDOR}/simple
19+
uv pip install setuptools==79.0.1 scikit-build-core==0.12.2 pybind11==3.0.3 'cmake>=3.20,<4.0' ninja==1.13.0
20+
2121
# Setup
2222
uv pip install setuptools==82.0.1 scikit-build-core==0.12.2 pybind11==3.0.3 cmake==3.31.10 ninja==1.13.0
23-
uv pip install torch==2.7.1+musa.4.0.0 \
24-
--index https://resource.flagos.net/repository/flagos-pypi-mthreads/simple
25-
uv pip install triton==3.1.0+musa1.4.6 \
26-
--index https://resource.flagos.net/repository/flagos-pypi-mthreads/simple
27-
uv pip install torch_musa==2.7.1 \
28-
--index https://resource.flagos.net/repository/flagos-pypi-mthreads/simple
29-
23+
uv pip install --index $FLAGOS_PYPI
24+
"torch==2.7.1+musa.4.0.0" \
25+
"torch_musa==2.7.1" \
26+
"triton==3.1.0+musa1.4.6"
3027
uv pip install -e .[mthreads,test]
3128

29+
#=== Start testing ===
30+
31+
export MUSA_HOME=/usr/local/musa
32+
export PATH=$MUSA_HOME/bin:$PATH
33+
export LD_LIBRARY_PATH=$MUSA_HOME/lib:$LD_LIBRARY_PATH
3234
# For the intel math library
3335
export LD_LIBRARY_PATH=$VIRTUAL_ENV/lib:$LD_LIBRARY_PATH
3436

35-
# Print out package versions for debugging.
36-
uv pip list
37-
38-
# In case the backend detection fails
39-
# export GEMS_VENDOR=$VENDOR
40-
41-
# Reduction ops
42-
# FIXME(moore): Softmax only support float32/float16/bfloat16
43-
# pytest -s tests/test_reduction_ops.py
44-
pytest -s tests/test_general_reduction_ops.py
45-
# FIXME(moore): BatchNorm supports Float/Half/BFloat16 input dtype
46-
# pytest -s tests/test_norm_ops.py
47-
48-
# Pointwise ops
49-
pytest -s tests/test_pointwise_dynamic.py
50-
# FIXME(moore): RuntimeError: _Map_base::at (missing operators)
51-
pytest -s tests/test_unary_pointwise_ops.py
52-
pytest -s tests/test_binary_pointwise_ops.py
53-
pytest -s tests/test_pointwise_type_promotion.py
54-
55-
# TODO: test_accuracy_randperm
56-
pytest -s tests/test_tensor_constructor_ops.py
57-
58-
# BLAS ops
59-
# TODO(Qiming): Fix sharedencoding on Hopper
60-
pytest -s tests/test_attention_ops.py
61-
# FIXME(moore): unsupported data type DOUBLE
62-
# pytest -s tests/test_blas_ops.py
63-
64-
# Special ops
65-
pytest -s tests/test_special_ops.py
66-
67-
# Distribution
68-
pytest -s tests/test_distribution_ops.py
69-
70-
# Convolution ops
71-
pytest -s tests/test_convolution_ops.py
72-
73-
# Utils
74-
# pytest -s tests/test_libentry.py
75-
pytest -s tests/test_shape_utils.py
76-
pytest -s tests/test_tensor_wrapper.py
37+
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
38+
39+
echo "Starting tests..."
40+
41+
TEST_FILES=(
42+
# Reduction
43+
"tests/test_reduction_ops.py"
44+
"tests/test_general_reduction_ops.py"
45+
"tests/test_norm_ops.py"
46+
# Pointwise
47+
"tests/test_pointwise_dynamic.py"
48+
"tests/test_unary_pointwise_ops.py"
49+
"tests/test_binary_pointwise_ops.py"
50+
"tests/test_pointwise_type_promotion.py"
51+
# Tensor
52+
"tests/test_tensor_constructor_ops.py"
53+
"tests/test_tensor_wrapper.py"
54+
# Attention
55+
"tests/test_attention_ops.py"
56+
"tests/test_blas_ops.py"
57+
# Special
58+
"tests/test_special_ops.py"
59+
# Distribution
60+
"tests/test_distribution_ops.py"
61+
# Convolution
62+
"tests/test_convolution_ops.py"
63+
# Utils
64+
"tests/test_libentry"
65+
"tests/test_shape_utils.py"
66+
# DSA
67+
"tests/test_DSA/test_bin_topk.py"
68+
"tests/test_DSA/test_sparse_mla_ops.py"
69+
"tests/test_DSA/test_indexer_k_tiled.py"
70+
# FLA
71+
"tests/test_FLA/test_fla_utils_input_guard.py"
72+
"tests/test_FLA/test_fused_recurrent_gated_delta_rule.py"
73+
)
74+
75+
for testcase in "${TEST_FILES[@]}"; do
76+
echo "Testing $testcase"
77+
pytest -s --tb=line $testcase --ref cpu
78+
done

0 commit comments

Comments
 (0)