flip.nvflare.metrics

Functions

send_metrics_value() → None)

Sends a metric value to the Central Hub.

handle_metrics_event() → None)

Use on the server to handle metrics data events raised by clients.

Module Contents

flip.nvflare.metrics.send_metrics_value(label: str, value: float, fl_ctx: nvflare.apis.fl_context.FLContext, x_value: float | None = None, x_label: str | None = None, flip: flip.FLIP = FLIP()) None

Sends a metric value to the Central Hub.

The metric is always recorded against the FL global round it is reported in (provenance). Where it is plotted is the (x_label, x_value) pair: ‘x_value’ is the x-coordinate (e.g. an epoch counter, a step, any float) and ‘x_label’ names the x-axis (e.g. “epoch”). Both default to the FL global round / the “Global Rounds” axis when absent. A plot’s identity is (label, x_label), so the same metric logged under different x-labels renders as separate plots (see https://github.com/londonaicentre/FLIP/issues/148).

Parameters:
  • label – The label of the metric.

  • value – The value of the metric.

  • fl_ctx – The federated learning context.

  • x_value – The x-coordinate the metric is plotted at (default: None -> the FL global round).

  • x_label – The label naming the x-axis (default: None -> “Global Rounds”).

  • flip – FLIP instance used for logging (default: FLIP()).

flip.nvflare.metrics.handle_metrics_event(event_data: nvflare.apis.shareable.Shareable, global_round: int, model_id: str, flip: flip.FLIP = FLIP()) None

Use on the server to handle metrics data events raised by clients.

Parameters:
  • event_data – The event data containing the metrics.

  • global_round – The global round number (aka _current_round in scatter_and_gather scripts).

  • model_id – The ID of the model.

  • flip – FLIP instance used to forward metrics to the Central Hub (default: FLIP()).