Repository navigation
Studio: overlap the Hub search listings and ask only for rows that are read - #18477
Conversation
…e read A typed model search read the Unsloth listing before it requested the general one, so the first page waited on two Hub round trips. The general listing's first page is now requested alongside and read after the Unsloth rows, with the same order, dedupe and cache priming; a failure surfaces where it did before and a cancelled search aborts both. The training picker's listing likewise loads while its priority lookups finish. Listings that read a bounded number of rows now pass that bound as limit: the Unsloth pass of an unfiltered typed search (3 rows), the trending pool of the Latest sort (100 per task) and channel first pages (192).
Codex Review Summary: ❌ FailedThis 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. |
|
Codex Review: Didn't find any major issues. 🎉 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". |
) ## Summary `(Python 3.13, diffusion)` fails on `main` for every PR (seen on #18477, which only touches Hub frontend hooks): ``` FAILED tests/test_diffusion_windows_rocm_wide_head.py::test_dit_trainer_guards_the_preview_vae_a_warm_cache_loads[False] core/training/diffusion_dit_trainer.py:3050: in _rekey_conditioning_cache if (fresh.family, getattr(fresh, "text_encoder", "")) == ( E AttributeError: 'object' object has no attribute 'family' ``` Reproduced locally on `main` at `3ee3907c23`. ## Root cause #18386 added `_rekey_conditioning_cache`, which reopens the persistent conditioning cache once the conditioners are on disk and compares its namespace (`family`, `text_encoder`) with the one the run opened. That is correct for the real `PersistentConditioningCache`, which always sets both attributes in `__init__`. The test replaced `PersistentConditioningCache` with `lambda *_a: object()`, a bare object with none of the cache's attributes. It only worked while the cold path never read one. So the trainer change is fine and the stub was too thin. ## Changes - `test_diffusion_windows_rocm_wide_head.py` and `test_diffusion_training_download_phases.py` no longer stub `PersistentConditioningCache`. Both already point `cond_cache_dir` at `tmp_path`, and the real constructor only creates that directory, so the tests now run against the real cache and keep working when the trainer reads another of its attributes. The encode and warm-load steps around it stay stubbed as before, so nothing is encoded or downloaded. No source change. ## Testing - `pytest tests/test_diffusion_windows_rocm_wide_head.py tests/test_diffusion_training_download_phases.py` (from `studio/backend`): 19 passed; on `main` the `[False]` case fails as above. - The existing `tests/test_diffusion_cond_cache_rekey.py` covers `_rekey_conditioning_cache` itself and is unchanged.
|
Codex Review: Didn't find any major issues. You're on a roll. 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". |
…cker's Discover search finds the official Unsloth GGUF again (unslothai#18744) When you type in the composer model picker's Discover tab, the search shows a few Unsloth matches first, then community results. It only pulled the **3 newest** Unsloth matches, sorted newest-first. One release's uploads (FP8, bnb-4bit, NVFP4, GGUF) are ordered by upload time, so for `qwen3.8-27b` those 3 were the FP8, bnb-4bit and NVFP4 repos. The chat picker hides all three, and `unsloth/Qwen3.8-27B-GGUF` (the 4th) was never fetched. `qwen` alone worked only because it matches the Qwen provider search. Popularity sorts keep the short Unsloth head of 3. Newest-first sorts now read up to 20 Unsloth matches, so the whole release is there. **Test:** `tests/hub-search-unsloth-prefetch.test.ts` runs the 5 repos the Hub returns newest-first for `qwen3.8-27b` through the new limit, for every sort. It fails on base and passes here. The existing hub and composer-picker tests (406) pass, and `tsc --noEmit` is clean. ## Screenshots Colab T4, Linux, Unsloth Studio web UI. Both sides ran on the same VM: the PR head `7495936`, then the same checkout with `use-hub-model-search.ts` reverted to main `ba4979c` and the frontend rebuilt. `ba4979c` already has unslothai#18477 and unslothai#18473, and as of `fd3bbb2` main hasn't changed this hook since. | typed in Discover | before (main `ba4979c`) | after (`7495936`) | |---|---|---| | `qwen3.8-27b` | `Qwen3.8-27B-GGUF` only shows up at row 11, below the community repos | first | | `Qwen3.8-27B` | same | same | | `gemma-4-31b` | no Google GGUF in the first 10 rows | `gemma-4-31B-it-qat-GGUF`, `gemma-4-31B-it-GGUF` first | | `gemma-4` | no official Gemma 4 GGUF in view | E4B, E2B, 12B, 26B-A4B qat GGUFs first | | `mistral-small-3.2-24b-instruct-2506` | official GGUF at row 6 | first | | `qwen` (control) | unchanged | unchanged |   <details><summary>Edge cases: caps, broad query, Mistral, control</summary>     </details> --------- Co-authored-by: Daniel Han <[email protected]>
…#18994) ## Problem A typed model search (Model hub, composer model picker, export page, voice tab, embedding picker) fills its first page of 48 rows by reading at most `MAX_RAW_ITEMS_PER_BATCH` (192) rows. Several of the listings it reads pass no `limit` to `listModels`, so `@huggingface/hub` asks for `limit=500` and the Hub answers with 500 fully expanded rows (safetensors, config, gguf, tags, ...) before the first page can show: - the general listing of `mergedModelIterator` (every typed search), - the Unsloth-only typed search (`orgSearch`), - `createChannelIterator` when the caller sets no limit (channel lists, and the newest listing of the Latest sort), - `providerUnslothFirstIterator` for a model maker's name (`qwen`, `google`, `meta`, ...): one listing per Unsloth search term plus one per maker org, while `take()` reads only `PROVIDER_POOL` (100) rows of each before ranking. For `qwen3` the general listing is 7.7 MB of JSON (1.8 MB on the wire) for 500 rows, of which the first page reads at most 192. An SDK `limit` cannot fix this: it ends the listing after that many rows, and these listings must keep paging for infinite scroll and for the maker groups' tails. ## Change `makeSortFetch` takes an optional `firstPageLimit`. On the first request of a listing (no `cursor`), it lowers `limit` to that value. The Hub's next link repeats the request's limit, so on later pages (with `cursor`) it puts back the limit the SDK asked for (500). Only the first request of the listing gets smaller: the rows, their order and the later pages stay the same. - `mergedModelIterator` general listing: 192 on its first request. - Unsloth-only typed search: 192. - `createChannelIterator` with no caller limit: 192. Calls that already pass a `limit` (`fetchChannelFirstPage` at 192, the Latest trending pool at 100) keep it, and the SDK still ends them there. - `providerUnslothFirstIterator` listings: `PROVIDER_POOL` (100). The tail after the pool continues on the next page. Listings that already set a small limit (the Unsloth pass of a typed search at 3, the feed first pages, the trending pool) and the listings this PR does not touch (plain browse, owner listings, priority listing) send the same requests as before. Why 192 is enough: the first batch stops at 192 rows scanned. In `mergedModelIterator` each general row it skips as a repeat is one of the Unsloth rows already counted, so the batch never reads more than 192 general rows. A maker search reads 100 rows from each listing before it yields anything. ## Checked on the live Hub Anonymous GETs with the same `expand` fields Studio sends. For each listing, the capped first page was compared with the 500-row page, and the capped page's next link (limit set back to 500) was compared with the 500-row page plus its own next page: | listing | cap | rows compared | first page = leading rows (whole row JSON) | continuation = same order | | --- | --- | --- | --- | --- | | `search=coder`, downloads | 192 | 692 | yes | yes | | `search=coder`, createdAt (composer, Latest) | 192 | 692 | yes | yes | | `search=qwen3`, downloads | 192 | 692 | yes | yes | | `search=llama`, downloads | 192 | 692 | yes | yes | | `author=unsloth search=qwen` (maker `qwen`) | 100 | 411 | yes | yes | | `author=Qwen` (maker `qwen`) | 100 | 469 | yes | yes | | `author=unsloth search=gemma` (maker `google`) | 100 | 161 | yes | yes | | `author=google` (maker `google`) | 100 | 600 | yes | yes | Each next link from the Hub carried the capped limit (`limit=192` or `limit=100`), which is why later pages put back 500. I also ran the hook itself through 12 batches (576 rows) on `main` and on this PR for `coder` and for maker `qwen`. Both give the same 576 rows in the same order. ## Results I ran the shipped hook in Node (`main` and this PR, with React stubbed) against the live Hub, interleaving `main`, this PR and `main` again (A/A), 3 runs each. Time is from the start of the search to the first batch of 48 rows. MB is the JSON the requests of that search downloaded. The first-page rows were identical in every run of all three arms. | search | `main` | `main` (A/A) | this PR | MB `main` | MB this PR | | --- | --- | --- | --- | --- | --- | | Model hub `coder` | 475 ms (407 to 484) | 470 ms (424 to 606) | 292 ms (266 to 313) | 5.06 | 2.36 | | Model hub `qwen3` | 619 ms (497 to 725) | 632 ms (593 to 666) | 292 ms (256 to 405) | 7.73 | 3.04 | | Model hub `llama` | 298 ms (284 to 320) | 296 ms (278 to 321) | 227 ms (180 to 266) | 1.53 | 0.69 | | Model hub `qwen` (maker) | 294 ms (283 to 312) | 314 ms (272 to 382) | 183 ms (167 to 233) | 5.43 | 1.54 | | Model hub `google` (maker) | 222 ms (179 to 309) | 327 ms (261 to 382) | 268 ms (227 to 400) | 2.66 | 1.60 | | Composer picker `coder` (Latest) | 359 ms (331 to 414) | 344 ms (326 to 411) | 201 ms (195 to 280) | 4.34 | 1.66 | | Model hub `coder`, Unsloth only | 189 ms (115 to 226) | 158 ms (128 to 161) | 184 ms (151 to 216) | 0.34 | 0.34 | Both arms send the same number of requests for each search. For `google` the time difference is inside the A/A spread. Its largest listing (`unsloth` `gemma`, 161 rows) is only a little smaller at 100 rows, so the bytes still drop but the time does not. The Unsloth-only `coder` search has 4 rows, so nothing changes there. Compressed size on the wire for the first request: | listing | `main` (limit 500) | this PR | | --- | --- | --- | | `search=coder` | 1.19 MB | 0.41 MB (192) | | `search=qwen3` | 1.83 MB | 0.82 MB (192) | | `author=Qwen` | 0.39 MB | 0.13 MB (100) | | `author=unsloth search=qwen` | 0.47 MB | 0.12 MB (100) | The host has a fast link to the Hub, so on slower connections the time saved should be larger. Trade-off: scrolling a typed search past 192 rows now needs one more request (the next page is fetched at row 192 rather than at row 500). Rows and order do not change. In the 576-row runs above, `main` and this PR downloaded 8.41 MB and 6.62 MB for `coder`, and 5.43 MB each for `qwen`. ## Tests New `tests/hub-search-first-page-limit.test.ts` runs the shipped hook with the real `@huggingface/hub` `listModels` against a fake Hub that pages like the real one (honours `limit` and `cursor`, and its next link repeats the request's limit). Each test also compares the full output with a Hub serving 500-row pages, which is what `main` reads. - A typed search asks for 192 general rows first and 500 per page after that. The Unsloth pass still asks for 3. All 702 rows come out in the same order, and the second page starts right after the first page's last row. - A maker search asks for 100 rows first from the Unsloth term listing and from the maker org, then 500 on the next page. The output matches the uncapped run. - The Unsloth-only typed search and a channel listing ask for 192 first. A 600-row channel pages through unchanged. - Listings that already set a limit keep it: `fetchChannelFirstPage` sends one request at 192 and no next page, the Latest trending pool stays at 100, and a plain browse still asks for 500. All 4 fail on `main`. Two assertions in `tests/hub-search-listing-overlap.test.ts` (from unslothai#18477) pinned the old first request at 500: the general listing of a typed search, and the newest listing of the Latest sort. They now expect 192. Frontend tests matching hub, search, picker, channel, feed, merge-task, embedding, export and voice: 1347 passed on this PR and 1343 on `main` (the 4 new tests make the difference), no failures on either. `tsc` (app and tests) is clean on both, and `eslint` on the changed files is clean.
A typed model search (
mergedModelIterator, used by the Model hub, the composer picker, the legacy picker, the export page, the voice tab and the embedding picker) reads up to 3 rows from theowner=unslothlisting first, then the general listing. The general listing is an async generator that does not start until it is first read, so its request only went out after the Unsloth answer arrived. Every debounced search paid two Hub round trips in a row before the first page of 48 rows could fill.Several listings also asked the Hub for 500 fully expanded rows while reading far fewer:
qwen3on the live Hub that answer is 2.52 MB, against 31 KB for 3 rows),fetchChannelFirstPage(the Model hub feed rows) reads at mostMAX_RAW_ITEMS_PER_BATCH(192).The training picker had a smaller version of the same wait:
priorityThenListingIteratorwaited for all its prioritymodelInfolookups (3 at a time) to finish before it requested the listing.Change
use-hub-model-search.ts: newprefetchListinghelper. It requests a listing's first item right away, one microtask after the listing read first, so request order stays the same. It hands the listing over later throughread(). A rejection is handled at once and thrown again whereread()is iterated, which is where the error used to come out.cancel()aborts the listing and closes it. The listing gets its ownAbortController, which follows the search's signal.mergedModelIteratorstarts the general listing with it. The Unsloth pass is unchanged: same order, sameseendedupe, same cache priming. If that pass throws or the consumer stops during it, the general listing is cancelled. A new keystroke aborts both listings through the search's signal, as before.filterPriority) and no parameter filter, the Unsloth pass passeslimit(3 for a typed query) tolistModels. The SDK then sendslimit=3and stops after 3 rows. Phase 1 never read more than that.priorityThenListingIteratorstarts its listing while the priority lookups finish, and yields in the same order.createChannelIteratortakes an optionallimit. The fresh trending pool passes its pool size (FRESH_POOLtimes the task count). Task listings never share a model, so no single task listing can give more than the whole pool. The newest listing is read past its pool and stays unbounded.fetchChannelFirstPagepassesMAX_RAW_ITEMS_PER_BATCH(now exported), the mostpullBatchreads. On the Latest sort, this caller limit is dropped.A smaller
limitgives the same rows only if the Hub returns the leading rows of the same ordering, the same assumption the SDK's own pagination makes. I checked this on the live Hub for 7 listings (typedowner=unslothsearches sorted by downloads, trending and likes at limit 3, the trending pool at 100 for everyone and forunsloth, and the two feed channels at 192). Each smaller answer was exactly the first rows of the 500-row one.Results
Production builds of
mainand this PR in headless Chromium. Studio's/apiwas stubbed, and huggingface.co/api/modelswas answered from listings recorded once from the live Hub (500 rows with every expanded field Studio requests; a smallerlimitgets the leading rows), with 150 ms of latency per request, served concurrently. Querycoder, 5 runs per arm,mainrun twice as an A/A. Time is from the debounced query's first Hub request to the first search row on screen, median (min to max).Model hub waterfall, ms after the typed search starts (request start to answer):
owner=unsloth search=coderlimit=3)search=coder(general)Bytes from huggingface.co listings, same stub data:
codercoderBoth arms send the same number of listing requests. On both surfaces, for the typed search and the landing views, every run of both arms shows the same model rows in the same order. The result list's rendered text, with digits masked, has the same hash on both arms. Neither arm logs a page error or unhandled rejection; the one console message on both is a 404 from an unstubbed Studio endpoint. Superseding an in-flight search with one more keystroke aborted or completed the stale search's requests on both arms, and no other requests went out.
Tests
New
tests/hub-search-listing-overlap.test.tsruns the shipped hook with a fake Hub that holds each request open until the test releases it:limit=3, andlimit=500when a filter is active.All 7 fail on
main.Frontend tests matching hub, search, picker, channel, feed, merge-task, embedding, export and voice: 1312 passed on this PR and 1305 passed on
main(the 7 new tests make the difference), with no failures on either.tsc(app and tests) andeslinton the changed files are clean.