Skip to content

feat(train): add list_hyperparameters() for pre-trainer HP discovery - #6149

Open
joshuatowner wants to merge 3 commits into
aws:masterfrom
joshuatowner:list-hyperparameters
Open

feat(train): add list_hyperparameters() for pre-trainer HP discovery#6149
joshuatowner wants to merge 3 commits into
aws:masterfrom
joshuatowner:list-hyperparameters

Conversation

@joshuatowner

Copy link
Copy Markdown
Contributor

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() to sagemaker.train -- a public utility function that returns a FineTuningOptions object 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 same FineTuningOptions object that trainer.hyperparameters provides, but without the trainer construction prerequisites.

Usage:

from sagemaker.train import list_hyperparameters

hp = list_hyperparameters("huggingface-llm-qwen2-5-7b-instruct", "SFT", "LORA")
hp.get_info()  # display all params with defaults and ranges
hp.get_info("learning_rate")  # display info for a single param

Changes:

  • sagemaker-train/src/sagemaker/train/common_utils/finetune_utils.py: Added list_hyperparameters() function
  • sagemaker-train/src/sagemaker/train/__init__.py: Added lazy import for list_hyperparameters
  • sagemaker-train/tests/unit/train/common_utils/test_finetune_utils.py: Added 2 unit tests (basic usage, enum acceptance)

Testing:

  • Unit tests with mocked hub content and S3 responses
  • Manual validation against live SageMakerPublicHub in us-west-2 and us-east-1 across 6 models (Qwen 2.5, Qwen 3, Llama 3.1, DeepSeek R1 Distill) and 4 techniques (SFT, DPO, RLVR, RLAIF). 15/16 cases pass; one failure is an S3 access gate on a subscription model (not our code).

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Joshua Towner added 2 commits August 3, 2026 20:21
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants