[Bugfix][V2] Warm up kernels before capturing CUDA graphs (#55341)
Signed-off-by: aoshen02 <aoshen02@users.noreply.github.com> Signed-off-by: Nick Hill <nickhill123@gmail.com> Co-authored-by: aoshen02 <aoshen02@users.noreply.github.com> Co-authored-by: Nick Hill <nickhill123@gmail.com>
This commit is contained in:
co-authored by
aoshen02
Nick Hill
parent
8f269a93bb
commit
685074cd61
@@ -82,6 +82,30 @@ def test_workspace_lanes_compose_with_ubatches(monkeypatch) -> None:
|
||||
assert len(pointers) == 4
|
||||
|
||||
|
||||
def test_workspace_lock_blocks_growth_and_unlock_restores(monkeypatch) -> None:
|
||||
"""Once locked, oversized requests fail loudly instead of reallocating the
|
||||
buffer that captured CUDA graphs point at; unlock restores growth."""
|
||||
monkeypatch.setattr(workspace, "dbo_current_ubatch_id", lambda: 0)
|
||||
manager = workspace.WorkspaceManager(torch.device("cpu"), num_lanes=1)
|
||||
|
||||
(buf,) = manager.get_simultaneous(((256,), torch.uint8))
|
||||
manager.lock()
|
||||
assert manager.is_locked()
|
||||
|
||||
# Requests within the reserved size still reuse the same buffer.
|
||||
(same,) = manager.get_simultaneous(((256,), torch.uint8))
|
||||
(smaller,) = manager.get_simultaneous(((8,), torch.uint8))
|
||||
assert same.data_ptr() == buf.data_ptr()
|
||||
assert smaller.data_ptr() == buf.data_ptr()
|
||||
|
||||
with pytest.raises(AssertionError, match="Workspace is locked"):
|
||||
manager.get_simultaneous(((512,), torch.uint8))
|
||||
|
||||
manager.unlock()
|
||||
(grown,) = manager.get_simultaneous(((512,), torch.uint8))
|
||||
assert grown.numel() == 512
|
||||
|
||||
|
||||
def test_workspace_lane_validation(monkeypatch) -> None:
|
||||
monkeypatch.setattr(workspace, "dbo_current_ubatch_id", lambda: 0)
|
||||
manager = workspace.WorkspaceManager(torch.device("cpu"), num_lanes=1)
|
||||
|
||||
Reference in New Issue
Block a user