YuE2 LoRA Trainer
Teach ComfyUI's music model your sound (and accept what it can't learn)
- dataset
- lora_path
- training_log
What this node is for
Music generation in ComfyUI has one obvious trainable option - ACE-Step, which shipped LoRA training with v1.5 and runs on a 4GB card - and one stubbornly interesting one: YuE2, the 3B successor to the "Suno at home" model that got the whole idea of local song generation taken seriously. ACE-Step is the polished, instrumentals-are-great option. YuE2 is the one people reach for when they want vocals and song structure. Neither had a ComfyUI trainer until this pack.
YuE2LoRATrainer is that trainer. Feed it a dataset built from a folder of your own tracks, give it a trigger word like mystyle, queue the prompt, and it writes <lora_name>.safetensors into models/loras in native ComfyUI format - loaded with the stock LoraLoaderModelOnly on the native YuE2 checkpoint. No conversion step, no A1111 detour.
The honest framing: this is experimental software from a small utility-node author (Starnodes, of helper-nodes and Image Manager). Treat your first run as a test, not a production job.
The mechanism, in one paragraph
YuE2 has three parts: a 2.2B AR language model that plans the song and writes semantic tokens, a 1.5B NAR flow-matching branch that renders 64-channel VAE latents into audio, and a 48 kHz stereo VAE. This trainer adapts the NAR branch only. The composer stays frozen - m-a-p never released an audio→token encoder or training code - so what you get is a style/instrumentation/timbre LoRA, not a voice clone. The README is blunt that voice cloning still doesn't work. Training uses the released flow-matching objective, conditioned on the checkpoint's own text prefix (trigger_word, caption).
Inputs you actually touch
Required, all of them - there's nothing optional:
dataset- theYUE2_TRAIN_DATASETfromYuE2TrainingDataset. This is the only wire in.checkpoint- a native YuE2 all-in-one file frommodels/checkpoints. Pick the same file you generate with. Non-YuE2 files and the INT8/quantized variant are rejected outright.trigger_word- defaultmystyle. It goes at the start of your style prompt at generation time.steps(3000) andlearning_rate(1e-4) - the two dials that decide whether the LoRA does anything. Rank 32 / alpha 32 is the tuned default and you can leave it.lora_name- writesmodels/loras/<lora_name>.safetensors, plus a<lora_name>_raw.safetensorssibling when EMA is on.
The rest have defaults worth not fiddling with: lr_scheduler = cosine, ema_decay = 0.999, t_sampling = logit_normal, max_grad_norm = 1.0, warmup_steps = 50, caption_dropout = 0.1, grad_accum = 1, target_preset = nar_attn_mlp. Two exceptions: flip optimizer to adamw_8bit if you're tight on VRAM, and set save_every if you want intermediate checkpoints to A/B. And leave EMA on - the main file gets the smoothed weights, the _raw sibling gets the noisy ones, and that pairing is what removes most run-to-run variance.
Outputs: lora_path (STRING - the file you just wrote) and training_log, which is the wire into YuE2TrainingCurve.
Installing
ComfyUI Manager, search ComfyUI-YuE2-Trainer, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Starnodes2024/ComfyUI-YuE2-Trainer.git
python_embeded/python.exe -m pip install -r ComfyUI-YuE2-Trainer/requirements.txt
Two small deps and nothing exotic: soundfile (audio fallback when torchaudio can't decode a file) and matplotlib (curve node only). The official m-a-p inference code is bundled, so there's no second pack to install.
The model: one file, yue2_3b_bf16.safetensors (~7.8 GB) from Comfy-Org/YuE2, into ComfyUI/models/checkpoints/. One download covers training and generation. Use bf16, not the INT8 repack - quantized weights can't be trained. Then restart ComfyUI; three nodes appear under YuE2/Training.
Where people get burned
- VRAM. 24 GB recommended. The node unloads your other ComfyUI models before training starts - deliberate, one training run owns the GPU. Out of memory? Lower
clip_secondsin the dataset node first, then tryadamw_8bit. - Nonsense checkpoint errors. Pointing
checkpointat a GGUF/INT8 file or a non-YuE2 model gives you "not a native YuE2 all-in-one checkpoint" - a key-signature check, not a bad download. An emptytrigger_wordand path characters inlora_namealso raise immediately; those are guards, not bugs. - Overfitting looks like success. Muffled, repetitive output that weakly copies your training tracks means too many steps or too high an LR - drop to 5e-5 or cut steps. If the trigger has no audible effect at all, go the other way (2e-4).
- Speed expectations. On a 4090, 10-second clips run ~1–3 s/step, so 1000 steps is 25–50 minutes. A 3000-step run is an evening.
And the one nobody reads: YuE2 weights are CC BY-NC 4.0. Your LoRA is a derivative, and so is anything you generate with it. Non-commercial, attribution required.
Is it the one to reach for?
If you want local, trainable music with a 4 GB floor, ACE-Step is still the answer. Reach for YuE2LoRATrainer when you specifically want YuE2's vocal-forward songwriting and you're willing to babysit an experimental trainer with a reconstructed objective, no caption files, and a 24 GB appetite. Set the trigger word at the start of the style prompt and keep cot = off when you generate - that matches the text-only regime the LoRA was trained in.
Inputs (22)
| Name | Type | Default | Description |
|---|---|---|---|
| dataset | YUE2_TRAIN_DATASET | — | |
| checkpoint | COMBO | Native YuE2 all-in-one checkpoint (models/checkpoints) the LoRA is trained on — pick the same file you generate with. | |
| trigger_word | STRING | mystyle | Token/word placed at the start of the style prompt. Use it in your style prompt at generation time (cot=off works best). |
| steps | INT | 30001–100000 | Total training steps (one random clip per step). 3000 is a good default for 5-30 songs; fewer steps = weaker style, more = risk of overfitting (muffled/repetitive output). |
| learning_rate | FLOAT | 0.00011e-7–0.01 | AdamW learning rate. 1e-4 works well for rank 16-64. If the LoRA has no audible effect, try 2e-4; if it overfits, try 5e-5. |
| rank | INT | 321–256 | LoRA rank (adapter capacity). 32 is the recommended default; lower = smaller file/less detail, higher = more capacity but easier to overfit. |
| alpha | FLOAT | 32.00.1–512 | LoRA alpha (scaling). Keep equal to rank (scaling = 1.0) unless you know you want a different baked-in strength. |
| lora_dropout | FLOAT | 0.000–0.9 | Dropout on the LoRA input. 0.0 is usually fine; try 0.05-0.1 only if the LoRA overfits on few songs. |
| target_preset | COMBO | Which NAR layers get LoRA. nar_attn_mlp is the recommended default; ..._proj also adapts the latent projections (more VRAM/params). | |
| lora_name | STRING | yue2_mystyle | Output file name (<name>.safetensors) written into models/loras. With EMA on, <name>_raw.safetensors (non-EMA) is saved too. |
| seed | INT | 12340–9223372036854776000 | Random seed for clip choice, noise and timestep sampling. Change it (or set to randomize) for a different training run. |
| optimizer | COMBO | adamw_8bit (bitsandbytes) saves VRAM; falls back to adamw if unavailable. | |
| lr_scheduler | COMBO | cosine (recommended): fades the learning rate to 0 over the run — more stable results. constant: keeps the full LR until the end. | |
| warmup_steps | INT | 500–10000 | Linearly ramp the LR from 0 over the first N steps. 50 is a safe default; 0 disables warmup. |
| grad_accum | INT | 11–64 | Gradient accumulation steps (effective batch = accum x 1 clip). |
| caption_dropout | FLOAT | 0.100–0.9 | Chance per step to train without trigger/caption (keeps the base style reachable). |
| t_sampling | COMBO | Timestep sampling for flow matching. logit_normal (recommended) emphasizes mid-noise levels; uniform spreads evenly. | |
| max_grad_norm | FLOAT | 1.000.01–100 | Gradient clipping threshold. 1.0 prevents loss spikes from destabilizing the LoRA; rarely needs changing. |
| log_every | INT | 101–1000 | Print the averaged loss to the console / training_log every N steps. |
| save_every | INT | 00–100000 | Save an intermediate LoRA every N steps (0 = only the final one). |
| ema_decay | FLOAT | 0.99900–0.9999 | EMA (smoothed) LoRA weights — strongly recommended, fixes 'hit and miss' results. The main file uses EMA weights; the raw copy is saved as <name>_raw.safetensors. 0 disables EMA. |
| live_curve | BOOLEAN | true | Update a live loss/LR chart in the YuE2 Training Curve node while training runs (needs matplotlib; auto-disables with a log note if unavailable). No effect on training itself. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| lora_path | STRING | — |
| training_log | STRING | — |