Skip to content

studio: allow specifying family override for image and video diffusion models (#8618) - #8622

Closed
karan68 wants to merge 24 commits into
unslothai:mainfrom
karan68:fix/image-model-family-override
Closed

karan68 wants to merge 24 commits into
unslothai:mainfrom
karan68:fix/image-model-family-override

Conversation

@karan68

@karan68 karan68 commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #8618

Problem

When loading fine-tunes, merges, or custom derivative checkpoints for diffusion image or video models (e.g. user/FLUX.2_klein_9B, user/flux2_klein, user/klein-image-gen, or custom community LoRA/GGUF repacks), the backend raises a refusal because the repo id does not match canonical family substring heuristics:

_ValueError: '{model_name}' is not a supported diffusion image model. Supported families: flux.1, flux.2-klein, flux.2-dev, ... If this is a variant of one of them, pass family_override with that family name.

While the backend load and download-plan endpoints already accepted a family_override parameter, there was no way for users to set this override in the Studio UI. Additionally, delimiter variations in repo names (e.g., underscores _ vs hyphens - or dots .) caused heuristic auto-detection to fail on common names like FLUX.2_klein_9B.


Changes

  1. Frontend (images-page.tsx & video-page.tsx):

    • Added a Family architecture selector in the Advanced Options disclosure panel (defaulting to "Auto (detect)").
    • For image models, lists all supported diffusion families: FLUX.1, FLUX.2 Klein, FLUX.2 Dev, FLUX.1 Kontext, Qwen-Image, Qwen-Image-Edit, Z-Image, Krea 2, Lumina 2, HunyuanImage 2.1, HiDream-I1, Ideogram 4, SDXL.
    • For video models, lists supported video families: MiniMax-H3, LTX-2, Wan2.2-TI2V-5B, Wan2.2-T2V-A14B, HunyuanVideo-1.5.
    • Threaded family_override through LoadAdvanced / VideoLoadAdvanced, currentLoadAdvanced, loadDiffusionModel / loadVideoModel, and the download staging preflight (getDiffusionDownloadPlan / getVideoDownloadPlan).
    • Added loaded family indicator and resolved provenance to LoadedBuildSummary and formatResolvedValue.
  2. Backend Delimiter Flexibility & Aliases (diffusion_families.py & video_families.py):

    • Updated _token_in_needle with _token_regex to match delimiter variations (_, ., -, /, \), allowing repo names such as FLUX.2_klein_9B, flux2_klein, and flux-klein-v1 to auto-detect without requiring manual overrides.
    • Added aliases for Klein variants ("flux-klein", "klein").
    • Mirrored the delimiter regex matching in video_families.py.
    • Recorded family_override in build_resolved_record for runtime provenance.
  3. Tests (test_diffusion_backend.py):

    • Added unit test cases for explicit family_override resolution.
    • Added test_detect_family_delimiter_flexibility covering underscores, hyphens, and shorthand naming variants across families.

Verification

  • Tested auto-detection on variant repo identifiers:
    • user/FLUX.2_klein_9B -> flux.2-klein
    • user/flux2_klein -> flux.2-klein
    • user/flux-klein-v1 -> flux.2-klein
    • user/klein-4b-lora -> flux.2-klein
    • user/FLUX.2_dev -> flux.2-dev
    • user/flux-2-dev -> flux.2-dev
    • user/qwen_image_lora -> qwen-image
    • user/z_image_turbo -> z-image
    • user/wan2_2_ti2v_5b -> wan2.2-ti2v-5b
  • Verified explicit family_override on unrecognized custom repo names for all supported image and video families.
  • Verified build_resolved_record provenance and formatResolvedValue title formatting.
  • Ran backend unit tests in test_diffusion_backend.py (all passed).
Screenshot 2026-08-13 at 3 17 01 PM

@karan68
karan68 requested a review from danielhanchen as a code owner August 12, 2026 21:39
…n models (unslothai#8618)

- Add UI selector in Image and Video Generation Advanced Options panels for family_override.
- Thread family_override through load and download planning requests.
- Add delimiter flexibility and aliases in diffusion_families.py and video_families.py.
- Add backend unit tests for family overrides and delimiter variations.
@karan68
karan68 force-pushed the fix/image-model-family-override branch from c255d27 to 613fdd5 Compare August 12, 2026 21:42
@karan68 karan68 changed the title studio: allow specifying family override for image and video diffusio… studio: allow specifying family override for image and video diffusion models (#8618) Aug 12, 2026
@mahiatlinux

Copy link
Copy Markdown
Contributor

@karan68 this screenshot is not from Unsloth Desktop... have you manually verified and tested the fix?

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@karan68

karan68 commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor Author

@mahiatlinux Yes, here is a screenshot from the running Unsloth Studio interface showing the new Family override control under Advanced Options:
Screenshot 2026-08-13 at 3 17 55 PM

Review Feedback Addressed & Verified:

  1. Generation Defaults Seeding: defaultsFor now respects family_override so selecting an override (e.g. SDXL) immediately updates steps and guidance sliders to that model's recommended parameters (30 steps, 7.0 guidance) instead of defaulting to 9/0.
  2. Hunyuan 720p Video Family: Added hunyuanvideo-1.5-720p (HunyuanVideo-1.5 (720p)) to VIDEO_FAMILY_OPTIONS and resolved-precision.ts labels.
  3. Reseed on Remount: resolvedSeedKey and the load-time reseeding effect track family_override so the state persists across tab switches.
  4. H3 Task Chooser Routing: isH3PipelinePick accounts for familyOverride === "minimax-h3" || familyOverride === "h3" to route custom H3 pipelines through the partition selector dialog (fl2va vs ref2va).

@karan68
karan68 force-pushed the fix/image-model-family-override branch 2 times, most recently from 2138516 to d0062aa Compare August 13, 2026 07:15
@karan68
karan68 force-pushed the fix/image-model-family-override branch from d0062aa to cfa6de2 Compare August 13, 2026 07:21
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed there is no way to set family_override from the images or video tabs today, only through the API layer in studio/frontend/src/features/images/api.ts, so the selector is worth having. The direction is right but the same _token_regex helper is copied into both diffusion_families.py and video_families.py and the bare "klein" alias widens auto-detection beyond the ask, so could you factor the helper into one place and keep the matching change minimal?

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 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-09-01T12:36:04.937682Z 7d8f2c1 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.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

…edback

# Conflicts:
#	studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx
chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 31, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 31, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 31, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 31, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 31, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 31, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 31, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 31, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 31, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 31, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 31, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 31, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 31, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 31, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 31, 2026
@Imagineer99 Imagineer99 self-assigned this Sep 1, 2026
@Imagineer99

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: 7d8f2c1034

ℹ️ 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 +43 to +44
supportsStandaloneCheckpoint &&
(recoverableDiffusionGguf || inertSafetensors)

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 Admit opaque pipeline directories for family overrides

When a local full Diffusers pipeline has an opaque directory name and its metadata does not map to a known family, classification leaves it with task == null, model_format == "unknown", and canChat == false. The shared inventory only preserves the inert-safetensors signature, and this predicate likewise accepts only GGUF or safetensors; moreover, supportsStandaloneCheckpoint explicitly rejects MiniMax-H3. Consequently, selecting the H3 override can never expose an unrecognized local H3 pipeline, even though H3 is pipeline-only and family_override is the only way to classify such a custom fine-tune. Preserve and admit taskless Diffusers pipeline-directory rows when an explicit compatible family is selected.

Useful? React with 👍 / 👎.

Comment on lines +663 to +665
_DIFFUSION_COMPANION_WEIGHT_STEMS = frozenset(
{"ae", "vae", "clip_l", "clip_g", "t5xxl", "learned_embeds", "embeddings"}
)

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 Exclude registered text encoders from checkpoint discovery

The new bare-safetensors classifier does not recognize several text-encoder filenames that this repository itself registers as diffusion companions, including qwen_3_4b.safetensors, qwen_3_8b.safetensors, and mistral_3_small_flux2_bf16.safetensors in diffusion_families.py. If one of these files is placed directly under ./models, an LM Studio root, or a custom scan folder, it is classified as an inert standalone checkpoint and becomes selectable as soon as a family override is chosen; selecting it then sends an encoder-only payload through the diffusion single_file loader and fails. Add the known companion basenames (or derive them from the family registry) to this exclusion.

Useful? React with 👍 / 👎.

return _is_transformers_safetensors_weight_name(path.name)


_SAFETENSORS_SHARD_SUFFIX = re.compile(r"-\d+-of-\d+\.safetensors$", re.IGNORECASE)

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 dtype-qualified safetensors shards

This suffix only rejects shards whose count is immediately followed by .safetensors, but the repository documents real Diffusers shard names such as diffusion_pytorch_model-00001-of-00002.bf16.safetensors in hub/utils/inventory_scan.py. When dtype-qualified shards are loose files in ./models, LM Studio, or a custom scan root, each file is classified independently as a complete inert checkpoint, exposed by a family override, and then fails when loaded alone. Match the optional variant segment between the shard count and .safetensors so incomplete variant shards cannot be offered as standalone models.

Useful? React with 👍 / 👎.

@Imagineer99

Copy link
Copy Markdown
Member

Superseded by #10150, which carries forward the original feature from @karan68 and credits Karan as a co-author on the replacement commit. The new branch starts from current main and replaces the review-churn heuristics with an explicit structural artifact contract, while preserving the family-override product direction. Closing this PR so review and CI converge on one branch. Thank you @karan68 for originating the fix.

@Imagineer99 Imagineer99 closed this Sep 1, 2026
danielhanchen pushed a commit that referenced this pull request Oct 1, 2026
Adds a registry-backed Family control to Images and Video, pins family_override through download planning, staging, loading, status and Reapply, and admits a task-less cached row only when a non-Auto family is chosen and the folder is a complete Diffusers pipeline root.

Fixes #8618. Supersedes #8622.

Co-authored-by: karan yadav <[email protected]>
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.

[Feature] [Bug] Allow users to specify family_name overrides for image models and similar through the UI.

5 participants