Bases: LMOperationalMetric
Average wall-clock latency in seconds per LM call over this run.
Computed as elapsed_s / calls. Because elapsed_s accumulates each
call's own duration, this reports the mean per-call latency regardless of
how many calls ran concurrently -- unlike Throughput, which divides by
the phase's wall-clock span and so does reflect concurrency. The two
coincide (latency = 1 / throughput) only when calls run serially.
Example:
program.compile(
metrics=[
synalinks.metrics.AvgLatency(),
],
)
Source code in synalinks/src/metrics/lm_metrics.py
| @synalinks_export("synalinks.metrics.AvgLatency")
class AvgLatency(LMOperationalMetric):
"""Average wall-clock latency in seconds per LM call over this run.
Computed as ``elapsed_s / calls``. Because ``elapsed_s`` accumulates each
call's own duration, this reports the mean per-call latency regardless of
how many calls ran concurrently -- unlike `Throughput`, which divides by
the phase's wall-clock span and so does reflect concurrency. The two
coincide (latency = 1 / throughput) only when calls run serially.
Example:
```python
program.compile(
metrics=[
synalinks.metrics.AvgLatency(),
],
)
```
"""
def __init__(self, name="avg_latency"):
super().__init__(name=name)
def result(self):
calls = self._delta("calls")
if calls <= 0:
return 0.0
return self._delta("elapsed_s") / calls
|