Nodes/ComfyUI-Viggle-Animate-H3/Viggle Sample Chunk
ComfyUI Node

Viggle Sample Chunk

Samples one chunk, writes it to disk, then lets you decode it — the heart of the crash-safe Viggle loop

By Saganaki22·Created 4 days ago·Updated about 21 hours ago· 71
Viggle Sample Chunk
  • state
  • guider
  • sampler
  • sigmas
  • chunk
  • video_latent
  • filename_prefix
seed0
rerender_chunk0
rerender_seed0

This is the node that makes a long Viggle-Animate render survivable. Viggle Sample Chunk sits inside the pack's disk-checkpoint loop and does exactly one job per call: sample one window of your driving clip, checkpoint the latent to disk before it returns, and hand you the latent plus the loop state so you can decode and save the chunk through your own nodes. If ComfyUI crashes ten minutes into chunk 4, everything before it is already on disk, and re-queuing restores it instead of resampling.

Quick context for the loop newcomers: the pack wraps Viggle-Animate, a 33B finetune of MiniMax-H3's ref2va for character replacement in video (driving clip supplies the motion, a reference still supplies identity, no text prompt). Long clips get chunked into 124-frame windows by the Windowed Conditioning node. The loop - Viggle Chunk Loop Start → this node → VAE Decode → Viggle Chunk Loop End → Viggle Assemble Chunk Latents - renders each chunk, decodes and saves it through your nodes while the next one samples. This node is where the sampling and the checkpoints happen. You place exactly one of them in the graph; the loop's expansion re-runs it per chunk.

How it works

Sample Chunk reads the current window from the loop state, samples it with the same carry mechanics as the single-pass Viggle Chunked Sampler - the previous chunk's overlap is pinned into the new one via a denoise mask - then writes a safetensors checkpoint plus a manifest.json to output/viggle_chunks/<run_name>/ atomically, so a crash never leaves a half-valid file. That happens before the node returns, which is the whole point: even if your decode/save branch dies, the expensive sampling work is already safe. Noise is generated internally from the effective seed; there's no noise input.

It has a read-only live_progress display built in - sampling/restoring → checkpoint saved → decoding/saving → loop completed - updating the same visible node every iteration with no extra wiring. Restart ComfyUI and refresh the browser after updating so the frontend extension loads.

Inputs

  • state - from Loop Start's state output. Carries the plan, run name, resume flag and the loop's position.
  • guider / sampler / sigmas - your usual stack (BasicGuider, KSamplerSelect, a ManualSigmas schedule). Same rules as the single-pass sampler: the guider's positive gets replaced per chunk from the conditioning set; the sigma schedule must end in exactly one 0.0 (the baseline is 1.0, 0.8571428571428571, 0.6, 0.0).
  • seed, plus rerender_chunk and rerender_seed - same semantics as the single-pass sampler. Chunk N uses seed + N − 1; to redo one chunk's motion, set rerender_chunk to its 1-based number and rerender_seed to a new value. That chunk and everything after resamples; everything before restores from disk.

Outputs

  • chunk (VIGGLE_LOOP_STATE) - feed it to Loop End's chunk input. It's the carried state for the next iteration.
  • video_latent (LATENT) - the sampled chunk, ready for a normal VAE Decode in the loop body. Note the loop has no VAE input here; decoding is deliberately your job.
  • filename_prefix (STRING) - a handy save-name prefix built from the run name, chunk number and fingerprint. Wire it to your Video Combine's filename prefix.

Installing and troubleshooting

It's one node in the pack, so install it whole:

cd ComfyUI/custom_nodes
git clone https://github.com/Saganaki22/ComfyUI-Viggle-Animate-H3

or use ComfyUI Manager, restart, refresh the browser. No pip deps; you need current ComfyUI with MiniMax-H3 support plus the model files (pruned ref2va diffusion model, DMD LoRA, frozen text conditioning in models/text_cond/, H3 video VAE).

Two things that read as bugs but aren't. First, checkpoint filenames embed a fingerprint of your sampling graph - including loaders' file paths, sizes and mtimes, and the node code itself - so changing any model file in the same category, or updating the pack, means saved chunks don't match and get resampled under new filenames. Old takes stay on disk; they don't get deleted. Second, if a decode fails after the latent was checkpointed, the checkpoint is still good: fix the decode, re-queue with the same run_name and resume on, and it restores and re-decodes without resampling. The one real memory note: ComfyUI's execution cache can retain each decoded preview (~0.82 GiB per 124-frame 1024×576 chunk), so enable your save node's save_output for durable previews and don't be surprised by RAM creep on long runs.

Categorysampling/viggle/experimental

Inputs (7)

NameTypeDefaultDescription
stateVIGGLE_LOOP_STATE
guiderGUIDERFrom BasicGuider / CFGGuider. Only its model, cfg and negative matter — the positive is replaced per chunk from the cond_set.
samplerSAMPLERFrom KSamplerSelect or RES4LYF — reused for every chunk.
sigmasSIGMASThe step schedule (BasicScheduler etc.) — every chunk runs the identical schedule.
seedINT00–18446744073709550000Base seed. Chunk i renders with seed + i, so the chunks vary independently while staying reproducible.
rerender_chunkINT00–641-based chunk number to change (0 = off). Set a new rerender_seed to regenerate it and the following chunks; earlier chunks reuse cache when available.
rerender_seedINT00–18446744073709550000Seed for the chunk selected by rerender_chunk. Type a new number for a new take.

Outputs (3)

NameTypeDescription
chunkVIGGLE_LOOP_STATE
video_latentLATENT
filename_prefixSTRING