Tinkex.MetricsReduction (Tinkex v0.3.4)

View Source

Metric reduction for chunked forward/backward results.

Mirrors Python's chunked_fwdbwd_helpers._metrics_reduction helper by reducing metrics based on the suffix that comes after the last : in the metric name. Only metrics present in the first chunk are considered, and keys missing from later chunks are ignored (they are not treated as zero).

Summary

Functions

Reduce metrics from chunked forward/backward results.

Types

metrics()

@type metrics() :: %{required(String.t()) => number()}

Functions

reduce(results)

Reduce metrics from chunked forward/backward results.

  • Weights use the number of loss_fn_outputs for each chunk.
  • Unknown suffixes fall back to the weighted mean reducer.
  • :unique metrics retain every value by emitting suffixed keys (key_2, key_3, ...).
  • Weighted reducers return 0.0 when the total weight is 0.
  • :hash_unordered returns an integer hash (not a float) for order-insensitive identity checks. Suitable for verifying batch composition across distributed chunks.