evaluator_model was checked against a hardcoded _ALLOWED_EVALUATOR_MO… - #6217
evaluator_model was checked against a hardcoded _ALLOWED_EVALUATOR_MO…#6217mohamedzeidan2021 wants to merge 2 commits into
Conversation
…DELS dict (model -> regions) in sagemaker/train/constants.py. That list is triplicated across clients and goes stale: when a judge model reaches end of life it still passes client-side validation, so the eval job spins up and only fails deep inside the in-container Bedrock CreateEvaluationJob call, wasting compute and surfacing a poor error. Replace it with two-step validation against authoritative sources: - Construction: fetch the service-maintained supported-judge-models list at s3://jumpstart-cache-prod-<region>/fmhMetadata/supported-llmaj-judge-models.json and fail fast if evaluator_model is not a supported judge model. - evaluate(): call bedrock:GetFoundationModel and fail fast if the model is unavailable in the region or past its endOfLifeTime. The lookup is gated on the caller's IAM permission via a new non-raising caller_can_perform() helper that mirrors the existing SimulatePrincipalPolicy caller-check pattern (verify_evaluation_caller_permissions). Both steps degrade gracefully instead of blocking: if a source can't be read (missing bedrock:GetFoundationModel permission, unreadable list, or a transient error) the SDK logs an actionable warning with a link to the supported models and continues. - Remove _ALLOWED_EVALUATOR_MODELS from sagemaker/train/constants.py - Add caller_can_perform() to sagemaker/core/helper/iam_role_resolver.py - Add unit tests for both validation steps and caller_can_perform
|
Claude finished @mohamedzeidan2021's task in 3m 13s —— View job Review: replace hardcoded
|
|
Claude finished @mohamedzeidan2021's task in 3m 28s —— View job Review: replace hardcoded
|
…DELS
LLMAsJudgeEvaluator.evaluator_model was validated against a hardcoded _ALLOWED_EVALUATOR_MODELS dict (model → regions) in sagemaker/train/constants.py. This PR replaces that with two-step validation against authoritative, service-maintained sources, and removes the dict.
Problem
This is real today: the supported list still advertises claude-3-5-sonnet-20240620, claude-3-5-haiku, claude-3-5-sonnet-v2, and claude-3-7-sonnet, all of which return ResourceNotFoundException from Bedrock in us-west-2.
Solution — two-step validation
Step 1 — construction (is it a judge-capable model?): fetch the service-maintained list at s3://jumpstart-cache-prod-/fmhMetadata/supported-llmaj-judge-models.json (source of truth for supported judge models) and fail fast if evaluator_model isn't in it.
Step 2 — evaluate() (is it still in service?): the supported list is a superset that can still include end-of-life models, so we call bedrock:GetFoundationModel and fail fast if the model is unavailable in the region or past its endOfLifeTime. The lookup is gated on the caller's IAM permission via a new non-raising caller_can_perform() helper that reuses the existing iam:SimulatePrincipalPolicy caller-check pattern (verify_evaluation_caller_permissions).
Graceful degradation everywhere: we never block on "can't tell." If a source can't be read (missing permission, unreadable list, transient error), the SDK logs an actionable warning with a link to the supported models and continues.
User-facing messaging
Fail-fast errors (block construction / submission):
▎ evaluator_model '' is not a supported LLM-as-Judge model in region ''. Choose one of the supported judge models. See https://docs.aws.amazon.com/bedrock/latest/userguide/evaluation-judge.html#evaluation-judge-supported
▎ evaluator_model '' has reached end of life in region '' (end-of-life ) and can no longer be used as a judge. Choose a judge model that is in service. See https://docs.aws.amazon.com/bedrock/latest/userguide/evaluation-judge.html#evaluation-judge-supported
▎ evaluator_model '' is not available in region ''. It may be unsupported in this region or have reached end of life. Choose a judge model that is in service in this region. See https://docs.aws.amazon.com/bedrock/latest/userguide/evaluation-judge.html#evaluation-judge-supported
Warnings (degrade, do not block):
▎ Your IAM role does not include the bedrock:GetFoundationModel permission, so the SDK can't check whether the evaluator model '' is still in service or has reached end of life. The evaluation will still run, but it may fail if this model has been retired. Add bedrock:GetFoundationModel to your role to enable this check. See the list of supported judge models: https://docs.aws.amazon.com/bedrock/latest/userguide/evaluation-judge.html#evaluation-judge-supported
▎ The SDK couldn't confirm your IAM role includes the bedrock:GetFoundationModel permission, so it can't check whether the evaluator model '' is still in service or has reached end of life. The evaluation will still run, but it may fail if this model has been retired. See the list of supported judge models: https://docs.aws.amazon.com/bedrock/latest/userguide/evaluation-judge.html#evaluation-judge-supported
▎ The SDK couldn't verify whether the evaluator model '' is still in service right now (a temporary error occurred). The evaluation will still run, but it may fail if this model has been retired. See the list of supported judge models: https://docs.aws.amazon.com/bedrock/latest/userguide/evaluation-judge.html#evaluation-judge-supported
▎ The SDK couldn't retrieve the list of supported judge models, so it can't confirm '' is a valid judge model. The evaluation will still run, but it may fail if the model isn't supported. See the list of supported judge models: https://docs.aws.amazon.com/bedrock/latest/userguide/evaluation-judge.html#evaluation-judge-supported
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.