Skip to content

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

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

studio: allow specifying family override for image and video diffusion models (#8618)#8622
karan68 wants to merge 4 commits into
unslothai:mainfrom
karan68:fix/image-model-family-override

Conversation

@karan68

@karan68 karan68 commented Aug 12, 2026

Copy link
Copy Markdown

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
Collaborator

@codex review

@mahiatlinux

Copy link
Copy Markdown
Collaborator

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

@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: 129805030f

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

attention_backend: attentionBackend === "auto" ? undefined : attentionBackend,
memory_mode: memoryMode === "auto" ? undefined : memoryMode,
transformer_cache: transformerCache === "auto" ? undefined : transformerCache,
family_override: familyOverride === "auto" ? undefined : familyOverride,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Seed generation defaults from the family override

When an override is needed for an opaque custom repository, the image picker still calls defaultsFor(repoId), which falls back to the Z-Image recipe of 9 steps and guidance 0; the post-load resident seeding effect also skips this load because lastLoad.current is set. Consequently, for example, an opaque SDXL merge loaded with the new sdxl override immediately generates with 9/0 instead of SDXL's 30/7 unless the user manually corrects the sliders. Use the selected family when deriving defaults or reseed them from the resolved family after loading.

Useful? React with 👍 / 👎.

["ltx-2", "LTX-2"],
["wan2.2-ti2v-5b", "Wan2.2-TI2V-5B"],
["wan2.2-t2v-a14b", "Wan2.2-T2V-A14B"],
["hunyuanvideo-1.5", "HunyuanVideo-1.5"],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Expose the 720p Hunyuan family override

For an opaque custom HunyuanVideo-1.5 720p fine-tune—the exact case requiring this selector—the only available Hunyuan option resolves to the 480p family. The backend has a distinct hunyuanvideo-1.5-720p family with a different base repository, scheduler shift, and disjoint resolution presets, and name-based 720p rerouting cannot help when an explicit generic override is supplied. Add the 720p family to this list so these checkpoints are not loaded and generated with the 480p configuration.

Useful? React with 👍 / 👎.

);
const [memoryMode, setMemoryMode] = useState<"auto" | "fast" | "balanced" | "low_vram">("auto");
const [transformerCache, setTransformerCache] = useState<"auto" | "off" | "fbcache">("auto");
const [familyOverride, setFamilyOverride] = useState<string>("auto");

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 Restore the loaded family override after remounting

When the page mounts with an opaque custom pipeline already resident, this state resets to auto even though the backend now reports the original explicit choice in status.resolved.family_override; the Advanced reseeding effect restores quantization, memory, and attention but never this control. The resident-pipeline path still enables Reapply, so clicking it omits the override and the backend rejects the otherwise valid model as an unknown family. Seed this selector from the resolved family record just like the other load-time controls.

Useful? React with 👍 / 👎.

Comment on lines +1901 to +1902
family_override:
controls.familyOverride === "auto" ? undefined : controls.familyOverride,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Route overridden H3 pipelines through the task chooser

When minimax-h3 is selected for an opaque custom pipeline, the override reaches the backend but the frontend's isH3PipelinePick checks only the repository's literal name. Such a pick therefore bypasses the H3 task dialog and sends no h3_task, which defaults the modular loader and download plan to the fl2va transformer; the separate 66 GB transformer_ref partition and References workflow become unreachable, and a reference fine-tune can load the wrong denoiser partition. Include the resolved override in the H3 task-routing decision.

Useful? React with 👍 / 👎.

@karan68

karan68 commented Aug 13, 2026

Copy link
Copy Markdown
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
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.

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

3 participants