Skip to content

Commit

Permalink
Add cuda sync
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywonchung committed Oct 13, 2023
1 parent 6ab19d9 commit 1a9fa0f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions zeus/optimizer/perseus/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
FrequencySchedule,
)
from zeus.util.env import resolve_gpu_indices
from zeus.util.framework import cuda_sync


class PerseusOptimizer(Callback):
Expand Down Expand Up @@ -213,6 +214,8 @@ def on_instruction_begin(self, name: str) -> None:
expected instruction matches the name of the instruction, and set the
frequency accordingly.
"""
cuda_sync(self.cuda_device_id)

# Retrieve the next frequency from the schedule.
item = next(self.freq_schedule_iter, None)
if item is None:
Expand All @@ -228,3 +231,6 @@ def on_instruction_begin(self, name: str) -> None:
)

self.frequency_controller.set_frequency(frequency)

def on_instruction_end(self, _: str) -> None:
"""Mark the end of an instruction, like forward and backward."""

0 comments on commit 1a9fa0f

Please sign in to comment.