Nodes/ComfyUI/Plot Loss Graph
ComfyUI Node Runs on cloud

Plot Loss Graph

The boring node that tells you if training actually worked

By Comfy-Org·Created 4 years ago·Updated about 23 hours ago· 129,495
Plot Loss Graph
  • loss
    filename_prefixloss_graph

    Plot Loss Graph is the node nobody gets excited about and everybody needs. Training a LoRA is a black box until it isn't - you set the knobs, wait, and hope. This node takes the loss_map output from Train LoRA and draws the training loss as a line graph, shown to you as a preview image the moment the run finishes. It's the difference between guessing and knowing whether that run was learning anything.

    It ships with ComfyUI core alongside the rest of the training nodes. It's an output node: two inputs, no outputs, and it renders the graph as a UI preview rather than saving a file to your output directory.

    How it works

    Train LoRA records the loss value after every training step into the LOSS_MAP it hands you. This node takes that list, normalizes it (min–max scaling), and plots it as a blue line on an 800×480 canvas - axes labeled Loss and Steps, with the min and max loss values printed on the left edge. Simple, readable, zero dependencies, done with PIL. The result is pushed to the frontend as a preview image, so it appears in the UI right after training completes.

    The inputs

    • loss - the loss_map output from Train LoRA. That's the whole feed; no loss_map, no graph.
    • filename_prefix - default loss_graph. The name suggests where a saved image would go, but today the graph is rendered as a temp-folder preview rather than a permanent file. If you want it saved, grab the preview from the UI.

    Reading the graph - the part that matters

    The shape is the story, and it's worth knowing what you're looking at:

    • Falling curve - training is working. The model is getting better at predicting the clean latent from noise.
    • Falls fast then plateaus - normal. That's most of training.
    • Bounces around and never descends - learning rate too high (or, on some modern models, too high for the batch size). Drop it.
    • Flat from step one - either the LR is so low nothing happens, or something upstream is broken: mismatched latents and conditioning, wrong dtype, a dataset that doesn't match the model.
    • Climbing at the end - overfitting. The KB's advice applies: fewer steps, lower LR, or a better-curated set.

    One honest caveat: the loss number itself is not comparable across models. MSE on an x0 prediction for a 16-channel Z-Image latent means nothing next to the same metric on SDXL. Don't obsess over the absolute values - watch the shape, and compare runs you made under identical conditions.

    The workflow

    Train LoRA ──loss_map──→ Plot Loss Graph
    

    That's the whole wiring. Run it after every training session, keep the graph, and when a run produces a great LoRA you'll have a reference curve for what "good" looked like. When it produces a disaster, you'll be able to see exactly when the training went off the rails instead of re-running it blind. That's a surprisingly large chunk of the learning curve in LoRA training, automated for you by one boring little node.

    Categorymodel/training

    Inputs (2)

    NameTypeDefaultDescription
    lossLOSS_MAPLoss map from training node.
    filename_prefixSTRINGloss_graphPrefix for the saved loss graph image.

    Outputs (0)

    No outputs