Skip to content

Add tests for atomic APIs. #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 14, 2025
Merged

Add tests for atomic APIs. #50

merged 5 commits into from
Jul 14, 2025

Conversation

neoblizz
Copy link
Member

Notes:

============================= test session starts ==============================
platform linux -- Python 3.10.16, pytest-7.3.2, pluggy-1.5.0
rootdir: /workspace/iris
plugins: rerunfailures-14.0, xdoctest-1.1.0, cpp-2.3.0, flakefinder-1.1.0, hypothesis-5.35.1, xdist-3.3.1, anyio-4.9.0, typeguard-4.3.0
collected 540 items

tests/examples/test_load_bench.py ........                               [  1%]
tests/unittests/test_atomic_add.py ..................................... [  8%]
.......................................................................  [ 21%]
tests/unittests/test_atomic_cas.py ..................................... [ 28%]
.......................................................................  [ 41%]
tests/unittests/test_atomic_sub.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF [ 48%]
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF [ 61%]
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF                                      [ 68%]
tests/unittests/test_atomic_xchg.py .................................... [ 74%]
........................................................................ [ 88%]
                                                                         [ 88%]
tests/unittests/test_get.py ................                             [ 91%]
tests/unittests/test_load.py ................                            [ 94%]
tests/unittests/test_put.py ................                             [ 97%]
tests/unittests/test_store.py ................                           [100%]
...
FAILED tests/unittests/test_atomic_sub.py::test_atomic_sub_api[32-sys-acq_rel-dtype2] - AttributeError: module 'triton.language' has no attribute 'atomic_sub'. Did you mean: 'atomic_add'?
FAILED tests/unittests/test_atomic_sub.py::test_atomic_sub_api[32-sys-acq_rel-dtype3] - AttributeError: module 'triton.language' has no attribute 'atomic_sub'. Did you mean: 'atomic_add'?
================== 144 failed, 396 passed in 60.48s (0:01:00) ==================

@Copilot Copilot AI review requested due to automatic review settings July 14, 2025 02:07
@neoblizz neoblizz requested review from mawad-amd and BKP as code owners July 14, 2025 02:07
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds comprehensive unit tests for new atomic operations in the Iris library, covering add, sub, cas, and xchg across multiple data types, memory scopes, and cache‐ordering semantics.

  • Introduces test_atomic_add.py, test_atomic_sub.py, test_atomic_cas.py, and test_atomic_xchg.py
  • Parameterizes tests over data types, scopes (cta, gpu, sys), semaphores (acquire, release, acq_rel), and block sizes
  • Validates correctness of each atomic operation against expected Torch tensors

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
tests/unittests/test_atomic_add.py New parameterized tests for iris.atomic_add
tests/unittests/test_atomic_sub.py New parameterized tests for iris.atomic_sub
tests/unittests/test_atomic_cas.py New parameterized tests for iris.atomic_cas
tests/unittests/test_atomic_xchg.py New parameterized tests for iris.atomic_xchg
Comments suppressed due to low confidence (2)

tests/unittests/test_atomic_cas.py:19

  • [nitpick] Using the name cmp may be confusing (and shadows the old Python2 builtin). Consider renaming to cmp_val or compare_val for clarity.
    cmp = tl.full((), 0, dtype=dtype)  # scalar 0

tests/unittests/test_atomic_sub.py:1

  • Triton does not support atomic_sub, causing these tests to fail with an AttributeError. Add a module‐level skip, e.g., pytest.skipif(not hasattr(iris, 'atomic_sub'), reason='atomic_sub not supported by Triton', allow_module_level=True).
import torch

Copy link
Collaborator

@mawad-amd mawad-amd left a comment

Choose a reason for hiding this comment

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

Looks good, modulo the Copilot comment and a question. Thanks!

@neoblizz
Copy link
Member Author

Looks good, modulo the Copilot comment and a question. Thanks!

Copilot comments are not needed in this case.

@neoblizz neoblizz merged commit 3b4c197 into main Jul 14, 2025
2 checks passed
@neoblizz neoblizz deleted the muhosama/pytest-atomics branch July 14, 2025 19:36
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