Nodes/Realtime LoRA Trainer/Realtime LoRA Trainer (FLUX Klein - Musubi Tuner)
ComfyUI Node

Realtime LoRA Trainer (FLUX Klein - Musubi Tuner)

Train LoRAs for FLUX Klein 4B and 9B

By shootthesound·Created 8 months ago·Updated 2 months ago· 538
Realtime LoRA Trainer (FLUX Klein - Musubi Tuner)
  • image_1
  • image_2
  • image_3
  • image_4
  • lora_path
model_variantKlein Base 4B
inputcount4
images_path
musubi_path~/musubi-tuner
dit_model
vae_model
text_encoder
captionphoto of subject
training_steps400
learning_rate0.0001
lora_rank32
blocks_to_swap0
vram_modeLow (768px)
keep_loratrue
output_nameMyLora
custom_python_exe
caption_1
caption_2
caption_3
caption_4

What it is

FLUX Klein is Black Forest Labs' small, fast, distilled Flux 2 line, and it's been the default local image editor since it shipped in January 2026 - four checkpoints at once, split across size (4B/9B) and distillation (base/distilled). This node trains on the base variants: Klein Base 4B or Klein Base 9B, the undistilled ones BFL says explicitly are not meant for generation, only for fine-tuning. Whatever LoRA comes out gets applied at inference against the distilled 4B or 9B model, same pattern as Z-Image Base training on this pack.

Why bother: Klein tolerates LoRA stacking noticeably better than Z-Image (community reports of three LoRAs at full strength on Klein 9B without the quality collapse Z-Image shows past two), and its 4B variant is Apache 2.0 - the only Flux 2 weight you can build a commercial LoRA on without a BFL licensing conversation. Training landed in every major trainer within three days of Klein's release, which tells you the ecosystem cared.

How it works

Musubi Tuner trains against the Klein base checkpoint, using the Qwen3 text encoder Klein was built around (Qwen3-4B for the 4B model, Qwen3-8B for the 9B) and the FLUX.2 VAE. The node's blocks_to_swap control here is deliberately separate from resolution and precision settings, so you can dial VRAM usage independently of image quality - useful given how much heavier the 9B variant is than the 4B.

Inputs and outputs that matter

  • model_variant - Klein Base 4B or Klein Base 9B. This decision drives everything downstream: the 4B needs a Qwen3-4B text encoder and roughly 13GB VRAM footprint, the 9B needs Qwen3-8B and closer to 29GB.
  • dit_model, vae_model, text_encoder dropdowns, filled once you've downloaded the base (undistilled) checkpoint - not the distilled generation model - plus the matching Qwen3 encoder and the shared FLUX.2 VAE (ae.safetensors, the same file across all FLUX.2 variants).
  • inputcount plus image_N / caption_N pairs, or images_path for a folder.
  • training_steps (400), learning_rate (0.0001), lora_rank (32) - all deliberately lower/higher than this pack's older-architecture trainers, reflecting how sensitive current models are to a hot LR.
  • blocks_to_swap (0–16) as an independent VRAM lever, plus vram_mode with eight presets from Max (1256px) down to Min (512px), several offering fp8 and fp8-offload variants.

Output is a single lora_path string, ready for ApplyTrainedLora.

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/ShootTheSound/comfyUI-Realtime-Lora

Restart ComfyUI, install Musubi Tuner separately, and set musubi_path. From Hugging Face's black-forest-labs org, download flux-2-klein-base-4b.safetensors or flux-2-klein-base-9b.safetensors - the base, undistilled versions - plus ae.safetensors and the matching Qwen3-4B or Qwen3-8B text encoder. Dedicated example workflows for both sizes ship in the pack's workflows/Training/ folder.

Common issues

Downloaded the distilled model by mistake. BFL ships four Klein checkpoints and it's easy to grab the wrong one; only the base (undistilled) variants train correctly here.

9B running out of VRAM. The 9B is genuinely large - lean on blocks_to_swap first, then drop into an fp8 vram_mode preset, before concluding your card can't do it.

Applying a 4B LoRA to the 9B model or vice versa. The two sizes are not interchangeable; a LoRA trained on Klein Base 4B only applies to Klein 4B at inference, and the same goes for 9B. Publish and load for the size you actually trained on.

Categoryloaders

Inputs (24)

NameTypeDefaultDescription
model_variantCOMBOKlein Base 4BFLUX Klein model variant. 4B uses Qwen3-4B text encoder, 9B uses Qwen3-8B.
inputcountINT41–100Number of image inputs. Click 'Update inputs' button after changing.
images_pathSTRINGOptional: Path to folder containing training images. If provided, images from this folder are used instead of image inputs. Caption .txt files with matching names are used if present.
musubi_pathSTRING~/musubi-tunerPath to musubi-tuner installation.
dit_modelCOMBOFLUX Klein DiT model (flux-2-klein-base-4b.safetensors or flux-2-klein-base-9b.safetensors) from diffusion_models folder.
vae_modelCOMBOFLUX 2 VAE model (ae.safetensors from black-forest-labs/FLUX.2-dev) from vae folder. NOT the diffusers format VAE.
text_encoderCOMBOQwen3 text encoder (qwen_3_4b.safetensors for 4B, qwen_3_8b.safetensors for 9B) from text_encoders or clip folder.
captionSTRINGphoto of subjectDefault caption for all images. Per-image caption inputs override this.
training_stepsINT40010–5000Number of training steps. 400 is a good starting point.
learning_rateFLOAT0.00010.00001–0.1Learning rate. 0.0001 is recommended for FLUX Klein training.
lora_rankINT324–128LoRA rank/dimension. 32 is recommended for FLUX Klein.
blocks_to_swapINT00–16Number of transformer blocks to swap to CPU for VRAM savings. Max 13 for 4B, 16 for 9B. 0 = no swapping.
vram_modeCOMBOLow (768px)VRAM optimization preset. Controls resolution, gradient checkpointing, and fp8 settings.
keep_loraBOOLEANtrueIf True, keeps the trained LoRA file.
output_nameSTRINGMyLoraCustom name for the output LoRA. Timestamp will be appended.
custom_python_exeSTRINGAdvanced: Optionally enter the full path to a custom python.exe (e.g. C:\my-venv\Scripts\python.exe). If empty, uses the venv inside musubi_path. The musubi_path field is still required for locating training scripts.
image_1optIMAGETraining image (not needed if images_path is set).
caption_1optSTRINGCaption for image_1. Overrides default caption.
image_2optIMAGETraining image.
caption_2optSTRINGCaption for image_2. Overrides default caption.
image_3optIMAGETraining image.
caption_3optSTRINGCaption for image_3. Overrides default caption.
image_4optIMAGETraining image.
caption_4optSTRINGCaption for image_4. Overrides default caption.

Outputs (1)

NameTypeDescription
lora_pathSTRINGPath to the trained FLUX Klein LoRA file.