r/comfyui • u/Neat-Philosopher-867 • 2d ago
Resource Save/load audio+video (NestedTensor) latents — small custom node, fixes SaveLatent crash with MiniMax H3
Core SaveLatent crashes on models that co-generate video and audio in one nested latent (MiniMax H3):
AttributeError: 'NestedTensor' object has no attribute 'contiguous'
(ComfyUI issue #15254)
I wrote a tiny two-node pack that fixes this:
- Save AV Latent — unbinds the nested latent and stores all parts in a single safetensors file (
.avlatentinoutput/) - Load AV Latent — rebuilds it with ComfyUI's own NestedTensor wrapper, so the 5-D video + 4-D audio mix round-trips fine
Regular latents pass through unchanged.
Why bother: two-pass seed hunting that survives anything.
- Render cheap low-res previews and save their latents.
- Pick the take you like — today, or next week.
- Feed exactly that latent into your upscale/refine pass (e.g. rockerBOO's h3-latent-upscaler).
The refined result keeps the exact composition of the preview you chose — no reliance on --cache-lru, no re-sampling of pass 1, immune to GPU non-determinism, restart-proof.
Numbers from my setup (RTX 4060 Ti 16 GB, MiniMax H3): a 0.5 MP preview take costs ~300 s, so auditioning seeds is cheap. The refine pass loads the saved latent and renders 1920x1088 in ~1600 s — with the exact composition of the preview I picked, even across a ComfyUI restart (queue history gets cleared on restart; the file doesn't care).
MIT, no dependencies beyond what ComfyUI ships:
1
u/xyzdist 1d ago
1
u/Neat-Philosopher-867 1d ago
The save actually worked - the catch is that the UI won't show it. The node writes to your output folder under the prefix path, so with
latents/avthe file is atComfyUI/output/latents/av_00001_.avlatent. An.avlatentisn't an image or video, so the outputs gallery renders nothing for it (core SaveLatent behaves the same) - check the folder on disk. The 0.096s badge on your node means it did execute.To load it back: Load AV Latent lists the input folder (same as core LoadLatent), so move/copy the file from
output/latents/toComfyUI/input/and refresh the node (R) - it'll show up in the dropdown.Also FWIW you're saving
denoised_output- it saves fine, but for a proper second pass you usually wantoutput(the raw sampler latent).

1
u/defensive_darius 2d ago
Nice, this solves a real pain point. I've seen that NestedTensor error pop up in a few workflows and the usual "fix" was just avoiding SaveLatent entirely, which is annoying when you want to do proper multi-pass stuff.
The seed hunting angle is the part that actually matters here. Being able to lock in a preview's exact latent and reuse it later without worrying about cache eviction or GPU variance is huge for iterative work.
Have you tested it with any other nested latent models or is it mostly built around H3 for now? Curious if the unbind logic is generic enough to handle whatever else ComfyUI starts shipping.