Observability#
Megatron-LM is instrumented with OpenTelemetry via the nemo-lens library, emitting traces at training-framework boundaries and metrics for loss, throughput, and gradient norm.
Telemetry exports to any OTLP-compatible backend (Jaeger, Grafana Tempo, W&B Weave, Honeycomb, Datadog, …).
What’s in this section#
Scope#
This documentation covers Megatron-specific usage: CLI flags, environment variables, span names, metric names, and the pipeline-parallel trace correlation integration.
For general concepts — span groups, instrumentation primitives, configuration model, custom exporters, resource detection — see the lens documentation. This section links to lens docs when relevant rather than duplicating content.
Quick start#
export MEGATRON_OTEL_ENABLED=1
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
export MEGATRON_OTEL_SPAN_GROUPS=default # coarse-grained; safe for production
torchrun --nproc_per_node=8 pretrain_gpt.py ...
With default span groups, Megatron emits a handful of coarse spans per iteration and a steady stream of training metrics. Switch to per_step for profiling individual steps, or all for fine-grained debugging.
What gets instrumented#
Subsystem |
File |
Spans |
|---|---|---|
Training loop |
|
|
Pipeline schedules |
|
|
P2P communication |
|
|
Gradient sync (DDP) |
|
|
Checkpointing |
|
|
Model init |
|
|
Evaluation |
|
|
Each span is tagged with a span group that controls whether it’s emitted at runtime. See Span Groups.
What gets exported#
Traces: Jaeger / Tempo / Honeycomb / etc. via OTLP.
Metrics: Prometheus via the OTel Collector, or direct OTLP to Grafana Mimir / Datadog / etc.
Logs (optional): via the OTel log bridge when
MEGATRON_OTEL_LOGS_ENABLED=1— correlatesloggingrecords with the active span’s trace ID.
By default, only one rank exports (the last rank). For multi-rank telemetry, see Configuration — Rank strategy.