CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
71 lines
1.9 KiB
Python
71 lines
1.9 KiB
Python
"""Heap-base introspection tests.
|
|
|
|
Validates rocshmem4py.rocshmem_get_heap_bases (raw pointer list) and
|
|
rocshmem4py.interop.torch.get_heap_bases (int64 CUDA tensor).
|
|
"""
|
|
|
|
import pytest
|
|
|
|
import rocshmem4py
|
|
from rocshmem4py import (
|
|
rocshmem_my_pe,
|
|
rocshmem_n_pes,
|
|
rocshmem_get_heap_bases,
|
|
)
|
|
from conftest import requires_torch
|
|
|
|
|
|
def test_get_heap_bases_returns_n_pes_entries():
|
|
"""Bare-Python helper returns one entry per PE."""
|
|
nbytes = 1024
|
|
buf = rocshmem4py.SymmetricBuffer(nbytes)
|
|
try:
|
|
bases = rocshmem_get_heap_bases(buf.ptr)
|
|
assert isinstance(bases, list)
|
|
assert len(bases) == rocshmem_n_pes()
|
|
finally:
|
|
buf.free()
|
|
|
|
|
|
def test_local_pe_entry_is_self_pointer():
|
|
"""bases[my_pe] == the local allocation's pointer."""
|
|
nbytes = 1024
|
|
buf = rocshmem4py.SymmetricBuffer(nbytes)
|
|
try:
|
|
bases = rocshmem_get_heap_bases(buf.ptr)
|
|
me = rocshmem_my_pe()
|
|
assert bases[me] == buf.ptr
|
|
finally:
|
|
buf.free()
|
|
|
|
|
|
@requires_torch
|
|
def test_get_heap_bases_torch_helper_shape_and_dtype():
|
|
"""Torch helper returns (n_pes,) int64 CUDA tensor."""
|
|
import torch
|
|
from rocshmem4py.interop.torch import create_tensor, get_heap_bases
|
|
|
|
n = rocshmem_n_pes()
|
|
t = create_tensor((1024,), torch.uint8)
|
|
try:
|
|
bases = get_heap_bases(t)
|
|
assert bases.shape == (n,)
|
|
assert bases.dtype == torch.int64
|
|
assert bases.is_cuda
|
|
# Local entry matches the local data pointer.
|
|
assert int(bases[rocshmem_my_pe()].item()) == t.data_ptr()
|
|
finally:
|
|
from rocshmem4py.interop.torch import free_tensor
|
|
free_tensor(t)
|
|
|
|
|
|
@requires_torch
|
|
def test_get_heap_bases_rejects_non_symmetric_tensor():
|
|
"""Helper raises on a non-symmetric tensor."""
|
|
import torch
|
|
from rocshmem4py.interop.torch import get_heap_bases
|
|
|
|
t = torch.zeros(10, device="cuda")
|
|
with pytest.raises(ValueError, match="not a symmetric tensor"):
|
|
get_heap_bases(t)
|