MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / time_intervals

Function time_intervals

tests/unit/utils/test_timer.py:31–48  ·  view source on GitHub ↗
(timer, run_matmuls, matmuls_per_interval)

Source from the content-addressed store, hash-verified

29
30
31def time_intervals(timer, run_matmuls, matmuls_per_interval):
32 # Each interval is also measured by its own reference events, recorded just inside the timer's
33 # events. The reference durations are the expected values.
34 reference_events = []
35 for num_matmuls in matmuls_per_interval:
36 # Queue work first so the timer's and the reference's start events complete together on the
37 # device, however long the host takes between recording them.
38 run_matmuls(10)
39 reference_start = get_accelerator().Event(enable_timing=True)
40 reference_stop = get_accelerator().Event(enable_timing=True)
41 timer.start()
42 reference_start.record()
43 run_matmuls(num_matmuls)
44 reference_stop.record()
45 timer.stop()
46 reference_events.append((reference_start, reference_stop))
47 get_accelerator().synchronize()
48 return [start.elapsed_time(stop) for start, stop in reference_events]
49
50
51def test_elapsed_is_latest_interval_and_elapsed_total_is_sum(run_matmuls):

Calls 9

get_acceleratorFunction · 0.90
run_matmulsFunction · 0.85
appendMethod · 0.80
elapsed_timeMethod · 0.80
EventMethod · 0.45
startMethod · 0.45
recordMethod · 0.45
stopMethod · 0.45
synchronizeMethod · 0.45

Tested by

no test coverage detected