Nodes/VRGameDevGirl Video Enhancement Nodes/VRGDG Z-Image LoRA Train Chunk
ComfyUI Node

VRGDG Z-Image LoRA Train Chunk

Train a Z-Image character or style LoRA in resumable chunks, ComfyUI-native

By vrgamegirl19·Created about a year ago·Updated about 7 hours ago· 718
VRGDG Z-Image LoRA Train Chunk
  • model
  • model
  • latest_state_path
  • log_path
  • latest_comfy_lora_path
  • output_name
  • completed_steps
  • total_target_steps
dataset_images_dir
workspace_dir
run_nameZImageChunkRun
output_nameZImageChunkRun
resolution_width1024
resolution_height1024
steps_per_run250
total_target_steps3000
network_dim32
network_alpha32
blocks_to_swap4
clear_memory_before_text_encodertrue
learning_rate_preset1e-4
learning_rate0.0001
num_repeats1
cache_strategyauto
copy_latest_to_comfy_lorastrue
keep_only_comfy_lorafalse
strength_model1.00
create_captionsfalse
caption_text
add_trigger_wordfalse
trigger_text
musubi_rootA:/MUSUBI/musubi-tuner-ltx2
zimage_checkpointA:/MUSUBI/models/zimage/zimage-base.safetensors
vaeA:/MUSUBI/models/zimage/vae.safetensors
text_encoderA:/MUSUBI/models/qwen3
fp8_basetrue
fp8_scaledtrue
fp8_llmfalse
use_32bit_attentionfalse

Z-Image is one of the friendlier image models to train against - a Qwen3 text encoder, a 16-channel latent, and community recipes that put a character LoRA at around 32 minutes on a 5090. This node wraps that training in ComfyUI, using a musubi-tuner install as the engine, so you never leave the graph. If the LTX audio node is the weird one in VRGameDevGirl's training trio, this is the straightforward one: point it at a folder of images, set a step budget, and collect a LoRA.

It runs on the same resumable "chunk" philosophy as the rest of the pack: each execution does steps_per_run steps (default 250), saves state, and stops. Re-run the graph and it resumes until completed_steps hits total_target_steps (default 3000). workspace_dir holds cache, logs, config and checkpoints - keep it on a disk with room, because the text-encoder cache and checkpoints add up.

How it works

dataset_images_dir points at your training images (or a parent folder the node organizes into an images subfolder). resolution_width/resolution_height (default 1024×1024) set the training bucket written into the musubi dataset config - 1024 is fine for Z-Image; if you follow the community's small-dataset recipe you'll often train lower and let bucketing handle the rest. num_repeats controls how many times each image-caption pair repeats, and create_captions will write missing .txt files from caption_text (with add_trigger_word/trigger_text if you want a trigger token prepended).

Then the modern-training knobs, and this is where the KB's advice earns its keep: you do not train the text encoder on a Qwen3-class model. The node caches text embeddings and unloads memory first (clear_memory_before_text_encoder on by default) - that caching is the single biggest speed lever. learning_rate_preset offers 1e-4 down to 1e-5 (Custom to set your own); 1e-4 is the default and a reasonable start. blocks_to_swap offloads transformer blocks to CPU - higher values cut VRAM but slow training. fp8_base/fp8_scaled are on by default; fp8_llm additionally loads the Qwen3 encoder in fp8 during caching if you're tight on VRAM.

The three model paths - musubi_root, zimage_checkpoint, vae, text_encoder - default to A:/MUSUBI/... Windows paths that you must repoint at your own downloads. Same as the LTX node, this is the first thing that trips people up.

Outputs and the feedback loop

