[CPU] Fix torch.compile crash from torch.accelerator.synchronize on CPU-only hosts (#49960)
Signed-off-by: R <Ganesh.R@amd.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Li, Jiang <jiang1.li@intel.com>
This commit is contained in:
co-authored by
Cursor
Li, Jiang <jiang1.li@intel.com>
parent
32c42c4f2f
commit
ec40f6a8a6
@@ -17,6 +17,12 @@ def noop(*args: Any, **kwargs: Any) -> None:
|
||||
pass
|
||||
|
||||
|
||||
# Distinct no-op so empty_cache does not alias synchronize: Dynamo's
|
||||
# handle_synchronize is keyed on that object and asserts on CPU-only hosts.
|
||||
def empty_cache_noop(*args: Any, **kwargs: Any) -> None:
|
||||
pass
|
||||
|
||||
|
||||
def fake_pin_memory(self: torch.Tensor, *args: Any, **kwargs: Any) -> torch.Tensor:
|
||||
return self
|
||||
|
||||
@@ -58,7 +64,7 @@ torch.cuda.Stream = _StreamPlaceholder
|
||||
torch.cuda.set_stream = noop
|
||||
torch.cuda.current_stream = lambda *args, **kwargs: _StreamPlaceholder()
|
||||
torch.accelerator.synchronize = noop
|
||||
torch.accelerator.empty_cache = noop
|
||||
torch.accelerator.empty_cache = empty_cache_noop
|
||||
torch.Tensor.pin_memory = fake_pin_memory
|
||||
torch.Tensor.record_stream = noop
|
||||
torch.accelerator.get_memory_info = get_memory_info
|
||||
|
||||
@@ -240,5 +240,10 @@ def _set_torch_accelerator_to_noop() -> None:
|
||||
def noop(*args: Any, **kwargs: Any) -> None:
|
||||
pass
|
||||
|
||||
# Distinct no-op so empty_cache does not alias synchronize: Dynamo's
|
||||
# handle_synchronize is keyed on that object and asserts on CPU-only hosts.
|
||||
def empty_cache_noop(*args: Any, **kwargs: Any) -> None:
|
||||
pass
|
||||
|
||||
torch.accelerator.synchronize = noop
|
||||
torch.accelerator.empty_cache = noop
|
||||
torch.accelerator.empty_cache = empty_cache_noop
|
||||
|
||||
Reference in New Issue
Block a user