MCPcopy
hub / github.com/hpcaitech/ColossalAI / benchmark_func

Function benchmark_func

colossalai/auto_parallel/offload/solver.py:21–39  ·  view source on GitHub ↗

benchmark data transfer cost.

(func, number=1, repeat=1, warmup=3)

Source from the content-addressed store, hash-verified

19
20
21def benchmark_func(func, number=1, repeat=1, warmup=3):
22 """
23 benchmark data transfer cost.
24 """
25
26 for i in range(warmup):
27 func()
28
29 costs = []
30
31 for i in range(repeat):
32 torch.cuda.synchronize()
33 begin = time.time()
34 for i in range(number):
35 func()
36 torch.cuda.synchronize()
37 costs.append((time.time() - begin) / number)
38
39 return sum(costs) / len(costs)
40
41
42class Solver(ABC):

Callers 1

_profile_bandwidthMethod · 0.85

Calls 2

synchronizeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…