Skip to content

Studio VLM conversion: fetch repo image files on a pool, settle rows in order - #17029

Merged
danielhanchen merged 3 commits into
mainfrom
perf/r30-vlm-bare-filename-pool
Nov 8, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
perf/r30-vlm-bare-filename-pool

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

In image + text datasets, the image column sometimes holds bare file names (0001.jpg, images/0001.jpg) that point at files in the dataset repo. convert_to_vlm_format resolved those with one hf_hub_download per row, one row at a time, before training could start. Each call is at least one Hub request (a HEAD even when the file is cached, since no revision is pinned), so 10k rows meant 10k sequential round trips. #15786 already moved the ShareGPT + image converter onto an in-order pool for the same case. This converter's image + text path was still serial.

Change

For rows whose image is a repo file name, the download and decode run on a thread pool: min(safe_thread_num_proc(), 8) workers, the same cap as the ShareGPT converter. Rows are still settled in row order on the calling thread, so the converted list, the random.choice pick for list captions, the failure count and the first-failure log line are the same as before. At most 2x workers images are held while waiting. Each task runs in a copy of the caller's context, so the fetch sees the same account and HF cache settings. Rows with local paths, URLs or embedded images are unchanged, and URL datasets keep their own probe-and-batch path.

Both converters now share one _settle_in_order helper (bounded in-order pool, context copy per task, queued tasks cancelled on interrupt), replacing the ShareGPT converter's inline copy. Net change in format_conversion.py: about 40 lines added, 60 removed.

Results (200 rows, fake Hub with 100 ms per download, 3 alternating runs per side)

main this branch
convert_to_vlm_format 20.31 to 20.48 s 2.58 to 2.67 s
converted rows / output digest 199 / same 199 / same
fetches issued before a Ctrl-C on row 20 stops it 21 31 (queued ones cancelled, no leftover threads)

The gain scales with the per-request latency and the worker count (8 here).

Tests

  • New tests/test_vlm_repo_image_fetch_pool.py. 48 rows that mix repo-relative and bare names, list captions picked with a fixed seed, and one download that fails: the pooled output equals the serial output, in the same order with the same captions. The same files are fetched, and more than one fetch runs at a time. It fails on main, because fetches run one at a time there.
  • tests/test_vlm_*.py + tests/test_sharegpt_*.py: 119 passed (ShareGPT pool tests unchanged and green on the shared helper).

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-08T15:17:39.080918Z
We couldn’t complete this review. Comment @codex review to try again.
3870057 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 93a1c3737a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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
danielhanchen marked this pull request as ready for review November 8, 2026 15:17
@danielhanchen
danielhanchen merged commit 4e260ac into main Nov 8, 2026
@danielhanchen
danielhanchen deleted the perf/r30-vlm-bare-filename-pool branch November 8, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant