mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-08-30 06:30:37 +02:00
fix(gpu): permit bounded CUDA context residue
This commit is contained in:
@@ -6,6 +6,7 @@ from types import SimpleNamespace
|
||||
import pytest
|
||||
|
||||
from obliteratus.benchmark_lifecycle import (
|
||||
MAX_RELEASABLE_ALLOCATOR_RESIDUE_BYTES,
|
||||
admit_benchmark,
|
||||
mark_benchmark_ready,
|
||||
release_benchmark_pipeline,
|
||||
@@ -99,9 +100,36 @@ def test_cleanup_releases_only_after_cuda_is_gone(monkeypatch):
|
||||
assert lifecycle.events == [("release", "benchmark_complete")]
|
||||
|
||||
|
||||
def test_cleanup_releases_with_bounded_cuda_context_residue(monkeypatch):
|
||||
lifecycle = _LifecycleRecorder()
|
||||
memory = MemoryUsage(
|
||||
allocated_bytes=25_559_040,
|
||||
reserved_bytes=62_914_560,
|
||||
device_count=3,
|
||||
)
|
||||
assert memory.reserved_bytes < MAX_RELEASABLE_ALLOCATOR_RESIDUE_BYTES
|
||||
monkeypatch.setattr(
|
||||
"obliteratus.benchmark_lifecycle.measure_torch_memory", lambda _torch: memory
|
||||
)
|
||||
|
||||
release_benchmark_pipeline(
|
||||
[SimpleNamespace(handle=SimpleNamespace(model=object(), tokenizer=object()))],
|
||||
reason="benchmark_complete",
|
||||
lifecycle=lifecycle,
|
||||
torch_module=SimpleNamespace(cuda=SimpleNamespace(is_available=lambda: False)),
|
||||
device_module=SimpleNamespace(empty_cache=lambda: None),
|
||||
)
|
||||
|
||||
assert lifecycle.events == [("release", "benchmark_complete")]
|
||||
|
||||
|
||||
def test_cleanup_retains_lease_when_cuda_remains(monkeypatch):
|
||||
lifecycle = _LifecycleRecorder()
|
||||
memory = MemoryUsage(allocated_bytes=1, reserved_bytes=2, device_count=1)
|
||||
memory = MemoryUsage(
|
||||
allocated_bytes=MAX_RELEASABLE_ALLOCATOR_RESIDUE_BYTES + 1,
|
||||
reserved_bytes=MAX_RELEASABLE_ALLOCATOR_RESIDUE_BYTES + 1,
|
||||
device_count=1,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"obliteratus.benchmark_lifecycle.measure_torch_memory", lambda _torch: memory
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user