Skip to content

[gluon] Refactor gluon test#20

Open
apinge wants to merge 4 commits into
tingqli:mainfrom
apinge:adjust_gluon_text
Open

[gluon] Refactor gluon test#20
apinge wants to merge 4 commits into
tingqli:mainfrom
apinge:adjust_gluon_text

Conversation

@apinge

@apinge apinge commented May 17, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@apinge apinge requested a review from sammysun0711 May 17, 2026 07:01
@apinge

apinge commented May 18, 2026

Copy link
Copy Markdown
Collaborator Author

Still getting the following error with pytest :

========================================================== short test summary info ===========================================================
FAILED moe_gemm.py::test_acc - AssertionError: kernel_type='mxn_splitk_2s', B=129, weight_type=torch.bfloat16, TILE_M=32, TILE_N=64, run_count=0
FAILED moe_gemm.py::test_perf[batch0] - AssertionError: kernel_type='mxn_splitk_2s', B=512, weight_type=torch.bfloat16, TILE_M=32, TILE_N=64, run_count=10
FAILED moe_gemm_4wave.py::test_acc - AssertionError: kernel_type='mxn_splitk_2s', B=166, weight_type=torch.bfloat16, TILE_M=128, TILE_N=64, run_count=0
FAILED moe_gemm_4wave.py::test_perf[batch0] - AssertionError: kernel_type='mxn_splitk_2s', B=2048, weight_type=torch.bfloat16, TILE_M=128, TILE_N=64, run_count=10
FAILED moe_splitk.py::test_acc - NameError: name 'USE_FP4_SHUFFLE_WEIGHT' is not defined
============================================ 5 failed, 5 passed, 2 warnings in 1693.30s (0:28:13) ============================================

0522 update All tests passed.

~/workspace/pyhip/tests/contrib# ./run_gluon_test.sh 
======================================================================================== test session starts ========================================================================================
platform linux -- Python 3.12.3, pytest-9.0.3, pluggy-1.6.0
rootdir: /root/workspace/pyhip
configfile: pytest.ini
plugins: hypothesis-6.152.1
collected 979 items                                                                                                                                                                                 

gluon/gemm_splitk.py ..                                                                                                                                                                       [  0%]
gluon/moe_gemm.py ........................................................................................................................................................................... [ 17%]
............................................................................................................................................................................................. [ 36%]
...............................................................................................................................................................                               [ 53%]
gluon/moe_gemm_4wave.py ..................................................................................................................................................................... [ 70%]
............................................................................................................................................................................................. [ 89%]
....................................................................................................                                                                                          [ 99%]
gluon/moe_splitk.py ..                                                                                                                                                                        [ 99%]
gluon/test_fused_mlp.py ..                                                                                                                                                                    [100%]