model returns your base model with the latest LoRA optionally applied at strength_model. latest_comfy_lora_path is the converted ComfyUI-format LoRA (the node converts from musubi's format and, with copy_latest_to_comfy_loras on, drops a copy into your ComfyUI loras folder - keep_only_comfy_lora deletes the non-Comfy versions once the .comfy.safetensors exists). latest_state_path, log_path, output_name, completed_steps and total_target_steps complete the picture; wire the step counts into a compare node so the graph knows when to stop re-running.

Install and gotchas

Install the pack via ComfyUI Manager (search "vrgamedev") or cd ComfyUI/custom_nodes && git clone https://github.com/vrgamegirl19/comfyui-vrgamedevgirl, restart, and install kornia, librosa, imageio from the README. The real setup is separate: a musubi-tuner install, the Z-Image base checkpoint, its VAE, and the Qwen3 text encoder files - all pointed at via the node's path inputs.

Watch the VRAM math before you start. A 5090 breezes through Z-Image character training, but on a 12GB card you'll want fp8_llm on and blocks_to_swap cranked up, and you'll be trading speed for memory. Keep the dataset small and clean - the community's best results are 15–25 images, well-captioned, and 2200 steps; throwing 200 images at it trains slower and usually worse.

CategoryVRGDG/Training

Inputs (32)

NameTypeDefaultDescription
modelMODELBase model to return downstream with the latest trained LoRA optionally applied.
dataset_images_dirSTRINGFolder containing your training images, or a parent folder that will be organized into an images subfolder.
workspace_dirSTRINGWorking folder for cache, logs, config files, checkpoints, and training state.
run_nameSTRINGZImageChunkRunName prefix used for the log file.
output_nameSTRINGZImageChunkRunName prefix used for saved LoRA files and state folders.
resolution_widthINT102464–8192Training bucket width written to the musubi dataset config.
resolution_heightINT102464–8192Training bucket height written to the musubi dataset config.
steps_per_runINT2501–100000How many steps to train per run, and also when to save the LoRA/state at the end of that run.
total_target_stepsINT30001–1000000Training stops once the latest saved step reaches this total.
network_dimINT321–2048LoRA rank.
network_alphaINT321–2048LoRA alpha scaling value.
blocks_to_swapINT40–28Higher values reduce VRAM usage but usually slow training.
clear_memory_before_text_encoderBOOLEANtrueTries to unload ComfyUI models and clear VRAM/RAM before text encoder caching.
learning_rate_presetCOMBO1e-4Quick preset for the training learning rate. Choose Custom to use the float input below.
learning_rateFLOAT0.00011e-8–1Custom learning rate used only when the preset is set to Custom.
num_repeatsINT11–1000How many times each image-caption pair is repeated in the dataset.
cache_strategyCOMBOautoAuto builds cache only when needed, Force always rebuilds it, Skip goes straight to training.
copy_latest_to_comfy_lorasBOOLEANtrueCopies the latest Comfy-compatible LoRA into the ComfyUI loras folder after training.
keep_only_comfy_loraBOOLEANfalseIf enabled, deletes the standard .safetensors LoRA files after a matching .comfy.safetensors file exists.
strength_modelFLOAT1.00-100–100Strength used if the node applies the latest LoRA back onto the output model.
create_captionsBOOLEANfalseIf enabled, missing caption txt files are created automatically using the caption text input.
caption_textSTRINGBase caption text used when create_captions is enabled and an image has no caption file.
add_trigger_wordBOOLEANfalseIf enabled, the trigger text is prepended to each caption.
trigger_textSTRINGTrigger word or phrase to prepend to captions when add_trigger_word is enabled.
musubi_rootSTRINGA:/MUSUBI/musubi-tuner-ltx2Root folder of your musubi-tuner-ltx2 install.
zimage_checkpointSTRINGA:/MUSUBI/models/zimage/zimage-base.safetensorsPath to the base Z-Image DiT checkpoint used for caching and training.
vaeSTRINGA:/MUSUBI/models/zimage/vae.safetensorsPath to the Z-Image VAE checkpoint.
text_encoderSTRINGA:/MUSUBI/models/qwen3Path to the Qwen3 text encoder checkpoint or directory.
fp8_baseBOOLEANtrueEnable fp8 base model weights during Z-Image training.
fp8_scaledBOOLEANtrueEnable scaled fp8 weights during Z-Image training. Requires fp8_base.
fp8_llmBOOLEANfalseLoads the text encoder in fp8 mode during caching to reduce VRAM usage.
use_32bit_attentionBOOLEANfalseUse 32-bit precision for attention computations in the Z-Image model.

Outputs (7)

NameTypeDescription
modelMODEL
latest_state_pathSTRING
log_pathSTRING
latest_comfy_lora_pathSTRING
output_nameSTRING
completed_stepsINT
total_target_stepsINT