Repository navigation
Studio: ask the Hub only for the first page a search reads - #18994
Conversation
Open-ended Hub listings (the general listing of a typed search, the Unsloth-only typed search, channel listings with no caller limit, and the model maker listings) asked for 500 expanded rows on their first request while the first batch reads at most 192 (100 per maker listing). makeSortFetch now takes a firstPageLimit: the first request (no cursor) asks for that many rows, and later pages put back the SDK's page size, so the listing keeps paging with the same rows in the same order.
|
@codex review |
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. Breezy! 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". |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! 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". |
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 nolimittolistModels, so@huggingface/hubasks forlimit=500and the Hub answers with 500 fully expanded rows (safetensors, config, gguf, tags, ...) before the first page can show:mergedModelIterator(every typed search),orgSearch),createChannelIteratorwhen the caller sets no limit (channel lists, and the newest listing of the Latest sort),providerUnslothFirstIteratorfor a model maker's name (qwen,google,meta, ...): one listing per Unsloth search term plus one per maker org, whiletake()reads onlyPROVIDER_POOL(100) rows of each before ranking.For
qwen3the 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
limitcannot 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
makeSortFetchtakes an optionalfirstPageLimit. On the first request of a listing (nocursor), it lowerslimitto that value. The Hub's next link repeats the request's limit, so on later pages (withcursor) 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.mergedModelIteratorgeneral listing: 192 on its first request.createChannelIteratorwith no caller limit: 192. Calls that already pass alimit(fetchChannelFirstPageat 192, the Latest trending pool at 100) keep it, and the SDK still ends them there.providerUnslothFirstIteratorlistings: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
mergedModelIteratoreach 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
expandfields 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:search=coder, downloadssearch=coder, createdAt (composer, Latest)search=qwen3, downloadssearch=llama, downloadsauthor=unsloth search=qwen(makerqwen)author=Qwen(makerqwen)author=unsloth search=gemma(makergoogle)author=google(makergoogle)Each next link from the Hub carried the capped limit (
limit=192orlimit=100), which is why later pages put back 500.I also ran the hook itself through 12 batches (576 rows) on
mainand on this PR forcoderand for makerqwen. Both give the same 576 rows in the same order.Results
I ran the shipped hook in Node (
mainand this PR, with React stubbed) against the live Hub, interleavingmain, this PR andmainagain (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.mainmain(A/A)maincoderqwen3llamaqwen(maker)google(maker)coder(Latest)coder, Unsloth onlyBoth arms send the same number of requests for each search. For
googlethe time difference is inside the A/A spread. Its largest listing (unslothgemma, 161 rows) is only a little smaller at 100 rows, so the bytes still drop but the time does not. The Unsloth-onlycodersearch has 4 rows, so nothing changes there.Compressed size on the wire for the first request:
main(limit 500)search=codersearch=qwen3author=Qwenauthor=unsloth search=qwenThe 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,
mainand this PR downloaded 8.41 MB and 6.62 MB forcoder, and 5.43 MB each forqwen.Tests
New
tests/hub-search-first-page-limit.test.tsruns the shipped hook with the real@huggingface/hublistModelsagainst a fake Hub that pages like the real one (honourslimitandcursor, 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 whatmainreads.fetchChannelFirstPagesends 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 #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, andeslinton the changed files is clean.