lens.distributed
Cross-rank trace context broadcast and linked spans.
Provides helpers for sharing a trace_id across all ranks (so that distributed training appears as a single trace) and for creating linked spans that reference remote contexts.
Module Contents
Functions
API
Broadcast W3C trace context from src_rank to all other ranks.
Must be called after torch.distributed.init_process_group().
Returns a carrier dict with the broadcasted trace context.
Parameters:
Current process rank.
Rank that holds the source context.
Returns: dict | None
A carrier dict with the broadcasted trace context, or None if
Create a span with a link to a remote span context.
Use this for cross-rank or cross-service span correlation where parent-child relationships don’t make sense (e.g., pipeline parallel stages).
Parameters:
OTel tracer.
Span name.
An OTel Context from extract_context().
A W3C carrier dict (alternative to remote_context).
Span attributes.
Returns: trace.Span
The created Span (already started, caller must end it).