Priority: High
Edge per-layer inference times get an exponential moving average applied twice, and the first application ignores the configured offloading_algo.ema_alpha.
What happens
model_manager.py:212-216 smooths self.inference_times with a hard-coded alpha = 0.2:
if layer_key in self.inference_times:
alpha = 0.2 # Weight for new measurement
self.inference_times[layer_key] = (
alpha * elapsed_time + (1 - alpha) * self.inference_times[layer_key]
)
- That dict is
device_profiles[device_id]["edge_inference_times"] — it is passed by reference (edge_initialization.py:140,152 → model_manager.py:285), as the comment at model_manager.py:231 notes.
request_handler.py then applies the EMA again to the same dict, this time with the configured alpha, using the times returned by Edge.run_inference.
Why it matters
Suggested fix
Decide which layer owns the smoothing. Most likely model_manager should report the raw elapsed_time and leave all EMA work to the state manager (DeviceStateManager.update_edge_times), which already reads the configured alpha.
Files
src/server/models/model_manager.py:211-218
src/server/edge/edge_initialization.py:140,152
src/server/communication/device_state.py (update_edge_times)
Found while refactoring RequestHandler for #11 / #45. The refactor preserves the current behaviour exactly; this is a pre-existing bug.
Priority: High
Edge per-layer inference times get an exponential moving average applied twice, and the first application ignores the configured
offloading_algo.ema_alpha.What happens
model_manager.py:212-216smoothsself.inference_timeswith a hard-codedalpha = 0.2:device_profiles[device_id]["edge_inference_times"]— it is passed by reference (edge_initialization.py:140,152→model_manager.py:285), as the comment atmodel_manager.py:231notes.request_handler.pythen applies the EMA again to the same dict, this time with the configured alpha, using the times returned byEdge.run_inference.Why it matters
0.2. Changingema_alphainsettings.yamlonly affects the second application.Suggested fix
Decide which layer owns the smoothing. Most likely
model_managershould report the rawelapsed_timeand leave all EMA work to the state manager (DeviceStateManager.update_edge_times), which already reads the configured alpha.Files
src/server/models/model_manager.py:211-218src/server/edge/edge_initialization.py:140,152src/server/communication/device_state.py(update_edge_times)Found while refactoring
RequestHandlerfor #11 / #45. The refactor preserves the current behaviour exactly; this is a pre-existing bug.