[Hardware] Replace torch.cuda.synchronize() api with torch.accelerator.synchronize (#36085)

Signed-off-by: Kunshang Ji <kunshang.ji@intel.com>
This commit is contained in:
Kunshang Ji
2026-03-05 10:36:39 +00:00
committed by GitHub
parent 0bfa229bf1
commit 66a2209645
59 changed files with 158 additions and 161 deletions
+4 -4
View File
@@ -928,7 +928,7 @@ class GPUModelRunner(
# Note: used for model runner override.
def _sync_device(self) -> None:
torch.cuda.synchronize()
torch.accelerator.synchronize()
def _update_states(self, scheduler_output: "SchedulerOutput") -> None:
"""Update the cached states and the persistent batch with the scheduler
@@ -5345,7 +5345,7 @@ class GPUModelRunner(
cudagraph_runtime_mode=runtime_mode,
)
torch.cuda.synchronize()
torch.accelerator.synchronize()
end_free_gpu_memory = torch.cuda.mem_get_info()[0]
# Disable cudagraph capturing globally, so any unexpected cudagraph
@@ -6266,13 +6266,13 @@ class GPUModelRunner(
group_refs = group_lora_refs[current_item_idx : current_item_idx + num_items]
group_request_ids = {req_id for req_id, _ in group_refs}
torch.cuda.synchronize()
torch.accelerator.synchronize()
start_time = time.perf_counter()
try:
yield
finally:
torch.cuda.synchronize()
torch.accelerator.synchronize()
elapsed = time.perf_counter() - start_time
per_request_time = elapsed / max(len(group_request_ids), 1)