ROCm / ROCm/aiter

test_mha.py:test_mha_backward fails with causal=True and seqlen_q < seqlen_k

Open
#289 0 comments 0 reactions 1 assignee View on GitHub

@juuso-oskari is already working on this.

Since Apr 14, 2025.

bug
Dominant language
Python
Stars
565
Forks
585
Avg merge
3d 4h
Merged PRs (30d)
366

Description

How to reproduce:

At the main branch, add this:

if __name__ == "__main__":
    # TODO: fails for causal=True and seqlen_q < seqlen_k
    test_mha_backward(8, 1024, 4096, 16, 16, 128, 0.0, True, False, torch.float16)

to op_tests/triton/test_mha.py, and then run:

python $AITERDIR/op_tests/triton/test_mha.py

Produces:

Traceback (most recent call last):
  File "/home/jukorhon/aiter//op_tests/triton/test_mha.py", line 404, in <module>
    test_mha_backward(8, 1024, 4096, 16, 16, 128, 0.0, True, False, torch.float16)
  File "/home/jukorhon/aiter//op_tests/triton/test_mha.py", line 289, in test_mha_backward
    torch.testing.assert_close(triton_dv, torch_dv.to(triton_out.dtype),atol=1e-2, rtol=1e-2)
  File "/opt/conda/envs/register_fix/lib/python3.9/site-packages/torch/testing/_comparison.py", line 1530, in assert_close
    raise error_metas[0].to_error(msg)
AssertionError: Tensor-likes are not close!

Mismatched elements: 60880756 / 67108864 (90.7%)
Greatest absolute difference: 8.78125 at index (1, 2333, 12, 1) (up to 0.01 allowed)
Greatest relative difference: inf at index (0, 5, 6, 78) (up to 0.01 allowed)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.