feat(sft): surface multimodal payload through build_training_sample#94
Merged
Conversation
ApprovabilityVerdict: Needs human review This PR introduces a breaking API change by changing You can customize Macroscope's approvability policy. Learn more. |
eligotts
reviewed
Jun 30, 2026
| @@ -1534,15 +1534,54 @@ def _resolve_auto_config( | |||
| # --------------------------------------------------------------------------- | |||
|
|
|||
|
|
|||
Contributor
There was a problem hiding this comment.
can you add a comment here saying this mapping is matching the convention in prime-rl just to be crystal clear
eligotts
reviewed
Jun 30, 2026
| from renderers.base import PlaceholderRange, _build_mm_token_type_ids | ||
|
|
||
|
|
||
| def test_build_mm_token_type_ids_marks_ranges(): |
Contributor
There was a problem hiding this comment.
dont need these three tests
build_training_sample now returns a RenderedTrainingSample struct (token_ids, loss_mask, multi_modal_data, mm_token_type_ids) instead of a bare (token_ids, loss_mask) tuple. The mm fields are populated only when the renderer emitted media — None for text-only renderers and text-only samples — so text token_ids/loss_mask are byte-identical to before. This lets prime-rl's SFT consume one helper for both text and VLM instead of re-implementing the render+mask path inline for VLMs. mm_token_type_ids (0=text, 1=image, 2=video) are built from the rendered placeholder ranges at full token-stream length; the consumer truncates/shifts them in lockstep with token_ids. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
eligotts
approved these changes
Jun 30, 2026
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.
build_training_sample now returns a RenderedTrainingSample struct (token_ids, loss_mask, multi_modal_data, mm_token_type_ids) instead of a bare (token_ids, loss_mask) tuple. The mm fields are populated only when the renderer emitted media — None for text-only renderers and text-only samples — so text token_ids/loss_mask are byte-identical to before. This lets prime-rl's SFT consume one helper for both text and VLM instead of re-implementing the render+mask path inline for VLMs.
mm_token_type_ids (0=text, 1=image, 2=video) are built from the rendered placeholder ranges at full token-stream length; the consumer truncates/shifts them in lockstep with token_ids.
Rebased onto current
renderers/main; current PR head is99bedaf, which is the renderer commit pinned by PrimeIntellect-ai/prime-rl#2485.Note
Surface multimodal payload through
build_training_sampleas a structuredRenderedTrainingSampleRenderedTrainingSamplein renderers/base.py with fieldstoken_ids,loss_mask,multi_modal_data, andmm_token_type_ids, replacing the previous(token_ids, loss_mask)tuple return type ofbuild_training_sample._build_mm_token_type_idsto generate per-token modality IDs (0=text, 1=image, 2=video) from placeholder ranges, aligned to the prime-rl convention.multi_modal_dataandmm_token_type_idsare set toNone.RenderedTrainingSampleis publicly exported from renderers/init.py..token_idsand.loss_maskon the returned object.Macroscope summarized 99bedaf.
Note
Medium Risk
Breaking API change: any caller that unpacks the old 2-tuple must switch to
.token_ids/.loss_mask(and optionally the new mm fields).Overview
build_training_samplenow returns aRenderedTrainingSampledataclass instead of a(token_ids, loss_mask)tuple, so SFT pipelines can get multimodal fields from one render+mask path.The struct always includes
token_idsandloss_mask. When a VLM renderer actually emits media, it also fillsmulti_modal_dataandmm_token_type_ids(0=text, 1=image, 2=video per prime-rl), built from placeholder ranges via_build_mm_token_type_ids. Text-only renderers and empty media keep those fieldsNone; texttoken_ids/loss_maskstay the same as before.RenderedTrainingSampleis exported fromrenderers. Tests were updated to use the new return type and to cover modality flag marking.Reviewed by Cursor Bugbot for commit 99bedaf. Bugbot is set up for automated code reviews on this repo. Configure here.