Skip to content

Edge inference times are EMA-smoothed twice, with a hard-coded alpha=0.2 #72

Description

@ff225

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

  1. 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]
        )
  2. That dict is device_profiles[device_id]["edge_inference_times"] — it is passed by reference (edge_initialization.py:140,152model_manager.py:285), as the comment at model_manager.py:231 notes.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions