rhscope.integrations.sinks¶
Metric sinks.
A Sink is a minimal protocol for writing {name: scalar} metrics
during training. The integrations module uses sinks to record monitor scores
alongside TRL’s built-in logging.
Concrete sinks:
StdoutSink- log-level-controlled stdout printing.
TensorBoardSink-torch.utils.tensorboard.SummaryWriter.
WandbSink- W&B client, optional extra.
Users typically construct sinks via make_sink() which takes a string
name ("stdout" / "tensorboard" / "wandb" / "none") and
returns an appropriate instance.
- class rhscope.integrations.sinks.Sink(*args, **kwargs)[source]¶
Bases:
ProtocolMinimal metric-sink protocol.
Implementations must accept any dict of string keys to numeric values and a monotonically-increasing step counter.
closeis called at the end of training so sinks can flush and release handles.
- class rhscope.integrations.sinks.NullSink[source]¶
Bases:
objectNo-op sink. Useful as a default when logging is disabled.
- class rhscope.integrations.sinks.StdoutSink(*, prefix='rhscope-monitor')[source]¶
Bases:
objectSink that formats metrics as a single-line stdout record per call.
Formatted as
[step=N] key1=val1 key2=val2 ...so the output remains greppable without any JSON framing.- Parameters:
prefix (str)
- class rhscope.integrations.sinks.TensorBoardSink(log_dir, *, comment='')[source]¶
Bases:
objectSink backed by
torch.utils.tensorboard.SummaryWriter.- Parameters:
The
tensorboardoptional extra provides the package used for live viewing (tensorboard); writing itself only depends on torch.
- class rhscope.integrations.sinks.WandbSink[source]¶
Bases:
objectSink backed by the Weights & Biases client.
Uses an existing W&B run if one is active (
wandb.runis notNone) so the trainer and the monitor write to the same run. If no run is active, this sink does not start one on its own - callwandb.init(...)yourself first.
- rhscope.integrations.sinks.make_sink(name, *, log_dir=None)[source]¶
Construct a sink by name.
- Parameters:
- Returns:
A
Sinkinstance.- Raises:
ValueError – If
nameis unknown, or iflog_diris required but not supplied.- Return type: