Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions torchtitan/components/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import torch
from torch.utils.tensorboard import SummaryWriter
from torchtitan.components import fs
from torchtitan.components.optimizer import OptimizersContainer
from torchtitan.config import Configurable
from torchtitan.distributed import ParallelDims
Expand Down Expand Up @@ -187,6 +188,16 @@ def __init__(
raise ValueError("REPORTERV2_TRAINING_ID must be set to use ReporterV2 logging")
from reporterv2 import ReporterV2

if any(
fs.exists(f"{host.rstrip('/')}/{prefix}/{training_id}")
for prefix in ("runs", "checkpoint", "runs_timestamps")
):
raise FileExistsError(
f"ReporterV2 run {training_id!r} already exists. "
f"checkpoint.initial_load_path={host.rstrip('/')}/checkpoint/{training_id}/<step> "
"checkpoint.initial_load_model_only=false. To resume a run."
)

reporter_config = dict(config_dict or {})
metrics_config = reporter_config.get("metrics", {})
if not isinstance(metrics_config, dict):
Expand Down Expand Up @@ -498,6 +509,8 @@ def _build_metric_logger(
try:
reporterv2_logger = ReporterV2Logger(config_dict=config_dict, tag=tag)
logger_container.add_logger(reporterv2_logger)
except FileExistsError:
raise
except Exception as e:
if "No module named 'reporterv2'" in str(e):
logger.error(
Expand Down
Loading