MCPcopy Create free account
hub / github.com/microsoft/BitNet / Stats

Class Stats

gpu/stats.py:27–57  ·  view source on GitHub ↗

Generation stats, split by phases.

Source from the content-addressed store, hash-verified

25
26
27class Stats:
28 """
29 Generation stats, split by phases.
30 """
31
32 def __init__(self):
33 self.phases = []
34 self.current = None
35
36 def end_phase(self, tokens: int, now: Optional[float] = None):
37 """Terminate the current phase."""
38 if self.current is None:
39 return
40 if now is None:
41 now = time.time()
42 cname, ctokens, ctime = self.current
43 stats = PhaseStats(
44 name=cname,
45 tokens=tokens - ctokens,
46 time=now - ctime,
47 )
48 self.phases.append(stats)
49
50 def phase(self, name: str, tokens: int = 0):
51 """
52 Start a new phase, and terminate the current one,
53 if one is ongoing.
54 """
55 now = time.time()
56 self.end_phase(tokens, now)
57 self.current = (name, tokens, now)

Callers 1

generate_allMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected