annotate#
- ray.train.annotate(message: str, severity: Literal['info', 'warning', 'error'] = 'info', rank_zero_only: bool = True, **fields: Any) None#
Emit a custom annotation that Grafana can visualize.
Use this to mark a moment of interest on the same timeline as your training metrics, such as an evaluation completing, a learning-rate change, or a phase transition. Annotations are off by default, so this does nothing unless the cluster operator sets
RAY_ANNOTATIONS_ENABLED=1and ships the annotation log lines to Loki. See Overlay event annotations on the dashboards.You control what the dashboard tooltip shows. Grafana shows the
messageas the annotation text, and shows any**fieldstogether as a single JSON tag. All custom annotations share one dashboard layer, because Ray emits them under a fixed internal event name, andseveritycolors them.Example
>>> import ray.train >>> def train_func(config): ... for epoch in range(config["num_epochs"]): ... # Do training... ... ray.train.annotate( ... message=f"Finished epoch {epoch}", ... epoch=epoch, ... loss=loss, ... )
- Parameters:
message (str) – Human-readable description of the event. Grafana shows it as the annotation text and tooltip. Ray emits it as the
messagefield.severity (Literal['info', 'warning', 'error']) – One of
"info","warning"or"error". Defaults to"info". It selects which of the Train dashboard’s custom annotation layers the event shows under, and so its color.rank_zero_only (bool) – If
True, the default, only the rank 0 worker emits the annotation, producing a single point on the dashboard. IfFalse, every worker emits its own annotation and carriesray_train_worker_world_rankfor LogQL to distinguish ranks.**fields (Any) – Arbitrary additional key-value pairs to include in the emitted JSON payload, such as
epoch=3orloss=0.1. Ray serializes them together into a single JSON string under thecustom_fieldskey, so the dashboard annotation displays them as one JSON tag. Becausecustom_fieldsparses as a single string label, LogQL can’t filter on individual keys within it. Filter onseverity, or on the run and rank tags, instead.
DeveloperAPI: This API may change across minor Ray releases.