Monitoring and logging#
This page summarizes how Primus configures application logging, experiment tracking (Weights & Biases, TensorBoard, MLflow), training metrics, profilers, ROCm memory probes, and how to capture a reproducible configuration snapshot.
1. Primus logging system#
Primus uses loguru for structured logging. Initialization wires file sinks (per log level) and a stderr sink, binds experiment and distributed context (team, user, exp, module_name, node_ip, rank, world_size), and installs an intercept handler so legacy logging output from frameworks such as Megatron is forwarded to loguru with consistent formatting.
Rank-aware behavior
Worker processes write under
{exp_root}/logs/{module_name}/rank-{rank}/with separate rotated files fordebug,info,warning, anderror(subject tofile_sink_level).The launcher master process can use
logs/master/when the master logger is configured withis_head=True.
Levels from module configuration (primus/configs/modules/module_base.yaml)
Parameter |
Default |
Role |
|---|---|---|
|
|
If set, overrides both file and stderr sink levels. |
|
|
Minimum level for file sinks when |
|
|
Minimum level for stderr when |
init_worker_logger in primus/core/runtime/logging.py reads sink_level, file_sink_level, and stderr_sink_level from the merged module config. The Megatron trainer maps stderr_sink_level to Megatron’s numeric logging_level (the logging_level field in trainer_base.yaml is deprecated; this mapping supersedes it)…
Shell / runner environment (see docs/03-configuration-reference/environment-variables.md)
Variable |
Purpose |
|---|---|
|
Runner verbosity: |
|
|
|
|
CLI
primus-cli --debugsetsPRIMUS_LOG_LEVEL=DEBUGso launcher and shell logging are verbose (seedocs/02-user-guide/cli-reference.md).
2. Weights & Biases#
Megatron#
Configuration files: primus/configs/modules/megatron/trainer_base.yaml and primus_megatron_module.yaml.
Defaults in primus_megatron_module.yaml disable Weights & Biases; trainer fields in trainer_base.yaml supply names and paths when enabled.
Parameter |
Default (module / trainer) |
Description |
|---|---|---|
|
|
Master switch; when |
|
|
If unset when Weights & Biases is enabled, defaults to |
|
|
If unset, defaults to |
|
|
Optional WandB entity/team. |
|
|
Deprecated in favor of |
Environment
WANDB_API_KEYis required when Weights & Biases is enabled; Primus emits a warning if it is missing (primus/backends/megatron/patches/args/wandb_config_patches.py).
TorchTitan#
Configuration file: primus/configs/modules/torchtitan/pre_trainer.yaml.
Parameter |
Default |
Description |
|---|---|---|
|
|
Enables WandB in the TorchTitan metrics stack. |
When enabled, primus/backends/torchtitan/patches/wandb_patches.py can set WANDB_PROJECT and WANDB_RUN_NAME from Primus experiment metadata if unset. Use WANDB_API_KEY for authentication.
3. TensorBoard#
Megatron#
Module toggles
Configuration file: primus_megatron_module.yaml
Parameter |
Default |
Description |
|---|---|---|
|
|
When |
Trainer
Configuration file: trainer_base.yaml
Parameter |
Default |
Description |
|---|---|---|
|
|
Steps between TensorBoard writes. |
|
|
Event file queue size. |
|
|
Log timer stats. |
|
|
Log batch size. |
|
|
Log learning rate. |
|
|
Log validation perplexity. |
|
|
Log memory stats. |
|
|
Log world size. |
|
|
Log loss scale. |
|
|
Deprecated; Primus sets the directory under |
Note: Enabling Megatron profiling (profile: true) forces disable_tensorboard off in update_primus_config so TensorBoard is available for profile-related views.
TorchTitan#
Configuration file: pre_trainer.yaml.
Parameter |
Default |
Description |
|---|---|---|
|
|
Enables TensorBoard logging. |
|
|
Subfolder name (typically under the job dump directory in TorchTitan layouts). |
Launch TensorBoard locally
tensorboard --logdir <path-to-tensorboard-or-tb-folder>
Point <path> at the Megatron tensorboard directory under the experiment root, or at the TorchTitan metrics folder that contains the save_tb_folder subtree.
4. MLflow#
MLflow integration is Megatron-only in the paths described here.
Module
Configuration file: primus_megatron_module.yaml
Parameter |
Default |
Description |
|---|---|---|
|
|
When |
|
|
If unset when enabled, defaults to |
|
|
Passed to |
Startup behavior
Configuration file: primus/backends/megatron/training/global_vars.py
Logs training
argsas parameters.Logs filtered environment variables with an
env__prefix.Collects git metadata, sets MLflow source tags, and writes
system/git_metadata.jsonas a run artifact.
Environment (typical Databricks / hosted tracking)
Variable |
Role |
|---|---|
|
Checked by the Megatron trainer when MLflow is enabled; a warning is printed if unset. |
|
Authentication for Databricks-hosted tracking (see environment reference). |
|
Tracking server URI; optional depending on deployment. |
5. Training metrics#
Megatron#
Configuration file: trainer_base.yaml
Parameter |
Default |
Description |
|---|---|---|
|
|
Steps between standard training log lines. |
|
|
Log throughput metrics. |
|
|
Skip initial iterations when computing averages. |
|
|
Interval for resetting running averages. |
|
|
Log parameter norm. |
|
|
Log count of zero gradients. |
|
|
Progress-style logging. |
|
|
Timing log verbosity. |
|
|
Timing aggregation option. |
TorchTitan#
Configuration file: pre_trainer.yaml.
Parameter |
Default |
Description |
|---|---|---|
|
|
Metric logging frequency (steps). |
|
|
Disable colored console metrics. |
|
|
Save metrics from every rank vs. reduced ranks. |
6. Profiling#
Megatron#
Configuration files: trainer_base.yaml and primus_megatron_module.yaml
Parameter |
Source |
Default |
Description |
|---|---|---|---|
|
|
|
Enables Megatron profiling path; also forces TensorBoard on when |
|
|
|
Use PyTorch profiler integration. |
|
|
|
Ranks to profile. |
|
|
|
First step to profile. |
|
|
|
Last step to profile. |
|
|
|
Record memory history. |
|
|
|
Memory snapshot file name. |
|
|
|
Disable CPU activities in the profiler. |
|
|
|
Record tensor shapes. |
|
|
|
Capture Python stacks. |
|
|
|
Gzip profiler traces. |
TorchTitan#
Configuration file: pre_trainer.yaml.
Parameter |
Default |
Description |
|---|---|---|
|
|
Master profiling toggle. |
|
|
How often to capture traces. |
|
|
Enable memory snapshots. |
|
|
Output folder for snapshots. |
|
|
Folder for profiler traces. |
7. ROCm memory monitoring#
Configured in primus/configs/modules/megatron/primus_megatron_module.yaml and applied in the Megatron trainer when logging throughput.
Parameter |
Default |
Description |
|---|---|---|
|
|
When |
|
|
When |
Collection is evaluated where log_throughput drives the extended iteration log (see primus/backends/megatron/patches/training_log/print_rank_last_patches.py): enable log_throughput in trainer_base.yaml (or overrides) when you need ROCm memory lines in the training log.
8. Experiment snapshots#
On disk (every run)
Experiment root:
{workspace}/{work_group}/{user_name}/{exp_name}is created at config load time (PrimusConfig).Per-rank logs:
{exp_root}/logs/{module_name}/rank-{rank}/with rotated level-specific files.Checkpoints: Megatron uses
{exp_root}/checkpoints(trainer setssaveto this path).TensorBoard / WandB: Under
exp_rootas described above when those features are enabled.
MLflow (Megatron, when enabled): Parameters, environment snapshot, and git metadata artifact provide a structured record of the run configuration and repository state.
Resolved configuration
The launcher and parser accept --export_config, but the default core training path (primus/cli/subcommands/train.py into PrimusRuntime) does not currently write a resolved YAML file. Archive the submitted experiment YAML, any referenced presets, launcher config, and runtime logs with each run. Treat resolved-config export as a legacy or future capability unless your deployment has implemented it on the core runtime path.