Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions sagemaker-serve/src/sagemaker/serve/bedrock_model_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def deploy(
self._get_bedrock_client(), model_arn
)
if existing_deployment:
logger.warning(
logger.info(
"Reusing existing custom model %s and deployment %s "
"(matched model-source tag). No new resources were created. "
"Pass reuse_resources=False to force new resources.",
Expand All @@ -375,7 +375,7 @@ def deploy(
"modelArn": model_arn,
"customModelDeploymentArn": existing_deployment,
}
logger.warning(
logger.info(
"Reusing existing custom model %s (matched model-source tag); "
"creating a new deployment on it. Pass reuse_resources=False to "
"force a new model.",
Expand Down
4 changes: 2 additions & 2 deletions sagemaker-serve/src/sagemaker/serve/model_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4061,7 +4061,7 @@ def build(
reusable_endpoint = self._find_reusable_endpoint()
if reusable_endpoint:
self._reused_endpoint_name = reusable_endpoint
logger.warning(
logger.info(
"Reusing existing Model %r (matched model-source tag). "
"No new Model will be created. Pass reuse_resources=False "
"to force a new Model.",
Expand Down Expand Up @@ -5528,7 +5528,7 @@ def deploy(
endpoint_name,
reusable_endpoint,
)
logger.warning(
logger.info(
"Reusing existing endpoint %r (matched model-source tag and "
"deployment configuration). No new resources were created. "
"Pass reuse_resources=False to force a new endpoint.",
Expand Down
50 changes: 36 additions & 14 deletions sagemaker-train/src/sagemaker/train/base_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,30 +399,40 @@ def show_metrics(
ValueError: If no training job has been run yet, no logs/metrics
are found, or MLflow is not configured for OSS models.
"""
# Validate that we have a training job to get metrics from
if not hasattr(self, '_latest_training_job') or self._latest_training_job is None:
raise ValueError(
"No training job found. Call .train() first, then call .show_metrics() "
"to view training metrics."
# Resolve the job reference. Prefer _latest_training_job (CreateTrainingJob),
# fall back to _latest_job (generic CreateJob API used by MTRL).
resolved_job = getattr(self, '_latest_training_job', None)
if resolved_job is None:
latest_job = getattr(self, '_latest_job', None)
if latest_job is None:
raise ValueError(
"No training job found. Call .train() first, then call .show_metrics() "
"to view training metrics. If training has already completed, set the "
"job name directly via trainer._latest_training_job = '<job-name>' or "
"trainer._latest_job = '<job-name>'."
)
resolved_job = (
latest_job.job_name if hasattr(latest_job, 'job_name') else str(latest_job)
)

# Route based on model type
model_name = getattr(self, '_model_name', None)
is_nova = _is_nova_model(model_name) if model_name else False

if is_nova:
return self._show_metrics_cloudwatch(metrics, starting_step, ending_step, start_time, end_time)
return self._show_metrics_cloudwatch(resolved_job, metrics, starting_step, ending_step, start_time, end_time)
else:
return self._show_metrics_mlflow(metrics, starting_step, ending_step)
return self._show_metrics_mlflow(resolved_job, metrics, starting_step, ending_step)

def _show_metrics_mlflow(
self,
resolved_job,
metrics: Optional[List[str]] = None,
starting_step: Optional[int] = None,
ending_step: Optional[int] = None,
) -> None:
"""Pull and plot training metrics from MLflow for non-Nova models."""
training_job = self._latest_training_job
training_job = resolved_job

# Resolve the TrainingJob object if it's a string
if isinstance(training_job, str):
Expand Down Expand Up @@ -456,6 +466,7 @@ def _show_metrics_mlflow(

def _show_metrics_cloudwatch(
self,
resolved_job,
metrics: Optional[List[str]] = None,
starting_step: Optional[int] = None,
ending_step: Optional[int] = None,
Expand All @@ -464,7 +475,7 @@ def _show_metrics_cloudwatch(
) -> Any:
"""Parse and plot training metrics from CloudWatch logs (Nova models)."""

training_job = self._latest_training_job
training_job = resolved_job
if hasattr(training_job, 'training_job_name'):
job_id = training_job.training_job_name
elif isinstance(training_job, str):
Expand Down Expand Up @@ -631,10 +642,21 @@ def stream_logs(self, poll: int = 5, start_time: Optional[Any] = None) -> None:
Raises:
ValueError: If no training job has been run yet.
"""
if not hasattr(self, '_latest_training_job') or self._latest_training_job is None:
raise ValueError(
"No training job found. Call .train(wait=False) first, "
"then call .stream_logs() to stream logs in real-time."
# Resolve the job reference. Prefer _latest_training_job (CreateTrainingJob),
# fall back to _latest_job (generic CreateJob API used by MTRL).
resolved_job = getattr(self, '_latest_training_job', None)
if resolved_job is None:
latest_job = getattr(self, '_latest_job', None)
if latest_job is None:
raise ValueError(
"No training job found. Call .train(wait=False) first, "
"then call .stream_logs() to stream logs in real-time. "
"If training has already completed, set the job name directly via "
"trainer._latest_training_job = '<job-name>' or "
"trainer._latest_job = '<job-name>'."
)
resolved_job = (
latest_job.job_name if hasattr(latest_job, 'job_name') else str(latest_job)
)

# Resolve start_time for SMHP jobs
Expand All @@ -645,7 +667,7 @@ def stream_logs(self, poll: int = 5, start_time: Optional[Any] = None) -> None:
else:
start_time_ms = int(start_time)

training_job = self._latest_training_job
training_job = resolved_job
compute = getattr(self, 'compute', None)

if isinstance(compute, HyperPodCompute):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@
"SFT": {"training_loss": TRAINING_LOSS_REGEX, "lr": LEARNING_RATE_REGEX},
"CPT": {"training_loss": TRAINING_LOSS_REGEX, "lr": LEARNING_RATE_REGEX},
"RLVR": {"reward_score": SMTJ_RLVR_REWARD_SCORE_REGEX},
"MTRL": {"reward_score": SMTJ_RLVR_REWARD_SCORE_REGEX},
},
"smhp": {
"SFT": {"training_loss": TRAINING_LOSS_REGEX, "lr": LEARNING_RATE_REGEX},
"CPT": {"training_loss": TRAINING_LOSS_REGEX, "lr": LEARNING_RATE_REGEX},
"RLVR": {"reward_score": SMHP_RLVR_REWARD_SCORE_REGEX},
"MTRL": {"reward_score": SMHP_RLVR_REWARD_SCORE_REGEX},
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def is_multimodal_data(dataset: Union[str, "DataSet"]) -> bool:
True if multimodal fields detected, False otherwise
"""

logger.info(f"Auto-detecting whether dataset is multimodal: {dataset}")
logger.debug(f"Auto-detecting whether dataset is multimodal: {dataset}")

if isinstance(dataset, DataSet):
data_s3_path = dataset.source
Expand Down
1 change: 0 additions & 1 deletion sagemaker-train/src/sagemaker/train/cpt_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
from sagemaker.core.telemetry.constants import Feature

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)


class CPTTrainer(BaseTrainer):
Expand Down
1 change: 0 additions & 1 deletion sagemaker-train/src/sagemaker/train/dpo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from sagemaker.train.constants import get_sagemaker_hub_name

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)


class DPOTrainer(BaseTrainer):
Expand Down
2 changes: 2 additions & 0 deletions sagemaker-train/src/sagemaker/train/multi_turn_rl_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ class MultiTurnRLTrainer(BaseTrainer):
and 'job_name_prefix'. If not specified, no notifications are sent.
"""

_customization_technique = "MTRL"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the use of this variable?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for consistency. All the other trainers have it and will be called in BaseTrainer utils


def __init__(
self,
model: Union[str, ModelPackage],
Expand Down
1 change: 0 additions & 1 deletion sagemaker-train/src/sagemaker/train/sft_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
from sagemaker.core.training.constants import TrainingPlatform

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)


class SFTTrainer(BaseTrainer):
Expand Down