Skip to content

Unsloth Studio / Desktop: colour a companion download's bar by model, text encoder and VAE - #13112

Merged
danielhanchen merged 15 commits into
unslothai:mainfrom
LeoBorcherding:studio/download-bar-breakdown
Oct 12, 2026
Merged

danielhanchen merged 15 commits into
unslothai:mainfrom
LeoBorcherding:studio/download-bar-breakdown

Conversation

@LeoBorcherding

@LeoBorcherding LeoBorcherding commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

When Run fetches an image or video model's companions, the download panel shows one bar for everything. For Qwen-Image-2.1 Q2_K that's a 2.5 GB GGUF, 18 GB of text encoder and 1.4 GB of VAE behind a single percentage, so there's no way to see which part is taking the time.

This splits the companion bar into three segments: model (amber), text encoder (blue) and VAE (green). Each segment fills as its files arrive, with a legend underneath giving each part's size. A download that is all one kind of file, like the GGUF on its own, keeps the single bar.

Before: Unsloth Desktop 0.1.903 shows Qwen-Image-2.1's companion download as one bar. After: the same download split into model, text encoder and VAE

How

  • The diffusion and video download plans now carry file_bytes, the declared size of each file counted in bytes (diffusion.py, video.py, DiffusionDownloadPlanEntry in models/inference.py). The plan used to give one total per repo, and the text encoder and VAE usually come from the same repo, so the frontend couldn't tell 18 GB from 1.4 GB. A planner that doesn't fill file_bytes leaves it empty and the panel shows one bar, as before.
  • download-breakdown.ts sorts each file into model, text encoder or VAE. Tokenizer, scheduler and model_index.json count as text encoder, so there are always at most three parts. The job's single byte count is spread over the files in name order, since snapshot_download with max_workers=1 fetches them one at a time in that order.
  • The GGUF's size goes on the first companion's bar as the model segment, whether it was already cached or downloaded earlier in the same Run (it's staged first, as its own entry).
  • On a resumed download the job also counts files that were already on disk. Those bytes come off the count before the segments fill, otherwise all three segments read full while the counter is still at 15 of 19 GB (seen in a resumed run while testing this).
  • The legend is a wrapping row rather than labels under each segment: a 168 MB VAE segment is too thin for its own label.
  • The breakdown is saved with the download, so a reload keeps the colours. A malformed saved value is dropped.

Tests

Windows 11, tester PC (RX 6500 XT + RX 5700 XT, ROCm build).

base this PR
test_diffusion_backend.py -k download_plan (measured at 9d8f52f) 31 passed, 4 failed 32 passed, 4 failed
tests/download-breakdown.test.ts (at e126c93) not on base 8 passed
tsc -b clean clean

The 4 backend failures are the same tests on both sides: hosted-prequant and NVFP4 rung picks that resolve differently on this AMD box ('mxfp8' == 'nvfp4'). The three commits after 9d8f52f only touch the frontend, so the backend counts weren't re-run.

The screenshots and GIF come from a real download with this branch's backend and frontend, in Unsloth Studio on 127.0.0.1. The before is the released Unsloth Desktop 0.1.903 on the same download. The Desktop shell can't show the after yet, because it starts its own backend from the installed release, which doesn't send file_bytes.

Not tested: macOS and Linux, and the video page's download, which shares the same plan fields but wasn't run.

Before / after (merge base vs head f5855a0)

Two isolated Studio installs on Linux, same purged HF cache, Run on unsloth/Qwen-Image-2512-GGUF Q2_K. The panel is shot while the companion base repo downloads. Before: one bar. After: model 7.3 GB, text encoder 17 GB and VAE 254 MB segments with a legend, same 17 GB total.

Download panel before and after: the companion row's single bar becomes model, text encoder and VAE segments

Also in this branch: f5855a0 counts LTX-2's vocoder/ files as VAE (they were falling through to text encoder on the video page).

@LeoBorcherding
LeoBorcherding marked this pull request as draft October 9, 2026 01:41
@LeoBorcherding
LeoBorcherding removed the request for review from danielhanchen October 9, 2026 01:41
@LeoBorcherding
LeoBorcherding marked this pull request as ready for review October 10, 2026 07:31
@Imagineer99

Copy link
Copy Markdown
Member

I’d prefer to keep the existing separate model, encoder and decoder downloads. If some routes group those together, can we bring them into parity with the existing multi-stage UI rather than combine them in one bar?

image

- The Hub download queue runs the checkpoint first and drops unticked
  assets, so the bar's earlier/later parts are now worked out from that
  final list. Before, a plan that listed the encoder repo first showed the
  encoder as already done while the GGUF was still at 0.1 GB.
- A weights file at the repo root (a hosted prequant such as
  Qwen-Image-2.1-FP8.safetensors) counts as the model, not the text
  encoder.
- family-override.test.ts loads diffusion-pipeline-load-target.ts through
  the bundler resolver now that it imports via `@/`, and its source check
  matches the new `{ ...opts, checkpointBytes }` call.
- download-breakdown.test.ts passes `tsc -p tsconfig.test.json`.
… parts

- A checkpoint entry the plan stages with no bytes (an older snapshot
  already holds the GGUF) no longer hides the cached model segment on the
  companion rows.
- ae.safetensors, FLUX.1's VAE picked as a root-level override, counts as
  the VAE instead of the model.
@Etherll

Etherll commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

On the final head, the companion download bar splits into model, text encoder and VAE parts, and the parts fill in the order the files actually download.

What changed

  • From the Hub's Download button, the parts were sized in the plan's order, but the queue fetches the checkpoint first and skips assets you untick. A GGUF at 0.1 GB showed the text encoder as already done. The parts are now sized from the queue as it runs.
  • A hosted prequantized transformer such as Qwen-Image-2.1-FP8.safetensors was labelled "text encoder", and a checkpoint reused from an older snapshot dropped the model part from the companion rows. Both now show as the model. FLUX.1's ae.safetensors, picked as a VAE override, counts as the VAE.
  • tests/family-override.test.ts failed to load through the new @/ import, and the test file did not typecheck, so npm test and npm run typecheck would both fail. Both now pass.

The frontend suite, typecheck, build and bundle check pass on f2e99873. One timing-sensitive streaming test failed once under heavy host load and passes when run alone. The backend download-plan tests pass. Fork CI is running: Etherll#235. Not tested: a live video-page download, and macOS or Windows. The MiniMax-H3 native video planner and the sd.cpp image planner don't send per-file sizes yet, so those downloads keep the single bar.

Unsloth Studio download panel. Before (merge base 9e5d03bd): one bar. After (PR head f2e99873): model, text encoder and VAE segments with a legend

Unsloth Studio download panel, before at merge base 9e5d03bd and after at f2e99873. Both sides load the same seeded Qwen-Image-2.1 encoder + VAE download at 7.7 GB of 19 GB, with mocked progress.

Open product question

Earlier in this thread, the preference was to keep separate model, text encoder and decoder rows (the existing multi-row download UI) rather than one split bar. That needs a decision before this lands. One reuse option: when one repo supplies both the encoder and the VAE, stage them as two entries so they appear as the existing "Text encoder" and "Decoder & configuration" rows and the bar needs no colours. If the split bar stays, there are a few design points: it uses raw Tailwind amber/blue/emerald instead of theme tokens; amber already means "warning" on the same bar; the amber and emerald legend text at 10.5px is below 4.5:1 contrast on white; and the legend's lowercase "model" / "text encoder" differs from the "Text encoder" casing elsewhere in the panel.

@danielhanchen danielhanchen self-assigned this Oct 12, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 12, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-12T04:02:43.948802Z 34942e3 New commits
ℹ️ 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: de570e1f12

ℹ️ 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".

bytes: int = Field(
0, description = "Declared size of the files still missing from cache, 0 when unknown"
)
file_bytes: Dict[str, int] = Field(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Populate file sizes for native sd.cpp image plans

On hosts where /images/download-plan selects get_sd_cpp_backend() (the GPU-less/native sd.cpp path), SdCppBackend.download_plan() still creates every entry without file_bytes. This default serializes those entries with {}, and useStagedDownload only attaches a breakdown for a nonempty map, so image downloads that consist of a GGUF plus single-file encoders/VAE always keep the old single bar; populate the per-missing-file sizes in that planner too.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scope extension, not a bug: an sd.cpp plan without file_bytes keeps the single bar exactly as before, which is the documented fallback.

"repo_id": repo,
"files": names,
"bytes": sum(size for _name, size in staged),
"file_bytes": {name: int(size) for name, size in staged},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Populate file sizes for native MiniMax-H3 plans

For a MiniMax-H3 GGUF pick, VideoBackend.download_plan() returns through _h3_native_download_plan() before reaching this generic entry builder, and that native planner accumulates bytes without setting file_bytes. The response therefore contains an empty map and the frontend suppresses the breakdown, so H3's model, Qwen encoder, and VAE companion downloads do not receive the new segmented bar; mirror this per-file map in the native planner.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scope extension, not a bug: a MiniMax-H3 plan without file_bytes keeps the single bar exactly as before, which is the documented fallback.

/** The bar split by what each part of the download is, the cached model included. */
function PartsBar({ parts }: { parts: DownloadPart[] }) {
const total = parts.reduce((n, p) => n + p.bytes, 0);
const widths = parts.map((p) => Math.max(2, (p.bytes / total) * 100));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard segmented bars against zero-byte parts

When Hub metadata has unknown sizes, the new API legitimately supplies file_bytes values of 0; in a multi-entry plan, downloadParts() can still create two zero-byte kinds from earlierBytes/laterBytes and return them. Once the worker reports any downloaded bytes the bar is no longer indeterminate, and this division uses a total of zero, producing NaN% widths instead of a usable progress bar; skip nonpositive cross-job parts or fall back to the single bar when the aggregate size is zero.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d8cf44b: zero-byte parts are skipped, so a plan with unknown sizes keeps the single bar; test added.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d8cf44bb9d

ℹ️ 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".

const VAE = /vae|decoder|codec|vocoder|(^|\/)ae\.safetensors$/i;
// A weights file at the repo root is a single-file pick, the model itself: a hosted prequant such as
// `Qwen-Image-2.1-FP8.safetensors` names no transformer/ folder. Encoder prequants there say text_encoder.
const MODEL = /transformer|unet|\.gguf$|^[^/]+\.(safetensors|pt|pth|bin)$/i;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recognize nested single-file checkpoints as model bytes

When a supported Hub single-file checkpoint is below a directory (for example split_files/diffusion_models/dit.safetensors, a shape exercised by the backend's single-file path), this pattern does not match it because it only accepts transformer/unet, GGUF, or root-level weights. partOf() consequently adds the selected denoiser's bytes to the text-encoder segment, so these downloads show no model segment and can label most of the transfer as text encoder; classify checkpoint entries explicitly or recognize nested denoiser paths.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 663c61d: files under diffusion_models/ or checkpoints/ now count as the model; test added.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 663c61d951

ℹ️ 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".

Comment on lines +108 to +110
const checkpointDownloads = entries.some(
(e) => e.checkpoint && Object.keys(e.fileBytes ?? {}).length > 0,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle partially cached multi-file checkpoints

When a Wan 2.2 dual-expert pick has only one checkpoint file cached, VideoBackend reports checkpoint_bytes for both experts but fileBytes only for the missing expert. This all-or-nothing check either drops the cached expert when the selected file is missing, or adds the full two-expert size on top of the missing partner when the selected file is cached (checkpoint is then false), so the model segment is respectively too small or double-counted; compute the cached checkpoint contribution from the missing checkpoint bytes rather than just testing whether any checkpoint file is staged.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below the bar: it needs a Wan 2.2 pick with exactly one of its two experts cached, and the effect is a segment width in a progress legend; the byte counter and the download are unaffected.

checkpointBytes && checkpointBytes > 0 && !checkpointDownloads
? entries.findIndex((e) => !e.checkpoint)
: -1;
const merged = (list: T[]) => Object.assign({}, ...list.map((e) => e.fileBytes ?? {})) as Record<string, number>;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve duplicate filenames across repositories

When two staged repos use the same relative filename—supported component overrides can both be owner/repo/model.safetensors—this Object.assign overwrites the earlier entry's size. On a plan with checkpoint plus text-encoder/VAE override repos, the checkpoint row's laterBytes omits one entire asset, and rows after both repos do the same, so segment widths and totals are wrong; retain repo identity or sum collisions instead of flattening maps by filename.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in dc47781: same-named files from different repos are summed; test added.

// A weights file at the repo root is a single-file pick, the model itself: a hosted prequant such as
// `Qwen-Image-2.1-FP8.safetensors` names no transformer/ folder. Encoder prequants there say text_encoder.
// ComfyUI-layout single-file picks sit under diffusion_models/ or checkpoints/ (diffusion_content.py).
const MODEL = /transformer|unet|diffusion_models\/|(^|\/)checkpoints\/|\.gguf$|^[^/]+\.(safetensors|pt|pth|bin)$/i;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Carry component roles instead of inferring filenames

When a valid text_encoder_file or vae_file override has a generic Hub filename such as model.safetensors, the backend assigns its role from tensor contents, but this root-level-weight pattern makes partOf() classify it as model. These supported overrides therefore inflate the model segment and remove the actual encoder/VAE segment; carry the planner's component role in the breakdown rather than relying only on names.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below the bar: it needs a manual component override published under a generic file name, and only the legend colour moves. Carrying planner roles end to end is a separate refactor.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: dc47781137

ℹ️ 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".

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.

4 participants