Repository navigation
Studio: find VLM rows without an image or caption from Arrow validity - #15787
Merged
Merged
Conversation
This was referenced Oct 28, 2026
danielhanchen
marked this pull request as ready for review
October 29, 2026 09:28
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
danielhanchen
added a commit
to Etherll/unsloth
that referenced
this pull request
Oct 29, 2026
…hai#15870) ## What changes For a vision dataset whose image column holds URLs and has more than 200 rows, `convert_to_vlm_format` first probes the first 200 URLs to estimate throughput and the broken-link rate, discards the results, and then the conversion loop downloads and decodes those same 200 images again. The probe now keeps each image it downloaded successfully, keyed by row, and the first conversion batch uses it instead of fetching the URL again. Everything else stays as it was: - A URL whose probe download failed is not cached. The conversion retries it exactly as before, so a transient failure in the probe can still succeed. - The rest of each row's conversion (instruction, caption, `random.choice` for list captions) still runs in both passes, so the number of draws from the global RNG is the same as before. - Converted rows, their order, `failed_count`, the fail-rate gate, the ETA text and the progress messages are all unchanged. - Each cached image is popped when the first batch uses it. Main already kept the 200 probe results (images included) alive through its `futures` dict until the first batch started, and the finished list holds every converted image anyway, so peak memory does not grow. - One behaviour does differ: a URL whose content changes in the seconds between the probe and the first batch is now converted from the probe's download, where main used its second download. Either copy is a snapshot of the same row taken seconds apart, and the row is still downloaded through the same fetch path with the same checks. ## Results I ran a local HTTP server that serves 64x64 JPEGs, returns 404 for every 11th row, and counts GET requests. Each arm ran 3 times. | rows | GETs before | GETs after | converted | output sha256 (texts + pixel bytes) | progress messages | |---|---|---|---|---|---| | 450 | 650 | 469 | 409 / 409 | identical | identical | | 1200 | 1400 | 1219 | 1090 / 1090 | identical | identical | After the change, the GET count is the row count plus the probe rows that failed and get retried. Before the change it was the row count plus 200. Both counts were identical across all repeats. On loopback the wall time is inside run-to-run noise. The saving shows up on real remote URLs: about 200 downloads per dataset, or roughly 200 / (probe throughput) seconds. ## Tests - New `studio/backend/tests/test_vlm_probe_reuses_downloads.py` with 450 and 1200 rows, permanent and transient probe failures. It checks per-URL fetch counts, that transiently failed probe rows still convert, and the captions and pixels of every kept row. It fails before this change (probe rows are fetched twice) and passes after it. - The neighbouring VLM tests (`test_vlm_conversion_row_urls`, `test_vlm_null_caption_rows`, `test_vlm_probe_untrusted_rows`, `test_vlm_question_column`, `test_vlm_repo_relative_image_paths`, `test_vlm_text_only_rows`) give 72 passed both before and after. - `py_compile` passes on Python 3.9 and 3.10. ## Not covered - I did not time it against real remote image hosts. The evidence is the request count plus output parity. - Datasets with 200 rows or fewer skip the probe and are unaffected. - `convert_sharegpt_with_images_to_vlm_format` and `convert_llava_to_vlm_format` have no URL probe, so there was nothing to change there. - Merges cleanly with the open unslothai#15786 (ShareGPT image rows fetched concurrently) and unslothai#15787 (null image or caption rows found from Arrow validity); with all three applied, their tests and this one pass together (26 passed).
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 changes
Before converting,
convert_to_vlm_formatdrops rows whose image URL or caption is None. It found them by reading the whole column as Python objects (dataset[column]), which costs about 0.7 s per 100k rows per column, even when nothing is null._non_null_rowsnow reads the column's Arrow validity instead: no nulls returns at once; otherwise the valid positions come frompyarrow.compute.is_valid, in row order and respectingselect/shuffle/filterindex mappings. The selected rows, theselectcall (same Python int list), and the "Skipping N/M rows" log lines are unchanged. Empty strings and empty lists still count as present, only None is dropped. Image cells are not decoded. A dataset with a numpy, pandas, torch or custom format set (where a null float reads back as NaN and the walk keeps it), and anything without an Arrow view, walks the column as before.Results
100k caption rows, 3 runs each, same host:
Independent rerun, datasets 4.8.5, two arms each: no nulls 975.0 / 708.8 ms (main, main again) vs 2.15 / 2.21 ms; 1% nulls 807.2 / 724.5 ms vs 2.18 / 2.12 ms; same row indices. The same rows were also checked on datasets 3.4.1 with pyarrow 15.0.2 and datasets 4.3.0 with pyarrow 25.0.1 across strings, large strings, lists, nested structs, list of struct messages, dictionary encoded columns (including a null dictionary value), null typed columns, multi chunk tables, select / shuffle / filter,
Image()columns,IterableDatasetand plain lists (the last two take the walk, unchanged).A URL image dataset runs the check on both the image and the caption column, so a 100k row dataset saves about 1.3 s before the first image is fetched, and about 13 s at 1M rows.
Tests
studio/backend/tests/test_vlm_null_row_selection.py:Image()typed columns.Image()cells are not decoded.convert_to_vlm_formatno longer walks the image or caption column, and keeps the same rows and the same skip log lines. Fails on main (it walks both), passes here.tests/test_vlm_conversion_row_urls.pypasses on both arms (same IDs).format_conversion.pycompiles on Python 3.9 to 3.14.Not covered
Timed on Linux only; the change is pure Arrow and Python, nothing platform specific.