Skip to content

Conversation

@Pfannkuchensack
Copy link
Collaborator

Summary

Add full LoRA support for FLUX.2 Klein models (4B and 9B variants), including automatic detection, loading, key conversion, and UI integration.

Model Detection & Configuration

  • Detect FLUX.2 Klein LoRAs during model probe by inspecting tensor shapes (context_embedder, vector_in, hidden size, MLP ratio) to distinguish them from FLUX.1 LoRAs
  • Auto-detect Klein variant (4B vs 9B) from tensor dimensions and store as variant field on the config
  • New LoRA_LyCORIS_Flux2_Config and LoRA_Diffusers_Flux2_Config model configs
  • Register FluxLoRAFormat.BflPeft as a new recognized LoRA format
  • Fix Config_Base.get_tag() to handle None defaults (needed for the optional variant field)

BFL PEFT LoRA Format Support

  • New flux_bfl_peft_lora_conversion_utils.py with full BFL PEFT format detection and conversion
  • Handles fused QKV splitting (BFL fuses Q/K/V, diffusers uses separate projections)
  • Two conversion paths: FLUX.1 (keeps BFL keys) and FLUX.2 Klein (converts to diffusers keys)
  • Runtime fallback conversion via convert_bfl_lora_patch_to_diffusers() for LoRAs loaded with FLUX.1 format but applied to FLUX.2 models

LoRA Loading & Application

  • New Flux2KleinLoRALoaderInvocation and Flux2KleinLoRACollectionLoader invocations for applying LoRAs to Klein's transformer and Qwen3 text encoder
  • Variant mismatch warnings when a LoRA's variant doesn't match the transformer

Frontend

  • New addFlux2KleinLoRAs.ts graph builder for wiring LoRAs into the Klein generation graph
  • LoRA picker filters by variant compatibility (only shows 4B LoRAs for 4B models, etc.)

Related Issues / Discussions

QA Instructions

  1. Install a FLUX.2 Klein model (4B or 9B)
  2. Install a LoRA trained for that Klein variant (in BFL PEFT, diffusers, or LyCORIS format)
  3. Verify the LoRA is auto-detected as flux2 base with the correct variant (4B/9B) in the Model Manager
  4. Verify the LoRA picker only shows variant-compatible LoRAs when a Klein model is selected
  5. Generate an image with the LoRA applied and verify it takes effect without shape errors
  6. If possible, test with a mismatched variant LoRA and verify a warning is logged

Merge Plan

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • Changes to a redux slice have a corresponding migration
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

Pfannkuchensack and others added 3 commits February 6, 2026 01:01
Initial implementation for loading and applying LoRA models trained
with BFL's PEFT format for FLUX.2 Klein transformers.

Changes:
- Add LoRA_Diffusers_Flux2_Config and LoRA_LyCORIS_Flux2_Config
- Add BflPeft format to FluxLoRAFormat taxonomy
- Add flux_bfl_peft_lora_conversion_utils for weight conversion
- Add Flux2KleinLoraLoaderInvocation node

Status: Work in progress - not yet fully tested

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add BFL PEFT LoRA support for FLUX.2 Klein, including runtime conversion
of BFL-format keys to diffusers format with fused QKV splitting, improved
detection of Klein 4B LoRAs via MLP ratio check, and frontend graph wiring.
…ility

Auto-detect FLUX.2 Klein LoRA variant from tensor dimensions during model
probe, warn on variant mismatch at load time, and filter the LoRA picker
to only show variant-compatible LoRAs.
@github-actions github-actions bot added python PRs that change python files invocations PRs that change invocations backend PRs that change backend files frontend PRs that change frontend files labels Feb 8, 2026
@Pfannkuchensack
Copy link
Collaborator Author

I added the variant Fields for Loras too and maybe we could use that for SDXL Subtypes too.

@Pfannkuchensack Pfannkuchensack marked this pull request as ready for review February 9, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend PRs that change backend files frontend PRs that change frontend files invocations PRs that change invocations python PRs that change python files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant