Uh oh!
There was an error while loading. Please reload this page.
feat(train): validate raw base model name exists in SageMaker Hub - #6227
feat(train): validate raw base model name exists in SageMaker Hub#6227jam-jee wants to merge 2 commits into
Conversation
When a user passes a raw base model name to a V3 trainer (SFT/DPO/RLVR/ RLAIF/CPT/MTRL), model resolution now confirms the model actually exists in the SageMaker Hub before the job proceeds. A bogus or misspelled name fails fast with a clear error that points at list_supported_models(), instead of a later, more opaque failure during recipe resolution. The check runs in _resolve_model_and_name, the shared resolve path the trainer interfaces already use, so it also covers the base_model_name supplied with an S3 checkpoint. It issues a single DescribeHubContent against the active hub. Only a definitive not-found raises; transient or permission errors are logged and skipped so a Hub hiccup never blocks an otherwise-valid training job. Adds unit tests for the classifier and the resolve integration, plus an autouse conftest that no-ops the Hub check for trainer construction tests (which use placeholder model names against mock sessions). --- X-AI-Prompt: Add Hub-availability validation when a raw base model name is passed to trainer resolve_model path X-AI-Tool: Kiro
Validates against the live SageMaker Hub (prod us-west-2) what the mocked unit tests cannot: that a real DescribeHubContent miss surfaces as an error the not-found classifier recognizes, so the check fail-closes with a clear error instead of fail-opening on an unexpected error shape. Two cases: a real FineTuning-tagged model (picked via an independent hub scan, skipped if none) passes validation and resolves; a bogus name raises the "not available in SageMaker Hub" ValueError, both directly and through the shared resolve path. --- X-AI-Prompt: Add an integration test validating the Hub availability check against the live SageMaker Hub X-AI-Tool: Kiro
Claude finished @jam-jee's task in 1m 49s —— View job PR Review: validate raw base model name exists in SageMaker Hub
Overall this is a clean, well-scoped change. The fail-open-on-ambiguity / fail-closed-on-definitive-miss design is the right call, the exception classifier is reasonable, and test coverage (unit + a targeted integ test for the real error shape) is solid. A few things worth surfacing — none are blockers. 1. Behavioral change: trainer construction now makes a network call (worth documenting)
Two implications:
2. Nova / open-weights parity — looks safe, please confirmThe check applies to all raw names, including Nova, whereas 3. Message-text classification is a heuristic — acceptable because it fails open
4. Minor
No correctness bugs found. Nice work on the fail-open design and the integ test covering what the mocks can't.
|
Problem
When a user passes a raw base model name (a plain string, not a model-package ARN or
ModelPackage) to a V3 trainer, model resolution accepts the name without confirming the model actually exists in the SageMaker Hub. A misspelled or unsupported name is only caught later, during recipe resolution, where the failure is more opaque and harder to map back to the model argument.Why it matters
Fine-tuning jobs are long-lived and expensive to set up. A fast, clear "this model isn't in the Hub" at construction time saves users from a confusing downstream error and points them at the right next step (
list_supported_models()), rather than leaving them to decode a recipe-lookup failure.Fix (symptom → root cause → change)
_resolve_model_and_namenormalizes the name and validates region, but never checks Hub availability for the raw-string case._resolve_model_and_name, call a new_validate_model_in_hub(...)that issues a singleDescribeHubContentagainst the active hub (get_sagemaker_hub_name()) via the existing_get_hub_content_metadatahelper.ValueError; transient or permission errors (Hub outage, missingDescribeHubContentpermission, throttling) are logged and skipped, so a Hub hiccup never blocks an otherwise-valid job (fail-open on ambiguity, fail-closed only on a real miss)._is_hub_content_not_found(exc)classifier distinguishes the two cases (botocoreResourceNotFoundcode, sagemaker-core exception class name, or message text).Because the check lives in the shared
_resolve_model_and_namepath used by the trainer interfaces (SFT/DPO/RLVR/RLAIF/CPT/MTRL), it also covers thebase_model_namesupplied alongside an S3 checkpoint, which routes through the same resolver.Model-package ARNs and
ModelPackageobjects are unchanged: the Hub check only applies to raw base model names.Tests
tests/unit/train/common_utils/test_finetune_utils.py:_is_hub_content_not_foundclassification (error code, message text, transient/permission errors that must NOT be treated as not-found)._validate_model_in_hub: no-session skip, found passes, not-found raises, transient error does not block._resolve_model_and_nameintegration: raises for a missing model, resolves normally for a present model.tests/unit/train/conftest.pywith an autouse fixture that no-ops the Hub check for trainer construction tests (they build trainers with placeholder model names against mock sessions and must not reach the network). The fixture explicitly excludes thecommon_utils/directory so the dedicated tests above exercise the real function.Manual verification
N/A — unit coverage is sufficient; the new behavior is a single API call guarded by exception classification, fully exercised by mocked unit tests. Full
tests/unit/trainsuite: 2403 passed, 19 skipped (the one remaining failure,TestWaitForMlflowAppReady::test_polls_until_ready, is pre-existing onmasterand unrelated to this change).Screenshots
N/A — no user-visible UI change.