Skip to content

New Model: Krea 2 - #1568

Merged
dxqb merged 29 commits into
Nerogar:mergefrom
dxqb:krea2
Jul 3, 2026
Merged

New Model: Krea 2#1568
dxqb merged 29 commits into
Nerogar:mergefrom
dxqb:krea2

Conversation

@dxqb

@dxqb dxqb commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Diffusers and Comfy formats load into Comfy, maybe also Kohya
  • int8 makes some noise in the background sometimes but not too bad. if your GPU can do float W8A8 well you might want to try switching

contains #1563

Test plan

  • pre-commit run --all-files passes
  • Launched the affected UI or script and exercised the change
  • Tested with at least one real preset / config when relevant (note which: Krea)

AI assistance

  • AI-assisted — I have read every line in this diff and can defend each change

dxqb and others added 10 commits June 30, 2026 00:23
Replace the per-model key_set machinery with a single convert()-native
pipeline shared across all model types. Each model owns its
diffusers<->original mapping and declares its text encoders and fusion
groups once; savers and loaders derive every format from those.

Save formats reworked into a small enum (KOHYA, LEGACY, ORIGINAL, COMFY,
DIFFUSERS) with real kohya-ss native+fused output, a frozen LEGACY that
absorbs the old format, and full-model COMFY_TRANSFORMER support. Loading
auto-detects the source format and normalizes to canonical keys with
per-model legacy hooks.

Migrates SD1.5/2.x, SDXL, SD3/3.5, Flux, Flux2, Chroma, PixArt, Sana,
Qwen, Ernie, Z-Image, HiDream, HunyuanVideo, Stable Cascade and
Wuerstchen, plus the standalone LoRA/checkpoint conversion tool.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Resolves the Ctk/PySide6 view-controller split against the LoRA/full-model
output-format rework: LoRAModule.py keeps the fusion check while dropping
the rank check (upstream Nerogar#1549); ModelTab.py's split becomes
BaseModelTabView.py + ModelTabController.py, with the output-format
selection logic living in the controller (get_output_formats), matching
the TopBarController pattern.
…nto Nerogar:merge

Adds AttentionMechanism (SDP/FLASH) selection, restoring the explicit
attention-backend choice removed when xformers was dropped. Rebased from
PR Nerogar#1227 (originally against master) onto Nerogar:merge; the UI addition
was re-targeted at BaseTrainingTabView (the ctk/Qt6 split from PR Nerogar#1566)
since the old TrainingTab.py no longer exists on this base.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…verage

- Add AttentionMechanism.CUDNN (diffusers "_native_cudnn" backend).
- Make _set_attention_backend's mask argument required (no default) so
  every call site has to make an explicit decision; drop the unused
  varlen parameter (FLASH hard-raises on any mask, it doesn't "maybe fail").
- Roll out to the models the original PR missed: Ernie (mask=True, its
  transformer builds a real attention mask internally from text_lens),
  Flux2 (mask=False), Wuerstchen (mask=False, StableCascadeUNet.forward
  has no attention_mask parameter at all).
- Switch the UI dropdown to options_kv (same pattern as
  LoraTabController.get_peft_types()) with human-readable labels sourced
  from TrainingTabController.get_attention_mechanisms(), keeping the
  stored/serialized enum identity unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Removed an extra newline before setting the attention backend.
Adds Krea 2 (transformer + Qwen3-VL text encoder + Qwen-Image VAE) as a
new model type: sampling pipeline, LoRA and full finetune training,
checkpoint loading/saving (diffusers + native raw.safetensors formats),
UI wiring, and a starter 16GB LoRA preset.

Text-encoder training is not supported (matches Z-Image/Ernie).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dxqb
dxqb changed the base branch from master to merge July 1, 2026 21:19
@dxqb dxqb linked an issue Jul 1, 2026 that may be closed by this pull request
@Silvicultor

This comment was marked as resolved.

dxqb and others added 5 commits July 2, 2026 07:27
FusedModuleGroup._leaf_forward_N called the inner peft module's forward
once per leaf, and that forward's orig_forward is the synthetic fused
base recomputing all N leaves' base output every time -- N real base
computes per leaf, N^2 total for a group of N. Add PeftBase.delta_forward,
an optional hook returning just the adapter's own contribution (the term
added to orig_forward(x)) without touching the base. LoRAModule and
LoHaModule implement it (their deltas never read the base weight);
FusedModuleGroup uses it, when available, to add each leaf's real,
unfused base once instead. DoRA/OFT/LoKr keep the slower generic path
(delta_forward defaults to None) since their forwards recompose the base
weight itself and aren't expressible this way.

Also replace the functools.partial(self._leaf_forward, leaf_index) hook
with four fixed _leaf_forward_0..3 methods: torch.compile guards on
leaf.forward's function identity, and a partial rebuilt on every
hook_to_module() call was a fresh object each time, forcing a recompile
on every hook/unhook cycle.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dxqb

This comment was marked as resolved.

@hameerabbasi

This comment was marked as off-topic.

dxqb and others added 8 commits July 2, 2026 21:06
Remove non-explanatory/out-of-place comments, drop the untrue Cascade
bracket note on LEGACY_LORA, and revert unnecessary learning_rate
notation-only changes in a few presets.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…uess

Mirrors the saver's _convert_legacy opt-in default: a model gets LEGACY
load support only by explicitly declaring its historical layout, not by
inheriting a generic reconstruction that happens to be right for most
models but silently wrong for any that isn't. Flux/Flux2/HunyuanVideo/SD3
opt in via the extracted _mixture_legacy_conversion() helper; Sana's now-
redundant None override is removed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Trims explanatory-only comments, converts ModelType's LEGACY/ORIGINAL_TRANSFORMER
format support from denylists to allow-lists (new models default to unsupported
until a saver implements them), drops the qkv-group matching's dependency on a
literal "i" placeholder name (matched_leaf_groups works with any/no placeholder),
removes dead fuse_qkv/fuse_split duplication in favor of a single variadic fuse(),
and removes the _denoising_body_conversion identity wrapper.
…ression

- Add required base-model-name field to the convert tool for LoRA/embedding conversion
- Fix convert_model.py CLI crashing on any LoRA/embedding conversion
- Inline the unused _check_fusion_match indirection in LoRASaverMixin
- Fix Flux2 LEGACY LoRA output regression and remove leftover debug print
Squashed review fixes: centralize the LoRA param allowlist and derive
SUPPORTED_PARAM_PREFIXES from FACTOR_PREFIXES, filter absent text
encoders, drop dead guards, fix the DoRA chunk-swap, and trim duplicate
comments.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
dxqb added 5 commits July 3, 2026 21:17
# Conflicts:
#	modules/module/FusedModule.py
Remove dead text-encoder-LoRA/train-dtype fields and now-pointless
text_encoder-is-None guards (TE is always loaded and never trained in
Krea2), drop redundant comments, simplify a few one-liners, and add
TODO markers for code that should eventually be shared with other
models. Also tighten supported_lora_formats/supported_full_model_formats
to use is_flux_1()/is_flux_2() explicitly instead of the version-
spanning is_flux(), so a future Flux variant doesn't silently inherit
unverified legacy-format support.
@dxqb
dxqb merged commit e991240 into Nerogar:merge Jul 3, 2026
1 check passed
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.

[Feat]: Support Krea-2-Raw training

3 participants