-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Forward
shuffle
to trainer server and measure GPU (#526)
1. Add a unit test to how we pack the `StartTrainingRequest`, thereby catching the unspecified `shuffle`. 2. Enable accurate GPU operations measurement.
- Loading branch information
Showing
12 changed files
with
422 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
modyn/tests/trainer_server/internal/test_gpu_measurement.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import time | ||
from unittest.mock import patch | ||
|
||
from modyn.common.benchmark import Stopwatch | ||
from modyn.trainer_server.internal.trainer.gpu_measurement import GPUMeasurement | ||
|
||
|
||
@patch("modyn.trainer_server.internal.trainer.pytorch_trainer.torch.cuda.synchronize") | ||
def test_gpu_measurement(cuda_synchronize_mock): | ||
stopwatch = Stopwatch() | ||
with ( | ||
patch.object(Stopwatch, "stop", wraps=stopwatch.stop) as stopwatch_stop_mock, | ||
patch.object(Stopwatch, "start", wraps=stopwatch.start) as stopwatch_start_mock, | ||
): | ||
|
||
with GPUMeasurement(True, "measure", "cpu", stopwatch, resume=True): | ||
time.sleep(1) | ||
|
||
stopwatch_start_mock.assert_called_once_with(name="measure", resume=True) | ||
stopwatch_stop_mock.assert_called_once_with(name="measure") | ||
assert cuda_synchronize_mock.call_count == 2 | ||
assert 1000 <= stopwatch.measurements["measure"] <= 1100 | ||
|
||
stopwatch_start_mock.reset_mock() | ||
stopwatch_stop_mock.reset_mock() | ||
cuda_synchronize_mock.reset_mock() | ||
with GPUMeasurement(False, "measure2", "cpu", stopwatch, overwrite=False): | ||
pass | ||
|
||
stopwatch_start_mock.assert_called_once_with(name="measure2", overwrite=False) | ||
stopwatch_stop_mock.assert_called_once_with(name="measure2") | ||
assert cuda_synchronize_mock.call_count == 0 | ||
# we still want to take the (inaccurate) measurement | ||
assert "measure2" in stopwatch.measurements |
Oops, something went wrong.