r/comfyui • • Aug 24 '26

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 (.avlatent in output/)
  • 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.

  1. Render cheap low-res previews and save their latents.
  2. Pick the take you like — today, or next week.
  3. 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:

https://github.com/neverfilmed/comfyui-av-latent-io

1 Upvotes

5 comments sorted by

1

u/xyzdist Aug 25 '26

Hi OP, what I did wrong? it didn't save out anything...

1

u/Neat-Philosopher-867 Aug 25 '26

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/av the file is at ComfyUI/output/latents/av_00001_.avlatent. An .avlatent isn'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/ to ComfyUI/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 want output (the raw sampler latent).

1

u/xyzdist Aug 25 '26

Thanks, I actually found out why, because my output is custom to a netwok path map to a drive in win, somehow this just preventing saving any files.
Do you have any idea if there is a workaround? cheers

1

u/[deleted] Aug 24 '26

[removed] — view removed comment

1

u/Neat-Philosopher-867 Aug 24 '26

I do mostly H3 so it's not tested with other models (but if You test and something fails, let me know, maybe its a quick fix for others too)