feat(train): add list_hyperparameters() for pre-trainer HP discovery - #6149
Conversation
bf0f6de to
f9d8d7d
Compare
Add a public utility function that returns available hyperparameters
for a model/technique/training_type combination without requiring a
fully constructed trainer object.
This enables tools and scripts to discover valid hyperparameter names,
defaults, and ranges before setting up training infrastructure (model
package groups, datasets, roles, etc.).
Motivation: COE 398545 identified that hardcoded HP names in downstream
consumers break when recipe templates rename parameters. Dynamic
discovery at code-generation time prevents this class of failure.
Usage:
from sagemaker.train import list_hyperparameters
hp = list_hyperparameters('model-name', 'SFT', 'LORA')
hp.get_info() # display all params
hp.get_info('learning_rate') # display one param
Switch to the same model used by ~80% of existing integ tests to avoid deprecation risk. Llama 3.2 1B is the most battle-tested model in the repo's test infrastructure.
5a52e23 to
6eac70c
Compare
|
Claude finished @joshuatowner's task in 1m 51s —— View job Review:
|
Issue #, if available:
Related to Skills AI: "Update Skills to use dynamic HP discovery instead of hardcoded parameter names"
Description of changes:
Adds
list_hyperparameters()tosagemaker.train-- a public utility function that returns aFineTuningOptionsobject for a given model/technique/training_type without requiring a fully constructed trainer.Problem: Today, discovering available hyperparameters requires constructing a full trainer object (
SFTTrainer,DPOTrainer, etc.), which in turn requires a model package group, dataset ARN, IAM role, and S3 output path. Tools and scripts that generate training code need to know valid HP names before those resources exist.Solution:
list_hyperparameters()wraps the existing internal recipe resolution logic and returns the sameFineTuningOptionsobject thattrainer.hyperparametersprovides, but without the trainer construction prerequisites.Usage:
Changes:
sagemaker-train/src/sagemaker/train/common_utils/finetune_utils.py: Addedlist_hyperparameters()functionsagemaker-train/src/sagemaker/train/__init__.py: Added lazy import forlist_hyperparameterssagemaker-train/tests/unit/train/common_utils/test_finetune_utils.py: Added 2 unit tests (basic usage, enum acceptance)Testing:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.