Implement pytest tests for 06_message_passing examples #127
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds comprehensive pytest test coverage for the message passing examples in
examples/06_message_passing/
, following the established pattern fromtest_load_bench.py
.Overview
The implementation provides test coverage for both message passing examples:
message_passing_load_store.py
- Uses iris load/store operations for inter-rank communicationmessage_passing_put.py
- Uses iris put operations for inter-rank communicationKey Features
Comprehensive Test Coverage: The new
test_message_passing.py
provides 32 test combinations across:int8
,fp16
,bf16
,fp32
(4096, 1MB)
,(8192, 2MB)
512
,1024
Faithful Implementation: The tests exactly reproduce the validation logic from the original examples, ensuring that
destination_buffer == source_buffer * 2
after the producer-consumer message passing operations complete.Proper MPI Handling: Uses
pytest.skip()
to gracefully handle environments that don't have exactly 2 MPI ranks, which is required by the message passing examples.Clean Architecture: Implements helper functions that mirror the original example structure:
create_test_args()
- Creates argument dictionaries matching the originalparse_args()
outputrun_message_passing_kernels()
- Executes the core kernel logic without command-line argument parsingUsage
The tests follow the exact same pattern as the existing
test_load_bench.py
, using dynamic module imports viaimportlib.util
and parameterized test functions for comprehensive coverage.Fixes #60.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.