fix: keep dataset order in filter_long_prompt for mixed multimodal data - #2237
Open
keepkeen wants to merge 1 commit into
Open
fix: keep dataset order in filter_long_prompt for mixed multimodal data#2237keepkeen wants to merge 1 commit into
keepkeen wants to merge 1 commit into
Conversation
When a processor is configured, filter_long_prompt splits the samples into a text-only group (scored with one batched tokenizer call) and a multimodal group (scored one at a time), then appends the survivors group by group. The result is every surviving text-only sample followed by every surviving multimodal sample — the dataset's original order is gone even when nothing is filtered out. `--rollout-shuffle` defaults to False, so `Dataset.samples` is consumed exactly in this order: a VLM run over a mixed dataset trains all of its text-only prompts before it ever sees an image. The split is a throughput optimization introduced in THUDM#1662, which replaced a single order-preserving loop. Keep the split, carry each sample's original position through it, and sort the survivors back before returning.
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.
What
With a processor configured,
filter_long_promptreorders the dataset — even when it filters nothing out.Root cause
The function scores text-only samples with one batched tokenizer call and multimodal samples one at a time through the processor, then appends the survivors group by group:
So the returned list is every surviving text-only sample followed by every surviving multimodal sample, regardless of where they sat in the dataset.
Dataset.__init__assigns that list toself.origin_samples/self.samples, and--rollout-shuffledefaults toFalse, so this is the training order. A VLM run over a mixed text/image dataset trains every text-only prompt before it ever sees an image.Reproduction
Six alternating samples,
max_lengthhigh enough that nothing is dropped:Why it's a regression
Before #1662 this was a single order-preserving loop over
origin_samples. That PR split it into two groups for throughput ("Use processor only for samples with actual multimodal content; use batched tokenizer for text-only") and lost the ordering as a side effect — the stated goal was speed, not a different sample order.Fix
Keep the split, carry each sample's original position through it, and sort the survivors back before returning.
filter_long_promptruns once at dataset construction, so the sort is not on any hot path.Test
New CPU unit test
tests/test_filter_long_prompt.py, registered in thecpu-unittestjob: order is preserved with nothing filtered, with a mix of dropped text-only and dropped multimodal samples, for single-modality batches, and on the no-processor path. Two of the five cases fail onmain.slime.utils.processing_utilsis stubbed in the test — the multimodal branch imports it lazily and only needsprocess_vision_info, so the test doesn't pulltransformersinto the CPU image.