Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 30, 2025

This PR implements comprehensive pytest testing for the atomic_add benchmark example and fixes data type compatibility issues.

Changes Made

Testing Implementation

  • Added parametrized tests covering multiple data types and buffer sizes
  • Created bench_atomic_add() wrapper function for testing compatibility
  • Fixed HIP kernel configuration error by using shmem.ones() instead of shmem.arange() for large buffer initialization

Data Type Support Fix

  • Removed int8 support from both test and main files since atomic_add operations don't support int8 data types
  • Updated supported data types to match the atomic_add unit tests: int32, int64, float16, bfloat16, float32
  • Updated command-line argument choices and internal mappings accordingly

Documentation

  • Updated atomic_add README with correct title and testing instructions

The tests now align with the actual capabilities of the atomic_add operation and should pass CI validation.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Implement pytest for 04_atomic_add/atomic_add_bench.py Implement pytest for 04_atomic_add/atomic_add_bench.py Aug 30, 2025
Copilot finished work on behalf of mawad-amd August 30, 2025 22:06
@Copilot Copilot AI requested a review from mawad-amd August 30, 2025 22:06
@mawad-amd
Copy link
Collaborator

@copilot

CI Log

tests/examples/test_atomic_add_bench.py::test_atomic_add_bench[512-4294967296-8589934592-dtype0] FAILED [ 12%]
tests/examples/test_atomic_add_bench.py::test_atomic_add_bench[512-4294967296-8589934592-dtype1] PASSED [ 25%]
tests/examples/test_atomic_add_bench.py::test_atomic_add_bench[512-4294967296-8589934592-dtype2] PASSED [ 37%]
tests/examples/test_atomic_add_bench.py::test_atomic_add_bench[512-4294967296-8589934592-dtype3] PASSED [ 50%]
tests/examples/test_atomic_add_bench.py::test_atomic_add_bench[1024-4294967296-8589934592-dtype0] FAILED [ 62%]
tests/examples/test_atomic_add_bench.py::test_atomic_add_bench[1024-4294967296-8589934592-dtype1] PASSED [ 75%]
tests/examples/test_atomic_add_bench.py::test_atomic_add_bench[1024-4294967296-8589934592-dtype2] PASSED [ 87%]
tests/examples/test_atomic_add_bench.py::test_atomic_add_bench[1024-4294967296-8589934592-dtype3] PASSED [100%]

=================================== FAILURES ===================================
___________ test_atomic_add_bench[512-4294967296-8589934592-dtype0] ____________
tests/examples/test_atomic_add_bench.py:51: in test_atomic_add_bench
source_buffer = shmem.arange(buffer_size // element_size_bytes, dtype=dtype)
iris/iris.py:238: in arange
tensor[:] = torch.arange(start, end, step, dtype=dtype, device="cuda")
E RuntimeError: HIP error: invalid configuration argument
E HIP kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
E For debugging consider passing AMD_SERIALIZE_KERNEL=3
E Compile with TORCH_USE_HIP_DSA to enable device-side assertions.
___________ test_atomic_add_bench[1024-4294967296-8589934592-dtype0] ___________
tests/examples/test_atomic_add_bench.py:51: in test_atomic_add_bench
source_buffer = shmem.arange(buffer_size // element_size_bytes, dtype=dtype)
iris/iris.py:238: in arange
tensor[:] = torch.arange(start, end, step, dtype=dtype, device="cuda")
E RuntimeError: HIP error: invalid configuration argument
E HIP kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
E For debugging consider passing AMD_SERIALIZE_KERNEL=3
E Compile with TORCH_USE_HIP_DSA to enable device-side assertions.
=========================== short test summary info ============================
FAILED tests/examples/test_atomic_add_bench.py::test_atomic_add_bench[512-4294967296-8589934592-dtype0] - RuntimeError: HIP error: invalid configuration argument
HIP kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing AMD_SERIALIZE_KERNEL=3
Compile with TORCH_USE_HIP_DSA to enable device-side assertions.
FAILED tests/examples/test_atomic_add_bench.py::test_atomic_add_bench[1024-4294967296-8589934592-dtype0] - RuntimeError: HIP error: invalid configuration argument
HIP kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing AMD_SERIALIZE_KERNEL=3
Compile with TORCH_USE_HIP_DSA to enable device-side assertions.
========================= 2 failed, 6 passed in 11.94s =========================
Error: Process completed with exit code 1.

…shmem.ones() instead of shmem.arange()

Co-authored-by: mawad-amd <[email protected]>
Copy link
Contributor Author

Copilot AI commented Aug 31, 2025

@copilot

CI Log

...

Fixed the HIP kernel configuration error by changing the test to use shmem.ones() instead of shmem.arange() for buffer initialization. This resolves the "invalid configuration argument" issue that was occurring with large buffer sizes (4GB+) and matches the pattern used in the working test_load_bench.py. The change doesn't affect the performance testing since validation is disabled in the test.

Commit: 6d3ad46

@Copilot Copilot AI changed the title Implement pytest for 04_atomic_add/atomic_add_bench.py Implement pytest for 04_atomic_add/atomic_add_bench.py with HIP kernel fix Aug 31, 2025
@Copilot Copilot AI requested a review from mawad-amd August 31, 2025 03:33
Copilot finished work on behalf of mawad-amd August 31, 2025 03:33
Copilot finished work on behalf of mawad-amd August 31, 2025 03:36
Comment on lines 25 to 26
[
torch.int8,
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot atomic_add does not support int8

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're correct! I've removed int8 from both the test and the main atomic_add_bench.py file since atomic_add doesn't support int8. Updated to use the supported data types (int32, int64, float16, bfloat16, float32) that match the unit tests. (commit: )

@Copilot Copilot AI changed the title Implement pytest for 04_atomic_add/atomic_add_bench.py with HIP kernel fix Implement pytest for 04_atomic_add/atomic_add_bench.py and fix data type support Aug 31, 2025
@Copilot Copilot AI requested a review from mawad-amd August 31, 2025 04:11
Copilot finished work on behalf of mawad-amd August 31, 2025 04:11
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