Repository navigation
Images page Train tab: multi-family training UI, loss charts, labeling, deploy - #6822
Conversation
…r-image seeds, Qwen sampler Address review feedback on #6724: - engine router: unload the engine being deactivated on a switch, so the old model is not left resident-but-unreachable (the evictor only targets the active engine). - generate route: sd.cpp execution errors (nonzero exit / timeout / missing output) now map to 500, not 409 (which only means not-loaded / cancelled). - native batch: return per-image seeds and persist the actual seed for each image so every batch image is reproducible. - Qwen-Image native path: apply --sampling-method euler --flow-shift 3 per the stable-diffusion.cpp docs; other families keep sd-cli defaults. - honor speed_mode (native --diffusion-fa) and, off-CPU, memory_mode/cpu_offload offload flags on the native load instead of hardcoding them off. - fail the load when the sd-cli binary is present but not runnable (version() now returns None on exec error / nonzero exit). - size estimate: only treat the transformer asset as a possible local path.
…s behind operator opt-in load_prequantized_transformer ends in torch.load(weights_only=False), which executes arbitrary code from the pickle. The transformer_prequant_path load-request field reached that unpickle for any local file an authenticated caller named, so a request could trigger remote code execution. Refuse the source.kind=='path' branch unless the operator sets UNSLOTH_ALLOW_LOCAL_PREQUANT_PATH=1; the first-party hosted-repo checkpoint stays trusted and unaffected. Document the requirement on the API field and add gate tests.
…tive, gate arch-specific kernels, accept sdpa
- apply_attention_backend now restores the native default when no backend is requested or a
kernel fails. diffusers keeps a process-wide active attention backend that
set_attention_backend updates, and a fresh transformer's processors follow it, so a load
that wanted native could silently inherit a backend (e.g. cuDNN) an earlier speed-profile
load pinned, breaking the bit-identical/off guarantee.
- select_attention_backend drops flash3/flash4 up front when the CUDA capability is below
Hopper/Blackwell. diffusers only checks the kernels package at set time, so an explicit
request on the wrong card set fine then crashed mid-generation; it now falls back to native.
- Add the sdpa alias to the attention_backend Literal so an API request with sdpa (already a
valid alias of native) is accepted instead of 422-rejected by Pydantic.
- Drop the dead replace('-','_') normalization (no alias uses dashes/underscores).
- perf_levers_probe.py output dir is now relative to the script, not a hardcoded path.
…nsformers; quantized threshold for GGUF - apply_step_cache now engages only via the transformer's native enable_cache (the diffusers CacheMixin path), which exists exactly when the pipeline wraps the transformer call in a cache_context. The standalone apply_first_block_cache fallback installed on non-CacheMixin transformers too (e.g. Z-Image), whose pipeline opens no cache_context, so the load reported transformer_cache=fbcache and then the first generation crashed inside the hook. Such a model now runs uncached per the best-effort contract. - GGUF transformers are quantized (the default Studio load path), so they now use the higher quantized FBCache threshold when the caller leaves it unset, instead of the dense default that could keep the cache from triggering. - fbcache_flux_probe.py: compile cached runs with fullgraph=False (FBCache is a graph break, so fullgraph=True failed warmup and silently measured an eager cached run); output dir is now relative to the script, not a hardcoded path.
…adder _is_consumer_gpu treated professional parts (RTX PRO 6000 Blackwell, RTX 6000 Ada) as consumer because their names carry no datacenter token, so the auto ladder moved int8 ahead of fp8 and the fp8 path chose fast accumulate for them. The rest of the backend already classifies these as datacenter/professional (llama_cpp.py _DATACENTER_GPU_RE), so detect the same RTX PRO 6000 / RTX 6000 Ada markers here and keep fp8 first with precise accumulate. Also fix the consumer-Blackwell test to use compute capability (10, 0) instead of (12, 0).
…he mxfp8 config Accessing torch.float8_e4m3fn raises AttributeError on a torch build without it (not just TypeError on older torchao), which would break the mxfp8 config helper instead of falling back to the default. Catch both so the fallback is robust. quant_probe.py: same AttributeError fallback; run LPIPS on CPU so the scorer never holds CUDA memory during the per-row VRAM probe; output dir relative to the script.
…restore on failed speeded load - snapshot_backend_flags reads each flag defensively (getattr + hasattr), so a build/platform missing one (no cuda.matmul on CPU/MPS) still captures the rest instead of skipping the whole snapshot. restore_backend_flags restores each flag independently so one failure can't leave the others leaked process-wide. - load_pipeline restores the flags (and clears the GPU cache) when the build fails after apply_speed_optims mutated the process-wide flags but before _state captured them for unload to restore -- otherwise a failed default/max load left cudnn.benchmark/TF32 on and contaminated later off generations.
…output Iterating proc.stdout directly blocks until the stream closes, so a sd-cli that hangs without producing output (or without closing stdout) would never reach proc.wait and the wall-clock timeout was silently bypassed. Drain stdout on a daemon thread and wait on the PROCESS, so the main thread always enforces the timeout and kills a hung process (which closes the pipe and ends the reader). Add a test that times out even when stdout blocks, and make the no-binary test hermetic so a host-installed sd-cli can't leak in.
…a None fqn The filter callback can be invoked without a module name, so fqn.lower() would raise AttributeError on None. Fall back to an empty name (nothing matches the exclusion tokens, so the linear is kept) instead of crashing the quantise pass.
- sd_cpp_backend: stop truncating explicit seeds to 53 bits (mask to int64); a large requested seed was silently collapsed (2**53 -> 0) and distinct seeds aliased to the same image. Random seeds stay 53-bit (JS-safe). - sd_cpp_backend: sanitize empty/whitespace hf_token to None so HfApi/hf_hub fall back to anonymous instead of failing auth on a blank token. - sd_cpp_backend: a superseding load now cancels the in-flight generation, so the old sd-cli can no longer return/persist an image from the previous model. - diffusion_engine_router: run the previous engine's unload() OUTSIDE the lock so a slow 10+ GB free / CUDA sync does not block engine selection. - diffusion_engine_router: probe sd-cli runnability (version()) before committing to native, so a present-but-unrunnable binary falls back to diffusers at selection. - diffusion_device: resolve a torch-free CPU target when torch is unavailable, so a CPU-only install can still reach the native sd.cpp engine instead of failing load. - tests updated for the runnability probe + a not-runnable fallback case.
- SECURITY: a request-supplied local pre-quant path is now unpickled only when it resolves inside an operator-configured ALLOWLIST of directories (UNSLOTH_ALLOW_LOCAL_PREQUANT_PATH = dir[:dir...]). The previous boolean opt-in, once enabled for one trusted checkpoint, allowed torch.load(weights_only=False) on any path a load request named (arbitrary code execution). realpath() blocks symlink escapes; a bare on/off toggle is no longer a wildcard. - Validate the checkpoint's min_features against the runtime Linear filter, so a checkpoint that quantised a different layer set is rejected instead of silently loading a model that mismatches the dense path while reporting the same scheme. - Tolerant base_model_id compare (exact or same final path/repo segment), so a local path or fork of the canonical base is accepted instead of falling back to dense. - _has_meta_tensors uses any(chain(...)) (no intermediate lists). - prequant verify/probe scripts use repo-relative paths (+ env overrides), not the author's absolute /mnt paths. - tests: allowlist-dir opt-in, outside-allowlist refusal, min_features mismatch, fork tail.
…ipts - diffusion_memory: when group offload is unavailable and the plan falls back to whole-module offload, enable VAE tiling (the group plan left it off, but the fallback is the low-VRAM path where the decode spike can OOM). Covers both the group and sequential fallback branches. - perf_verify: include the balanced-vs-off PSNR in the pass/fail condition, so a balanced bit-identity regression actually fails the check instead of exiting 0. - compare_engines: --vae/--llm default to None (were author-absolute /mnt paths), and the load-progress poll has a 30 min deadline instead of looping forever on a hang. - test for the group->model fallback enabling VAE tiling.
- diffusion: a torchao-quantized transformer is committed only compiled. A dense model resolves to speed_mode=off, which would run the quant eager (~30x slower than the GGUF it replaced), so when transformer_quant engaged and speed resolved to off, promote to default (regional compile); warn loudly if compile still does not engage. - diffusion_transformer_quant: build the nvfp4 config with use_triton_kernel=False so the CUTLASS FP4 path is used (torchao defaults to the Triton kernel, which needs MSLK); otherwise the smoke probe fails on CUTLASS-only Blackwell and silently drops to GGUF. - nvfp4_probe: repo-relative output dir + --out-dir (was an author-absolute /mnt path). - test asserts the eager-quant -> default-compile promotion.
…olation - diffusion_attention: gate the auto cuDNN-attention upgrade on SM80+; on pre-Ampere NVIDIA (T4/V100) cuDNN fused SDPA is accepted at set time but fails at first generation, so auto now stays on native SDPA there. - diffusion_attention: _active_attention_backend handles get_active_backend() returning an enum/None (not a tuple); the old unpack always raised and was swallowed, so the native-restore short-circuit never fired. - perf_levers_probe: free the resident pipe on a skipped (attn/fbcache) variant; run LPIPS on CPU so it isn't charged to every variant's peak VRAM; reset force_fuse_int_mm_with_mul so the inductor_flags variant doesn't leak into later compiled rows. - tests for the SM80 cuDNN gate.
…rdening - install_sd_cpp_prebuilt: download the release archive with urlopen + an explicit timeout + copyfileobj (urlretrieve has no timeout and hangs on a stalled socket); extract through a per-member containment check (Zip-Slip guard); expanduser the --install-dir so a tilde path is not taken literally; and on Windows CUDA also fetch the separately-published cudart runtime DLL archive so sd-cli.exe can start. - sd_cpp_engine: find_sd_cpp_binary honors UNSLOTH_STUDIO_HOME / STUDIO_HOME like the installer, so a custom-root install is discovered without UNSLOTH_SD_CPP_PATH; start sd-cli with the parent-death child_popen_kwargs so it is not orphaned on a backend crash; reap the SIGKILLed child (proc.wait) so a cancel/timeout does not leave a zombie. - tests: Zip-Slip rejection, normal extraction, studio-home discovery.
Codex review: when batch_count > 1, stable-diffusion.cpp's save_results() writes the numbered files <stem>_<idx><suffix> (base_0.png, base_1.png, ...) instead of the literal --output path. SdCppEngine.generate checked only the literal path, so a batch generation would exit 0 and then raise 'no image' (or return a stale file). generate now returns the literal path when present and otherwise falls back to the numbered siblings; single-image behavior is unchanged. Test: a fake sd-cli that writes img_0.png/img_1.png (not img.png) is collected without error.
…ale repeats Codex review on the native engine arg builder: - build_sd_cpp_command emitted --width/--height unconditionally, so an img2img/inpaint/edit run that left dims unset forced a 1024x1024 resize/crop of the input. width/height are now Optional (None = unset): an image-conditioned run (init_img or ref_images) with unset dims omits the flags so sd.cpp derives the size from the input image (set_width_and_height_if_unset); a plain txt2img run with unset dims keeps the prior 1024x1024 default; explicit dims are always honored. width/height are read only by the builder, so the type change is local. - build_sd_cpp_upscale_command used a truthiness guard (params.repeats and ...) that silently swallowed repeats=0 into sd-cli's default of one pass, turning an explicit no-op into a real upscale. It now rejects repeats < 1 with ValueError and emits the flag for any explicit value != 1. Tests: img2img unset dims omit width/height (init_img and ref_images), explicit dims emitted, txt2img keeps 1024; upscale rejects repeats=0 and omits the flag at the default. (Two pre-existing binary-discovery tests fail only because a real sd-cli is installed in this dev environment; unrelated to this change.)
… doc Codex review: the transformer_prequant_path field description still told operators to enable local checkpoints with UNSLOTH_ALLOW_LOCAL_PREQUANT_PATH=1, but the prior security fix made that variable a directory allowlist -- _allowed_prequant_roots deliberately drops bare on/off toggle tokens (1/true/yes/...). An operator following the documented =1 would have every transformer_prequant_path request silently refused. The description now states it must name one or more allowlisted directories and that a bare on/off value is not accepted. Test: asserts the field help references UNSLOTH_ALLOW_LOCAL_PREQUANT_PATH, does not say =1, and describes an allowlist/directory (guards against doc drift).
…istry reset Codex review on attention-backend selection: - Explicit attention_backend=cudnn skipped the SM80 gate that auto applies, so on pre-Ampere NVIDIA (T4 SM75 / V100 SM70) it set fine then crashed at the first generation with no fallback. select_attention_backend now applies _cudnn_attention_supported() to an explicit cuDNN request too. - flash3 used a minimum-only capability gate (>= SM90), so an explicit flash3 on a Blackwell B200 (SM100) passed and then failed at generation -- FlashAttention 3 is a Hopper-SM90 rewrite with no Blackwell kernel. The arch gate is now a (min, max-exclusive) range: flash3 is SM9x-only, flash4 stays SM100+. - apply_attention_backend's success path left diffusers' process-wide active backend pinned to the kernel it set; a later component whose processors are unconfigured (backend None) would inherit it. It now resets the global registry to native after a successful per-transformer set (the transformer keeps its own backend), best-effort. Also fixed _active_attention_backend: get_active_backend() returns a (name, fn) tuple, so the prior code stringified the tuple and never matched a name, defeating the native-restore short-circuit. Tests: explicit cudnn dropped below SM80; flash3 dropped on SM100 and allowed on SM90; global registry reset after a successful set; _active_attention_backend reads the tuple return.
…8 ladder Codex review: _DATACENTER_GPU_TOKENS omitted GH200 (Grace-Hopper) and B300 (Blackwell Ultra), though it has the distinct GB200/GB300 superchip tokens. So _is_consumer_gpu returned True for 'NVIDIA GH200 480GB' / 'NVIDIA B300', and the auto ladder moved int8 ahead of fp8 on those data-center parts -- contradicting llama_cpp.py's datacenter regex, which lists both. Added GH200 and B300 so they are treated as data-center class and keep the intended fp8-first behavior. Test: extends the datacenter parametrize with 'NVIDIA B300' and 'NVIDIA GH200 480GB' (now _is_consumer_gpu False).
…in the builder Codex review: the M=1 modulation/embedder exclusion was wired only into the dense runtime quantiser; the offline builder scripts/build_prequant_checkpoint.py called make_filter_fn(min_features) with no exclusion. So an int8 prequant checkpoint quantised the AdaLN modulation and conditioning-embedder linears, and loading it via transformer_prequant_path (the load path only loads already-quantised tensors, it can't re-skip them) reintroduced the torch._int_mm M=1 crash this phase fixes for the runtime path. Extracted int8_exclude_name_tokens(scheme) as the single source of truth (int8 -> the M=1 exclusion, every other scheme -> none) and use it in both the runtime quantiser and the builder, so a prequant artifact's quantised-layer set always matches the runtime. fp8/fp4/mx artifacts are byte-identical (empty exclusion). Test: int8_exclude_name_tokens returns the exclusion for int8 and () for fp8/nvfp4/mxfp8.
…s offload, load race Codex review on the native-engine routing: - The /images/load route took the GPU arbiter (acquire_for(DIFFUSION) -> evict chat) unconditionally after engine selection. A native sd.cpp load on a pure-CPU host never touches the GPU, so that needlessly tore down the resident chat model. The handoff is now gated: diffusers always takes it, a force-native sd.cpp load on a CUDA/XPU/MPS box still takes it, but a native sd.cpp load on a CPU host skips it. - sd_cpp status() hardcoded offload_policy 'none' / cpu_offload False even when _run_load computed real offload flags (balanced/low_vram/cpu_offload off-CPU), so the setting was unverifiable. status now derives them from state.offload_flags (still 'none' on CPU, where the flags are empty). - _run_load committed the new state without cancelling/waiting on a generation that started during the (slow) asset download, so a stale sd-cli run against the OLD model could finish afterward and persist an image from the previous model once the new load reported ready. The commit now signals the in-flight cancel and waits on _generate_lock before swapping _state (taken only at commit, so the download never serialises against generation), mirroring the diffusers load path. Tests: CPU native load skips the arbiter while a GPU native load takes it; status reports offload active when flags are set; _run_load cancels and waits for an in-flight generation before committing.
…iffusion-train-tab
The fp32 LoRA parameters and the bnb 4-bit base matmuls need a single compute dtype during the forward, exactly like the diffusers dreambooth scripts run under accelerator.autocast. Without it the 4-bit backward on FLUX.1-dev fails with an illegal-address CUBLAS error partway into the first step. Z-Image and Qwen-Image smokes are unaffected and the SDXL path (its own trainer) is untouched.
…ion-train-datasets
…iffusion-train-tab
There was a problem hiding this comment.
Code Review
This pull request transitions the image generation workspace's LoRA training from a simple dialog to a comprehensive, full-page training panel. It introduces support for multi-family training (FLUX.1, Qwen-Image, Z-Image, and SDXL), dataset labeling with inline caption editing, and one-click example dataset imports. Review feedback highlighted a CSS hover bug in the dataset labeling grid where the 'Remove' button would display on all tiles simultaneously, and suggested a UX improvement for numeric input fields to prevent them from immediately snapping back to fallback values when cleared during typing.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| <div | ||
| className={cn( | ||
| "flex flex-col gap-1.5 rounded-lg border p-2", | ||
| uncaptioned ? "border-amber-500/60 bg-amber-500/5" : "border-border", | ||
| )} |
There was a problem hiding this comment.
The group class is currently placed on the grid container instead of the individual LabelTile component. This causes the "Remove" button to appear on all image tiles simultaneously when hovering anywhere within the grid. Moving the group class to the LabelTile wrapper ensures the "Remove" button only displays when hovering over that specific tile.
| <div | |
| className={cn( | |
| "flex flex-col gap-1.5 rounded-lg border p-2", | |
| uncaptioned ? "border-amber-500/60 bg-amber-500/5" : "border-border", | |
| )} | |
| <div | |
| className={cn( | |
| "group flex flex-col gap-1.5 rounded-lg border p-2", | |
| uncaptioned ? "border-amber-500/60 bg-amber-500/5" : "border-border", | |
| )} | |
| > |
| {uncaptioned > 0 ? ` · ${uncaptioned} without a caption` : " · all captioned"} | ||
| </span> | ||
| </div> | ||
| <div className="group grid max-h-[420px] grid-cols-2 gap-2 overflow-y-auto pr-1 sm:grid-cols-3"> |
There was a problem hiding this comment.
Remove the group class from the grid container to prevent hovering over the grid from triggering the hover state on all child tiles simultaneously.
| <div className="group grid max-h-[420px] grid-cols-2 gap-2 overflow-y-auto pr-1 sm:grid-cols-3"> | |
| <div className="grid max-h-[420px] grid-cols-2 gap-2 overflow-y-auto pr-1 sm:grid-cols-3"> |
| value={value} | ||
| onChange={(e) => { | ||
| settingsDirty.current = true; | ||
| set(Number(e.target.value) || fallback); | ||
| }} |
There was a problem hiding this comment.
Using || fallback on the onChange handler causes the input to immediately snap back to the fallback value (e.g., 1 or 500) whenever the user clears the field to type a new number. This makes editing numeric fields extremely frustrating. Since onStart already performs robust validation for values being < 1 or <= 0, we can safely allow the input to be temporarily empty (represented as 0 in state, rendered as "") without forcing an immediate fallback.
| value={value} | |
| onChange={(e) => { | |
| settingsDirty.current = true; | |
| set(Number(e.target.value) || fallback); | |
| }} | |
| value={value === 0 ? "" : value} | |
| onChange={(e) => { | |
| settingsDirty.current = true; | |
| const val = e.target.value; | |
| set(val === "" ? 0 : Number(val)); | |
| }} |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 88514e244f
ℹ️ 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".
| {pageMode === "train" ? ( | ||
| <DiffusionTrainPanel |
There was a problem hiding this comment.
Keep Train panel mounted across tab switches
When users start a long training run and switch back to Create, this conditional removes DiffusionTrainPanel from the tree. On return the backend status is re-polled, but local state such as instancePrompt/outputDir is reset; the completion card then deploys with an empty trigger, so the promised prompt seeding and any in-progress form state are lost. Keep the panel mounted while hidden/inactive, or persist the job's trigger outside the component.
Useful? React with 👍 / 👎.
| if (next === persisted.current.trim()) return; | ||
| setSaving(true); | ||
| try { | ||
| const updated = await setDiffusionDatasetCaption(dataset, record.filename, next); |
There was a problem hiding this comment.
Prevent metadata captions from pretending to save
For datasets whose captions come from metadata.jsonl/captions.jsonl, the backend resolves metadata before sidecar captions. This blur save still writes only a sidecar and then resets from updated.caption, so an edit to a metadata-sourced tile is discarded and the trainer keeps using the old metadata caption. Disable or clearly label metadata-sourced rows, or update the metadata source instead.
Useful? React with 👍 / 👎.
| const d = defaultsFor(args.baseRepo); | ||
| setSteps(d.steps); | ||
| setGuidance(d.guidance); | ||
| void handleLoad(args.baseRepo, { kind: "pipeline" }).then((started) => { |
There was a problem hiding this comment.
Pass the trained family when deploying custom bases
When the run used a custom repo/local path whose name does not contain a family token, training can still start because this panel sends model_family, but deploy reloads only baseRepo. The image load validator then cannot infer the family and rejects the base before the adapter is applied; pass args.family through as family_override for this deploy load.
Useful? React with 👍 / 👎.
| loadedBaseRepo && family.base_repos.includes(loadedBaseRepo) | ||
| ? loadedBaseRepo | ||
| : family.base_repos[0] ?? CUSTOM_BASE; | ||
| setBaseChoice(preferLoaded); |
There was a problem hiding this comment.
Preserve the chosen base across dataset refreshes
Because family is rebuilt from each /info response, any refreshInfo() caused by an upload, example import, or caption-count refresh re-runs this effect and resets the user's selected base back to the loaded/default repo. In that scenario a user can pick a custom or secondary base, label/import data, and then unknowingly start training on a different base; only reseed this when the family name actually changes or track whether the base was edited.
Useful? React with 👍 / 👎.
| } | ||
| pendingDeploy.current = { loraId: stem, family: args.family }; | ||
| if (args.trigger.trim()) setPrompt(args.trigger.trim()); | ||
| setPageMode("create"); |
There was a problem hiding this comment.
Reset the generation workflow on deploy
If the user was previously on Transform/Inpaint/Edit before going to Train, deploying only switches the outer page mode back to Create and leaves the inner workflow unchanged. The loaded training base can then return to a disabled image-conditioned workflow (or require a source image) instead of the promised prompt+LoRA text-to-image flow; set workflow to "create" when deploying.
Useful? React with 👍 / 👎.
| <Textarea | ||
| value={caption} | ||
| onChange={(e) => setCaption(e.target.value)} | ||
| onBlur={() => void save()} |
There was a problem hiding this comment.
Await caption saves before training starts
When a user edits a caption and immediately clicks Start training, the textarea blur fires void save() but the Start handler can post the training request before that PUT finishes. The trainer may then read the old caption (or no caption) for the run, so track pending saves and disable/await Start until the blur save has completed.
Useful? React with 👍 / 👎.
The example-dataset cards used a two-column grid in the ~340px config column, which wrapped titles one word per line and let the long license text overrun into the neighbouring card. Switch to one card per row with a horizontal layout: title with a compact truncated license badge (full text in the tooltip), a two-line clamped description, and the Import button on the right. The Create/Train switch had an icon inside the Train trigger that overhung the pill corner. Drop the icon, make both triggers a fixed equal width so the active pill sits flush in the top bar.
The Train tab reused the LLM charts section, which also rendered an empty Grad Norm card and an Eval Loss card showing an Evaluation not configured placeholder with a red smear. Neither applies to diffusion LoRA training. Add a diffusion-only two-card view that reuses the loss and learning-rate cards directly with fixed presentation defaults, and note under the loss chart that per-step loss is noisy by design so users read the smoothed line for the trend rather than the raw jitter.
When a dataset with images is selected, show a strip of up to 8 sampled thumbnails with a +N more tile, so users can see what is in the folder before training. Clicking the strip opens the existing caption review grid. Samples are drawn evenly across the folder and refresh on dataset change or after an upload/import.
The example-dataset cards still overran the ~340px config column: the license used the Badge component whose baked-in w-fit and whitespace-nowrap ignored the max-width and truncate, and the grid children had the default min-width auto so wide content pushed past the column edge and clipped the Import buttons. Replace the badge with a plain truncating pill span, and give the config column min-w-0 with overflow-x-hidden so nothing escapes its width.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5dd9975118
ℹ️ 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 deploy = pendingDeploy.current; | ||
| if (deploy) { | ||
| pendingDeploy.current = null; | ||
| if (!deploy.family || deploy.family === fam) { | ||
| setLoras([{ id: deploy.loraId, weight: 1 }]); |
There was a problem hiding this comment.
Apply deploys when the loaded family is unchanged
When Deploy is clicked while a LoRA-capable image model from the same family is already loaded, pendingDeploy.current is set but none of this effect's dependencies change after the reload (loraCapable remains true and status.family remains the same). In that common same-family case this block is not re-entered, so the newly trained adapter is never selected despite the deploy succeeding; drive the pending deploy from state/a load token or apply it from the load-completion path.
Useful? React with 👍 / 👎.
| loadedBaseRepo && family.base_repos.includes(loadedBaseRepo) | ||
| ? loadedBaseRepo | ||
| : family.base_repos[0] ?? CUSTOM_BASE; |
There was a problem hiding this comment.
Preserve loaded custom bases in the Train tab
When the currently loaded generation model is a trainable custom/local base that is not one of the curated family.base_repos, this fallback silently selects the first curated repo instead of the loaded base. The family is still seeded from loadedFamily, so the form looks ready, but Start training posts the default base and trains the adapter on the wrong model; use the custom option and populate customBase for unmatched loadedBaseRepo values.
Useful? React with 👍 / 👎.
| base_model: baseModel, | ||
| model_family: family?.name, |
There was a problem hiding this comment.
Use DiT target modules for non-SDXL starts
When this new panel starts FLUX/Qwen/Z-Image training, it sends the family but omits lora_target_modules; the FastAPI request model fills that omitted field with the SDXL default targets, so run_dit_lora_training never falls back to the family spec targets and FLUX/Qwen skip their added-kv projections. For non-SDXL families, send an empty/family-specific target list or let the backend default after resolving the family.
Useful? React with 👍 / 👎.
| resolution, | ||
| train_steps: steps, | ||
| learning_rate: learningRate, | ||
| train_batch_size: batchSize, |
There was a problem hiding this comment.
Honor DiT batch size before sending it
For FLUX/Qwen/Z-Image, this posted train_batch_size is accepted, but the DiT training loop samples one image per accumulation step (unsqueeze(0)) and never iterates over cfg.train_batch_size; changing Batch above 1 therefore leaves the effective batch unchanged while the progress/throughput math scales by the requested value. Gate Batch to 1 for DiT families or implement actual batching before exposing this field.
Useful? React with 👍 / 👎.
| className={selectClass} | ||
| > | ||
| <option value="bf16">bf16 (default)</option> | ||
| <option value="fp16">fp16 (older GPUs)</option> |
There was a problem hiding this comment.
Hide fp16 for bf16-only image families
For Qwen-Image and Z-Image, selecting this advertised fp16 option passes the panel's local validation and posts the start request, but the family-specific trainer then rejects fp16 in the subprocess after the route has already freed the loaded GPU models. Disable or pre-validate this option for bf16-only families so a bad precision choice fails before evicting the user's current model.
Useful? React with 👍 / 👎.
| onClick={remove} | ||
| disabled={deleting} |
There was a problem hiding this comment.
Disable dataset deletes while training is running
When a run is active, the trainer has already captured image paths but still loads image files lazily on each step; this Remove button stays enabled and can delete a file from the dataset mid-run, causing the next sampled path to fail and abort training. Pass the running state through to disable destructive dataset edits, or have the backend reject deletes for the active training dataset.
Useful? React with 👍 / 👎.
Two permissive ~100-image sets for the Train tab: huggan/smithsonian_butterflies_subset (CC0, the classic diffusers-docs training set, imported as a subject set with a trigger prompt since its metadata columns are species names not captions) and m1guelpf/nouns (CC0, captioned pixel-art avatars via the text column). Both cap at 100 images.
Large example datasets (100+ images) rendered every tile at once, so the caption review grid grew unbounded. Show 24 images per page with < > chevrons and an x-y of N indicator; a new dataset or refresh resets to the first page.
Add an Examples group to the training-images dropdown that imports a curated dataset in one pick, alongside the existing cards. Cards now show up to three preview thumbnails pulled from the public HF datasets-server so the set is visible before download. Hide the trigger prompt when every image already has a caption (a captioned style set needs no trigger), and turn the training-settings toggle into a ghost button with a rotating chevron.
…iffusion-train-tab
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 485d3dcd1c
ℹ️ 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".
| type="button" | ||
| className="w-full" | ||
| onClick={onStart} | ||
| disabled={starting || uploading} |
There was a problem hiding this comment.
Disable Start while an example import is pending
When an example import is running, dataset is not updated until runExampleImport() and refreshInfo() finish, but the Start button remains enabled. If a user picks an example while an existing dataset is selected and immediately clicks Start, the request trains the previous dataset instead of the example that is still importing; include importingId !== null in this disabled state or block onStart while importing.
Useful? React with 👍 / 👎.
| void handleLoad(args.baseRepo, { kind: "pipeline" }).then((started) => { | ||
| if (!started) pendingDeploy.current = null; | ||
| }); |
There was a problem hiding this comment.
Clear pending deploys when the background load fails
This only clears pendingDeploy when the load request fails to start, but handleLoad resolves true as soon as the backend background load starts. If that later fails during download/auth/OOM, the ref survives and a future successful LoRA-capable load of the same family can silently select this stale adapter even though Deploy failed; clear the pending deploy from the load-progress error/null paths or tie it to a load token.
Useful? React with 👍 / 👎.
| const fullyCaptioned = Boolean( | ||
| selectedDataset && | ||
| selectedDataset.image_count > 0 && | ||
| selectedDataset.caption_count >= selectedDataset.image_count, |
There was a problem hiding this comment.
Derive full-caption state from per-image captions
This folder-level count can mark a dataset as fully captioned even when the captions do not match the images, e.g. duplicate .txt/.caption files for a few images or stray text files make caption_count >= image_count. In that case the trigger prompt is hidden and Start can train only the matched subset or fail with no captioned images; base this on the resolved per-image records instead of the raw caption-file count.
Useful? React with 👍 / 👎.
The base-model select's state could briefly hold the previous family's repo after a family switch (the reseed effect runs a beat later, and a value with no matching option makes the browser display the first option anyway). The request then carried the stale repo: picking Qwen or Z-Image still sent black-forest-labs/FLUX.1-dev and surfaced FLUX's gated-repo error under the wrong family. Derive an effectiveBase clamped to the current family's repos and use it for the select value, the start request, and the deploy fallback. Also move the Trigger prompt above Adapter name: the trigger describes the dataset, the name only labels the output.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8a7cab0754
ℹ️ 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".
| <DatasetLabelingGrid | ||
| dataset={dataset} | ||
| refreshKey={gridRefresh} | ||
| onCountsChanged={() => void refreshInfo()} |
There was a problem hiding this comment.
Reset the selected dataset after deleting the last image
When the last image in the selected dataset is removed, /info no longer returns that folder because it only includes datasets with image_count > 0. This refresh updates info but leaves dataset pointing at the now-empty folder, so the controlled select can display a different option while Start still posts the stale dataset name; the backend then frees the loaded image model and fails in the trainer with no captionable images. Reconcile the selected dataset after this refresh, or pass the remaining count from the delete path and switch to another dataset/upload when it reaches zero.
Useful? React with 👍 / 👎.
# Conflicts: # studio/backend/core/inference/sd_cpp_backend.py # studio/backend/core/inference/sd_cpp_engine.py # studio/backend/models/inference.py # studio/backend/tests/test_sd_cpp_install.py # studio/frontend/src/features/images/api.ts # studio/frontend/src/features/images/images-page.tsx # studio/install_sd_cpp_prebuilt.py
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
…ss (#8215) * remove the unused images train dialog and fix media page responsiveness diffusion-train-dialog.tsx has been dead since #6822 replaced it with train/diffusion-train-panel.tsx. Nothing imports it, DiffusionTrainDialog is its only export, and #8016 spent responsiveness edits on it while it was already unreachable. DatasetLabelingGrid capped its height at 420px with default auto rows, so once the tiles passed the cap Chrome divided the definite height between them instead of scrolling. Each tile is overflow-hidden, so its automatic minimum size is zero and the aspect-square thumbnail collapsed: measured tile 26px, thumbnail 170x0. auto-rows-min restores tile 404px, thumbnail 170x170 and a scrolling grid. The Images header positioned the Create | Train switch absolutely over a justify-between row, so at a 390px header it painted 124px over the model selector and 44px over the Video link. It is now a three column grid with equal side tracks, and the pill padding keys off the header width rather than the viewport, since the header is the viewport minus a resizable sidebar. The train run pane sized its stat grids and charts on viewport breakpoints while its own width is whatever is left beside the 416px form column, which put four stat cells needing 396px into a 266px pane. The pane is a container now and both break on its width. The Video header's left group had no min-w-0, so a long resident model name pushed the Images link 51px off a 390px viewport. test_desktop_reliability_frontend_contract.py matched the header band on an order coupled class literal. The marker is the band size now and the group pattern allows utilities between the tokens; every assertion is intact and was mutation tested against four violations it must catch. * hide the video status chips when the header cannot hold them md: is a viewport query, but the header is the viewport minus a sidebar that is resizable to 480px. At a 420px header the chips kept their intrinsic width and squeezed the model name to zero. They now key off the header's own width, so the name stays 230px readable below 720px and the chips return above it. * let the media page link truncate instead of overlapping the mode switch The link button was shrink-0, so below a roughly 370px header its equal side track underflowed the 90px control and the link overflowed left across the Train tab. It now shrinks and truncates its label the way the model selector already does, keeping the icon, the arrow and the tooltip. Measured at header widths 300 through 1000: link-left minus pill-right is -8 everywhere, previously +25 at 300. * Fix the Images header pill sitting 8px right of the page centre for PR #8215 --------- Co-authored-by: danielhanchen <[email protected]>
The Images page gains a top-level Create | Train switch next to the model selector; the Train LoRA dialog becomes a full training workspace. Stacked on the dataset APIs PR.
What changed
Verification
Full production build (tsc and vite) passes. Backend suites on the merged stack: 109 tests pass. A Playwright end-to-end script covering the tab switch, example import, caption editing, a short Z-Image training run with live chart growth, and deploy-to-Create is included in the verification runs for this stack.