Skip to content

Studio: show diffusion training preparation progress - #15337

Merged
danielhanchen merged 6 commits into
mainfrom
fix/diffusion-training-preparation-progress
Oct 26, 2026
Merged

danielhanchen merged 6 commits into
mainfrom
fix/diffusion-training-preparation-progress

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Diffusion training shows a fixed zero-percent training bar, empty loss metrics, and an empty chart while it prepares the dataset. Its status text says "Preparing (cache latents 48/60)...", but those counts never reach the progress bar, making a working run look stuck.

Preserve preparation stage/counts in the status response and show preparation separately from optimization. For example, 48/60 fills the preparation bar to 80%; 60/60 says "Training data prepared" and explains that model setup is finishing. Loading and first-step work of unknown duration use an indeterminate indicator. Training metrics and charts appear after preparation; training steps then own the bar. Older backends' existing preparation messages are supported too.

Validation:

  • Eight frontend cases cover preparation counts, completed preparation, unknown durations, training transition, older backends, invalid counts, terminal states, and resume.
  • Backend transition tests cover count propagation and clearing on model-load completion, training, stop, and error.
  • Frontend type checking and production build passed; Ruff and diff whitespace checks passed.
  • Full diffusion service suite on Windows: 135 passed, 1 skipped, 2 failed. Both failures reproduce with the unchanged service from main: test_route_start_rejects_uncontained_paths uses /etc, and test_diffusion_dataset_upload_rejects_case_insensitive_stem_clash expects same-extension case variants to be accepted. Neither failure exercises preparation progress.

This change reports dataset preparation progress. It does not add model download byte tracking to the diffusion trainer.

Before / after

Tiny SDXL LoRA run, 2000 images with cache_latents=True, the run card while latents are being cached. Before is the merge base, after is this branch:

Diffusion training preparation before and after

Follow-up fixes

  • The status route returns DiffusionTrainingStatusResponse, which did not declare preparation, so FastAPI dropped the field from every /api/train/diffusion/status response. The bar still moved, but only through the legacy Preparing (...) message parser, which loses the counts as soon as a warning or a stop request replaces the message. preparation is now declared on the response model, and a route-level test checks that it comes back over HTTP.
  • A worker that dies during preparation (for example OOM while caching latents) sends no terminal event, and the pump's unexpected-exit path left in_model_load and the preparation counts stale. That path now clears both.
  • Warnings, stop/cancel acknowledgements and the resume notice are no longer hidden while preparing. The friendly caption is only used when the backend message is one of its own phase captions.
  • A run stopped or failed during preparation reports its terminal status shortly before the worker exits, while active is still true. During that window the card showed "Starting training" with an animated bar. A terminal status now wins.
  • MiniMax-H3 reports encode_prompts as n/n before it caches latents, so a finished encode stage no longer reads as "Training data prepared".

Validation of the follow-up

  • Real tiny SDXL LoRA runs with cache_latents=True (48 images), polling the live status route: with the fix, preparation goes 4/48, 8/48, ... 48/48, then clears at model_load_completed. On the previous head the key was absent from every response. Cancelling at 40/400 ends with preparation: null.
  • test_diffusion_training.py: 140 passed. Both new backend tests fail without the fix.
  • Frontend: 11 progress cases pass, typecheck passes.
  • Older frontends ignore the new optional field, and the status message text is unchanged. Newer frontends on an older backend still use the message fallback.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 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 ✅ Completed 2026-10-26T08:20:48.389945Z 13a595a Manual request
ℹ️ 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.

@danielhanchen danielhanchen self-assigned this Oct 26, 2026
The status route's response model filtered out the new preparation field,
so the UI only ever saw the counts through the legacy message fallback.
Declare it on DiffusionTrainingStatusResponse, clear it (and in_model_load)
when the worker dies mid-preparation without a terminal event, and keep
warnings and stop requests visible in the preparation caption.
A run stopped or failed during preparation reports its terminal status a
moment before the worker exits, while active is still true. Treat that as
terminal instead of showing "Starting training" with an animated bar.
MiniMax-H3 reports encode_prompts as n/n before it starts caching latents,
so a full encode stage is not the end of preparation.

[skip ci]
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 26, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 13a595a225

ℹ️ 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 added a commit that referenced this pull request Oct 26, 2026
## Problem

`trl-internal-testing/tiny-Phi3ForCausalLM` and
`trl-internal-testing/tiny-Qwen3_5ForConditionalGeneration` no longer
exist on the Hub. The model API returns 404 for both, even with a token.
TRL now publishes versioned names instead:

- `tiny-Phi3ForCausalLM-3` and `-3.5`
- `tiny-Qwen3_5ForConditionalGeneration-3.8`, `-NoThink` and `-Think`

Every test that loads one of the old ids fails with `OSError: ... is not
a valid model identifier`. This is red on every PR based on current
main, in both `Repo tests (CPU, rest)` and `Repo tests (CPU, gloo)`
(#15337, #15342):

- the `phi3` cases of `test_tp_native_oracle.py` and
`test_tp_native_gloo.py`
- the Qwen3.5 cases of `test_decision_model.py` and
`test_decision_from_lm.py`

Nothing in the repo changed; the upstream repos were renamed.

## Fix

Point the seven references at the closest renamed repo. I picked each
one by diffing its config against the old repo's config, which was still
in a local Hub cache:

| old | new | config differences |
|---|---|---|
| `tiny-Phi3ForCausalLM` | `tiny-Phi3ForCausalLM-3` | `vocab_size` 32011
to 32064, `sliding_window` None to 2047, `attention_bias` None to False
|
| `tiny-Qwen3_5ForConditionalGeneration` |
`tiny-Qwen3_5ForConditionalGeneration-NoThink` |
`text_config.full_attention_interval` 4 to 2; byte-identical
`chat_template.jinja` |

I rejected the other candidates:

- `tiny-Phi3ForCausalLM-3.5` adds `longrope` scaling and a 131k context.
- `tiny-Qwen3_5ForConditionalGeneration-3.8` changes the MLP size, the
value heads and the embedding tying, and ships a different chat
template.

`tiny-Qwen3_5ForConditionalGeneration-NoThink` was already used by one
test.

No other `trl-internal-testing/*` id referenced under `tests/`,
`studio/`, `unsloth/`, `scripts/` or `.github/` is missing from the
org's current model list.

## Verification

Every test id that failed in CI on #15337 and #15342 for this reason now
passes against the downloaded new repos:

- `test_tp_native_oracle.py`: `phi3` plan, simulated TP, fused-qkv GQA
layout and per-module local heads
- `test_tp_native_gloo.py`: `test_tp2_matches_one_process[phi3]`,
`test_sharded_loading_matches_full_load[phi3-2-None]`,
`test_tp2_x_fsdp2_dp2_matches_one_process[phi3-True-None]` and
`test_tp2_phi3_fused_qkv_under_a_packed_plan_matches_one_process`
- `test_decision_model.py`: the clef encoding, collator and
temperature-folding cases
- `test_decision_from_lm.py`: the train, save and reload case, and
`test_the_decision_notebook_runs_unchanged_on_a_plain_qwen3_5`

That is 45 + 1 passed. The wider selection over the seven touched files
passes as well: 187 passed, 12 skipped.
@danielhanchen
danielhanchen merged commit bafc1e8 into main Oct 26, 2026
66 of 67 checks passed
@danielhanchen
danielhanchen deleted the fix/diffusion-training-preparation-progress branch October 26, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant