The max_batch setting was being ignored with anima previews, had a LLM debug and it fix it, it spat out this:
Bug: max_batch ignored for video model latent formats when video_max_frames is -1
Description
The max_batch setting in betterTaesdPreviews (or previews) is ignored when using a video model latent format (e.g., wan21), even when doing batch image generation (not video). The preview always shows all batch items regardless of max_batch.
Root Cause
In py/better_previews/previewer.py:calculate_indexes(), when is_video=True (5D latent tensor), the code uses SETTINGS.btp_video_max_frames as the limit instead of self.max_batch_preview:
def calculate_indexes(self, batch_size: int, *, is_video=False) -> range:
max_batch = (
SETTINGS.btp_video_max_frames if is_video else self.max_batch_preview
)
if max_batch < 0:
return range(batch_size) # ← video_max_frames=-1 returns ALL items
...
When video_max_frames is -1 (default = unlimited), the condition max_batch < 0 is True, so range(batch_size) is returned — showing all batch items regardless of max_batch.
Steps to Reproduce
- Use any video model latent format (e.g., WAN21, HunyuanVideo, etc.) — the latent is 5D
[batch, channels, frames, H, W]
- Set
max_batch: 4 (or 2) in blehconfig.yaml
- Leave
video_max_frames: -1 (the default, unlimited)
- Set
batch_size: 5 in the KSampler
- Observe: the live preview shows 5 items in the grid, ignoring
max_batch
Expected Behavior
When video_max_frames is -1 (unlimited), the batch limit should fall back to max_batch_preview. That is, calculate_indexes should use max_batch_preview to limit batch items when video_max_frames doesn't provide a limit.
Proposed Fix
In calculate_indexes, when max_batch < 0 and is_video=True, fall back to self.max_batch_preview instead of returning all items:
def calculate_indexes(self, batch_size: int, *, is_video=False) -> range:
max_batch = (
SETTINGS.btp_video_max_frames if is_video else self.max_batch_preview
)
if max_batch < 0:
if is_video:
max_batch = self.max_batch_preview # fall back to batch limit
else:
return range(batch_size)
if not self.maxed_batch_step_mode:
return range(min(max_batch, batch_size))
return range(
0,
batch_size,
math.ceil(batch_size / max_batch),
)[:max_batch]
Workaround
Set video_max_frames to a specific value (e.g., video_max_frames: 4) instead of -1. This forces a limit on the frame/batch dimension for video models. However, this conflates frame limiting with batch limiting, which may not be desired.
The max_batch setting was being ignored with anima previews, had a LLM debug and it fix it, it spat out this:
Bug:
max_batchignored for video model latent formats whenvideo_max_framesis-1Description
The
max_batchsetting inbetterTaesdPreviews(orpreviews) is ignored when using a video model latent format (e.g.,wan21), even when doing batch image generation (not video). The preview always shows all batch items regardless ofmax_batch.Root Cause
In
py/better_previews/previewer.py:calculate_indexes(), whenis_video=True(5D latent tensor), the code usesSETTINGS.btp_video_max_framesas the limit instead ofself.max_batch_preview:When
video_max_framesis-1(default = unlimited), the conditionmax_batch < 0is True, sorange(batch_size)is returned — showing all batch items regardless ofmax_batch.Steps to Reproduce
[batch, channels, frames, H, W]max_batch: 4(or 2) inblehconfig.yamlvideo_max_frames: -1(the default, unlimited)batch_size: 5in the KSamplermax_batchExpected Behavior
When
video_max_framesis-1(unlimited), the batch limit should fall back tomax_batch_preview. That is,calculate_indexesshould usemax_batch_previewto limit batch items whenvideo_max_framesdoesn't provide a limit.Proposed Fix
In
calculate_indexes, whenmax_batch < 0andis_video=True, fall back toself.max_batch_previewinstead of returning all items:Workaround
Set
video_max_framesto a specific value (e.g.,video_max_frames: 4) instead of-1. This forces a limit on the frame/batch dimension for video models. However, this conflates frame limiting with batch limiting, which may not be desired.