Skip to content

fix: define LAMBDA_ARN_REGEX in finetune_utils to fix RLVRTrainer NameError#5988

Open
jam-jee wants to merge 1 commit into
aws:masterfrom
jam-jee:fix/rlvr-lambda-arn-regex-nameerror
Open

fix: define LAMBDA_ARN_REGEX in finetune_utils to fix RLVRTrainer NameError#5988
jam-jee wants to merge 1 commit into
aws:masterfrom
jam-jee:fix/rlvr-lambda-arn-regex-nameerror

Conversation

@jam-jee

@jam-jee jam-jee commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Issue

RLVRTrainer.train() crashes during reward-function verification with:

NameError: name 'LAMBDA_ARN_REGEX' is not defined
  File ".../sagemaker/train/rlvr_trainer.py", line 280, in _verify_reward_function
    elif isinstance(reward_function, str) and not _is_lambda_arn(reward_function):
  File ".../sagemaker/train/common_utils/finetune_utils.py", line 454, in _is_lambda_arn
    return bool(LAMBDA_ARN_REGEX.match(arn))

_is_lambda_arn() in finetune_utils.py references LAMBDA_ARN_REGEX, but the constant is never defined or imported in that module. Any RLVR training submitted with an evaluator (hub-content) ARN reward function takes the not _is_lambda_arn(...) branch in RLVRTrainer._verify_reward_function and hits the NameError, blocking programmatic RLVR submission entirely.

Fix

The identical regex already exists in rlvr_reward_verifier.py, and both call sites answer the same question — "is this reward-function string a Lambda ARN?". Rather than add a second, drift-prone copy, finetune_utils.py now imports the canonical pattern:

from sagemaker.train.common_utils.rlvr_reward_verifier import LAMBDA_ARN_REGEX

No circular import is introduced (rlvr_reward_verifier does not import finetune_utils).

Tests

Adds TestIsLambdaArn covering:

  • valid Lambda ARNs (incl. non-aws partitions like aws-us-gov)
  • evaluator hub-content ARNs → not a Lambda ARN
  • arbitrary non-ARN strings
  • assertion that both modules share the same compiled regex object (guards against future divergence)

Notes

A second, independent bug in the same RLVR verification path (Evaluator.get() raising ValueError on an unrecognized EvaluatorMethod) was identified but is intentionally out of scope for this PR and will be addressed separately.

…eError

`_is_lambda_arn()` in finetune_utils.py referenced `LAMBDA_ARN_REGEX`,
but the constant was never defined or imported in the module. Any RLVR
training submitted with an evaluator (hub-content) ARN reward function
hit the `not _is_lambda_arn(...)` branch in
`RLVRTrainer._verify_reward_function` and crashed with:

    NameError: name 'LAMBDA_ARN_REGEX' is not defined

The identical regex already exists in rlvr_reward_verifier.py, and both
call sites answer the same question ("is this a Lambda ARN?"). Import the
canonical pattern rather than duplicating it so the two paths cannot drift.

Adds regression tests covering valid Lambda ARNs (incl. non-aws
partitions), evaluator hub-content ARNs, and that both modules share the
same compiled regex.

Fixes: P467540738
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.

1 participant