========================================================================================= warnings summary ==========================================================================================
tests/contrib/gluon/gemm_splitk.py::test_perf[M0]
  /opt/venv/lib/python3.12/site-packages/_pytest/python.py:170: PytestReturnNotNoneWarning: Test functions should return None, but tests/contrib/gluon/gemm_splitk.py::test_perf[M0] returned <class 'dict'>.
  Did you mean to use `assert` instead of `return`?
  See https://docs.pytest.org/en/stable/how-to/assert.html#return-not-none for more information.
    warnings.warn(

tests/contrib/gluon/test_fused_mlp.py::test_perf[M0]
  /opt/venv/lib/python3.12/site-packages/_pytest/python.py:170: PytestReturnNotNoneWarning: Test functions should return None, but tests/contrib/gluon/test_fused_mlp.py::test_perf[M0] returned <class 'dict'>.
  Did you mean to use `assert` instead of `return`?
  See https://docs.pytest.org/en/stable/how-to/assert.html#return-not-none for more information.
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================================================================== 979 passed, 2 warnings in 1784.48s (0:29:44) ============================================================================

@apinge apinge changed the title Refactor gluon test [gluon] Refactor gluon test May 19, 2026
@apinge apinge marked this pull request as ready for review May 22, 2026 04:08

@sammysun0711 sammysun0711 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, leave minor comment.

Comment on lines +300 to +310
ACC_BATCH_SIZES = _acc_batch_sizes()

# (32, 64): moe_gemm_new.log — B in range(2, 64) all passed; B>=129 mostly AssertionError/OOM.
# Skip range(128,256), 256/512/768, 2048/8192, 6144+ for now; needs deep dive on mxn_splitk_2s + TILE_N=64.
ACC_BATCH_SIZES_TILE_64 = list(range(2, 64))

_ACC_CASES = (
[(32, 128, b) for b in ACC_BATCH_SIZES]
+ [(32, 64, b) for b in ACC_BATCH_SIZES_TILE_64]
)
_ACC_CASE_IDS = [f"TILE={m}x{n}-B={b}" for m, n, b in _ACC_CASES]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make it as function like: _acc_batch_sizes, use parameter name that easy to understand.

_ACC_CASE_IDS = [f"TILE={m}x{n}-B={b}" for m, n, b in _ACC_CASES]

@pytest.mark.parametrize("HIDDEN_SIZE,INTER_SIZE,TP", [(4096, 1024, 8)])
@pytest.mark.parametrize("TILE_M,TILE_N,B", _ACC_CASES, ids=_ACC_CASE_IDS)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is default value for B here?

Comment on lines +330 to +334
# TODO(TILE 32x64): moe_gemm_perf_only.log — mxn_splitk_2s vs ref AssertionError (e.g. B=256):
# - E=32, INTER_SIZE=2048 FAIL
# - E=512, INTER_SIZE=1024 FAIL
# - E=512, INTER_SIZE=2048 FAIL
# - E=32, INTER_SIZE=1024 PASS (only passing 32x64 combo)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it limitation of moe_gemm kernel or just missing test case coverage?

Comment on lines +154 to +160
def _acc_batch_sizes():
batch = list(range(2, 64))
batch += list(range(128, 256))
batch += [i * 256 for i in range(1, 4)]
batch += [i * 2048 for i in range(1, 5)]
batch += list(range(2048 * 3, 2048 * 3 + 256))
entry_common('mxn_splitk_2s', batch=batch, prec=[torch.bfloat16], TILE_M=TILE_M, TILE_N=TILE_N, HIDDEN_SIZE=HIDDEN_SIZE, INTER_SIZE=INTER_SIZE, TP=TP, run_count=0)
return batch

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seem the same function redefine in different moe kernel, can we move it in common place to reuse?

@sammysun0711

Copy link
Copy Markdown
Collaborator

I met following issue on gfx942:
Should we skip test on gfx942?

/root/workspace/pyhiptests/contrib# ./run_gluon_test.sh 
=============================================== test session starts ===============================================
platform linux -- Python 3.10.12, pytest-9.0.2, pluggy-1.6.0
rootdir: /root/workspace/pyhip_gluon/pyhip
configfile: pytest.ini
plugins: anyio-4.12.1, asyncio-1.3.0
asyncio: mode=strict, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 979 items                                                                                               

gluon/gemm_splitk.py Fatal Python error: Aborted

Current thread 0x00007f036e483480 (most recent call first):
  File "/usr/local/lib/python3.10/dist-packages/triton/backends/amd/compiler.py", line 513 in make_amdgcn
  File "/usr/local/lib/python3.10/dist-packages/triton/backends/amd/compiler.py", line 544 in <lambda>
  File "/usr/local/lib/python3.10/dist-packages/triton/compiler/compiler.py", line 327 in compile
  File "/usr/local/lib/python3.10/dist-packages/triton/runtime/jit.py", line 894 in _do_compile
  File "/usr/local/lib/python3.10/dist-packages/triton/runtime/jit.py", line 749 in run
  File "/usr/local/lib/python3.10/dist-packages/triton/runtime/jit.py", line 373 in <lambda>
  File "/root/workspace/pyhip_test/pyhip_gluon/pyhip/tests/contrib/gluon/gemm_splitk.py", line 109 in run
  File "/root/workspace/pyhip_test/pyhip_gluon/pyhip/tests/contrib/gluon/gemm_splitk.py", line 146 in _run_batch
  File "/root/workspace/pyhip_test/pyhip_gluon/pyhip/tests/contrib/gluon/gemm_splitk.py", line 193 in entry_common
  File "/root/workspace/pyhip_test/pyhip_gluon/pyhip/tests/contrib/gluon/gemm_splitk.py", line 212 in test_acc
  File "/usr/local/lib/python3.10/dist-packages/_pytest/python.py", line 166 in pytest_pyfunc_call
  File "/usr/local/lib/python3.10/dist-packages/pluggy/_callers.py", line 121 in _multicall
  File "/usr/local/lib/python3.10/dist-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/usr/local/lib/python3.10/dist-packages/pluggy/_hooks.py", line 512 in __call__
  File "/usr/local/lib/python3.10/dist-packages/_pytest/python.py", line 1720 in runtest
  File "/usr/local/lib/python3.10/dist-packages/_pytest/runner.py", line 179 in pytest_runtest_call
  File "/usr/local/lib/python3.10/dist-packages/pluggy/_callers.py", line 121 in _multicall
  File "/usr/local/lib/python3.10/dist-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/usr/local/lib/python3.10/dist-packages/pluggy/_hooks.py", line 512 in __call__
  File "/usr/local/lib/python3.10/dist-packages/_pytest/runner.py", line 245 in <lambda>
  File "/usr/local/lib/python3.10/dist-packages/_pytest/runner.py", line 353 in from_call
  File "/usr/local/lib/python3.10/dist-packages/_pytest/runner.py", line 244 in call_and_report
  File "/usr/local/lib/python3.10/dist-packages/_pytest/runner.py", line 137 in runtestprotocol
  File "/usr/local/lib/python3.10/dist-packages/_pytest/runner.py", line 118 in pytest_runtest_protocol
  File "/usr/local/lib/python3.10/dist-packages/pluggy/_callers.py", line 121 in _multicall
  File "/usr/local/lib/python3.10/dist-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/usr/local/lib/python3.10/dist-packages/pluggy/_hooks.py", line 512 in __call__
  File "/usr/local/lib/python3.10/dist-packages/_pytest/main.py", line 396 in pytest_runtestloop
  File "/usr/local/lib/python3.10/dist-packages/pluggy/_callers.py", line 121 in _multicall
  File "/usr/local/lib/python3.10/dist-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/usr/local/lib/python3.10/dist-packages/pluggy/_hooks.py", line 512 in __call__
  File "/usr/local/lib/python3.10/dist-packages/_pytest/main.py", line 372 in _main
  File "/usr/local/lib/python3.10/dist-packages/_pytest/main.py", line 318 in wrap_session
  File "/usr/local/lib/python3.10/dist-packages/_pytest/main.py", line 365 in pytest_cmdline_main
  File "/usr/local/lib/python3.10/dist-packages/pluggy/_callers.py", line 121 in _multicall
  File "/usr/local/lib/python3.10/dist-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/usr/local/lib/python3.10/dist-packages/pluggy/_hooks.py", line 512 in __call__
  File "/usr/local/lib/python3.10/dist-packages/_pytest/config/__init__.py", line 199 in main
  File "/usr/local/lib/python3.10/dist-packages/_pytest/config/__init__.py", line 223 in console_main
  File "/usr/local/bin/pytest", line 33 in <module>

Extension modules: numpy._core._multiarray_umath, numpy.linalg._umath_linalg, torch._C, torch._C._dynamo.autograd_compiler, torch._C._dynamo.eval_frame, torch._C._dynamo.guards, torch._C._dynamo.utils, torch._C._fft, torch._C._linalg, torch._C._nested, torch._C._nn, torch._C._sparse, torch._C._special, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, Cython.Plex.Actions, Cython.Plex.Scanners, Cython.Compiler.Scanning, pyarrow.lib, pandas._libs.tslibs.ccalendar, pandas._libs.tslibs.np_datetime, pandas._libs.tslibs.dtypes, pandas._libs.tslibs.base, pandas._libs.tslibs.nattype, pandas._libs.tslibs.timezones, pandas._libs.tslibs.fields, pandas._libs.tslibs.timedeltas, pandas._libs.tslibs.tzconversion, pandas._libs.tslibs.timestamps, pandas._libs.properties, pandas._libs.tslibs.offsets, pandas._libs.tslibs.strptime, pandas._libs.tslibs.parsing, pandas._libs.tslibs.conversion, pandas._libs.tslibs.period, pandas._libs.tslibs.vectorized, pandas._libs.ops_dispatch, pandas._libs.missing, pandas._libs.hashtable, pandas._libs.algos, pandas._libs.interval, pandas._libs.lib, pyarrow._compute, pandas._libs.ops, pandas._libs.hashing, pandas._libs.arrays, pandas._libs.tslib, pandas._libs.sparse, pandas._libs.internals, pandas._libs.indexing, pandas._libs.index, pandas._libs.writers, pandas._libs.join, pandas._libs.window.aggregations, pandas._libs.window.indexers, pandas._libs.reshape, pandas._libs.groupby, pandas._libs.json, pandas._libs.parsers, pandas._libs.testing, markupsafe._speedups, hip_utils (total: 69)
./run_gluon_test.sh: line 6: 155604 Aborted                 (core dumped) pytest $SCRIPT_DIR/gluon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants