Save Training Dataset
Encode once, then train a dozen times without re-encoding
- latents
- conditioning
Save Training Dataset is the cache in ComfyUI's built-in training pipeline. After Make Training Dataset encodes your images into latents and your captions into conditioning, this node writes the whole thing to disk so you never have to re-run the VAE and CLIP again. Find the right learning rate, keep experimenting with steps and rank, restart the workflow - the encoded dataset loads in seconds instead of minutes.
It's part of ComfyUI core (the training family landed late 2025 and is still experimental), it's an output node with three inputs and no outputs, and it's the least glamorous node in the group. It's also the one that makes iterative training tolerable.
How it works
It takes your two parallel lists - latents and conditioning - validates that they're the same length, then writes them out as sharded files. Each shard is a torch.save of a dict holding a slice of the dataset: shard_0000.pkl, shard_0001.pkl, and so on, plus a small metadata.json recording sample count, shard count, and shard size. Where do they land? In a dedicated datasets folder under your ComfyUI install - ComfyUI/datasets/<folder_name>/, not your output directory. That dedicated folder is a deliberate security choice from a 2026 hardening pass, so a folder_name can't point the node at arbitrary paths on your disk.
The inputs
latentsandconditioning- the outputs of Make Training Dataset, straight through. Lengths must match or it errors out rather than corrupting a file.folder_name- where to save, defaulttraining_dataset. Subfolders are allowed, soproject/run1is fine and keeps multiple experiments separate.shard_size- samples per shard file, default 1000. Leave it alone unless your dataset is huge; sharding exists so you don't get one giant unwieldy file, not so you can micro-tune it.
Where people get confused
- It's not image files. The shards are pickled tensors, not a browsable photo folder. Open it in Load Training Dataset, not in a file manager. If you want to inspect or edit individual training images, do that before encoding.
- Wrong folder hunt. People look in
output/because the tooltip in some versions says "output directory". Current ComfyUI saves toComfyUI/datasets/. If you can't find your dataset, that's where it is. - The dataset is baked. Latents carry the signature of the VAE that encoded them. Save once, and load it only into the same model family - a cached Z-Image dataset won't train a Flux LoRA no matter how many times you restart.
- Disk, not RAM. A few thousand latent tensors are small individually but they add up. If you're training on a huge set, keep
shard_sizesane and expect a real footprint.
Why bother
Dataset encoding is the boring repeated work in every training session - identical VAE passes, identical CLIP tokenization, every single time. Caching turns "tweak the trainer, rerun everything" into "tweak the trainer, load the cache." It also means you can prepare a dataset once, share it with someone, and both of you train against the exact same latents - which is genuinely useful when comparing runs. The workflow is simply:
Make Training Dataset → Save Training Dataset (first run)
Load Training Dataset → Train LoRA (every run after)
It's not a node you'll think about much. That's the point - it's the plumbing that lets you spend your time on the parts that actually matter: the captions, the settings, and the loss curve.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| latents | LATENT | List of latent dicts from MakeTrainingDataset. | |
| conditioning | CONDITIONING | List of conditioning lists from MakeTrainingDataset. | |
| folder_name | STRING | training_dataset | Name of folder to save the dataset into, inside the datasets directory. Subfolders like 'project/run1' are allowed. |
| shard_size | INT | 10001–100000 | Number of samples per shard file. |
Outputs (0)
No outputs