Skip to content
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

Disables memory usage assertions #3641

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
)
from pylibcugraph import uniform_neighbor_sample

# Set to True to disable memory leak assertions. This may be necessary when
# running in environments that share a GPU (pytest-xdist), are using memory
# pools, or other reasons which may cause the memory leak assertions to
# improperly fail.
mem_leak_assert_disabled = True

# =============================================================================
# Pytest fixtures
Expand Down Expand Up @@ -256,7 +261,7 @@ def test_neighborhood_sampling_large_sg_graph(gpubenchmark):
expected_delta = free_memory_before - free_before_cleanup
leak = expected_delta - actual_delta
print(f" {result_bytes=} {actual_delta=} {expected_delta=} {leak=}")
assert free_memory_before == device.mem_info[0]
assert (free_memory_before == device.mem_info[0]) or mem_leak_assert_disabled


def test_sample_result():
Expand Down Expand Up @@ -289,7 +294,7 @@ def test_sample_result():
device_batch_label=cp.arange(1e8 + 6, dtype="int32"),
)

assert free_memory_before > device.mem_info[0]
assert (free_memory_before > device.mem_info[0]) or mem_leak_assert_disabled

sources = sampling_result.get_sources()
destinations = sampling_result.get_destinations()
Expand All @@ -304,7 +309,7 @@ def test_sample_result():
# keeping the refcount >0.
del sampling_result
gc.collect()
assert free_memory_before > device.mem_info[0]
assert (free_memory_before > device.mem_info[0]) or mem_leak_assert_disabled

# Check that the data is still valid
assert sources[999] == 999
Expand All @@ -324,9 +329,9 @@ def test_sample_result():

# sources2 should be keeping the data alive
assert sources2[999] == 999
assert free_memory_before > device.mem_info[0]
assert (free_memory_before > device.mem_info[0]) or mem_leak_assert_disabled

# All memory should be freed once the last reference is deleted
del sources2
gc.collect()
assert free_memory_before == device.mem_info[0]
assert (free_memory_before == device.mem_info[0]) or mem_leak_assert_disabled