feat(train): Add SequenceLength support for SFT, DPO, RLVR, RLAIF trainers#5898
Closed
guanweim wants to merge 0 commit into
Closed
feat(train): Add SequenceLength support for SFT, DPO, RLVR, RLAIF trainers#5898guanweim wants to merge 0 commit into
guanweim wants to merge 0 commit into
Conversation
zachgk
reviewed
May 28, 2026
| elif (isinstance(training_type, TrainingType) and training_type == TrainingType.FULL) or training_type == "FULL": | ||
| recipe = next((r for r in recipes_with_template if not r.get("Peft") and not r.get("IsSubscriptionModel")), None) | ||
|
|
||
| # Override recipe selection when sequence_length is explicitly requested |
Contributor
There was a problem hiding this comment.
This is cleaner to think about as a recipe filter. So move the sequence_length filter above the recipe selection logic and reduce the list of available recipes. Afterwards the existing logic can stay the same
| accept_eula=accept_eula, | ||
| ) | ||
| if sequence_length is not None: | ||
| config_kwargs["sequence_length"] = sequence_length |
Contributor
There was a problem hiding this comment.
You can probably pass on the None value to ServerlessJobConfig
mollyheamazon
left a comment
Contributor
There was a problem hiding this comment.
Please add integ test as sanity check as this is working e2e.
| training_type, | ||
| sagemaker_session, | ||
| sequence_length=None, | ||
| hub_name: str = "SageMakerPublicHub" |
Contributor
There was a problem hiding this comment.
This should be set to hub_name: Optional[str] = None for original pattern and consistency.
Author
added |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes:
Summary
sequence_lengthparameter to SFTTrainer, DPOTrainer, RLVRTrainer, and RLAIFTrainer for specifying context length in serverless training jobsSequenceLengthfield, picking the smallest recipe with context length >= the requested valueSequenceLengthtoservice-2.jsonand regenerate shapes via codegenTest plan
_parse_context_lengthhelper (K suffix, lowercase, integer, None, empty)sequence_lengththrough_create_serverless_configwith/without sequence_lengthBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.