ai-toolkit/extensions_built_in/diffusion_models/flux2
科林 KELIN 489b194231
Fix CPU/CUDA device mismatch in Klein edit control image encoding (#742)
When training Klein models with a `control_path` (edit/kontext-style
paired datasets), `encode_image_refs()` returns tensors that reside on
the VAE's device (CPU, since the VAE weights are loaded via
`load_file(..., device="cpu")` and are never explicitly moved to the
training device).  Concatenating those CPU tensors with the training
latents (`packed_latents`) that live on CUDA raises:

    RuntimeError: Expected all tensors to be on the same device

Fix: move `img_cond_seq` and `img_cond_seq_ids` to the same device
(and dtype) as `img_input` / `img_input_ids` before concatenation.

Co-authored-by: HuangYuChuh <HuangYuChuh@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-25 11:45:38 -06:00
..
src Fixed issue that prevented full fine-tuning of flux2 models when using gradient checkpointing 2026-02-06 16:18:43 -07:00
__init__.py Add support for FLUX.2 klein base models 2026-01-17 17:46:25 -07:00
flux2_klein_model.py Add support for FLUX.2 klein base models 2026-01-17 17:46:25 -07:00
flux2_model.py Fix CPU/CUDA device mismatch in Klein edit control image encoding (#742) 2026-03-25 11:45:38 -06:00