[bugfix]: bound WanCausalModel num_frames_per_block override to <= 3

The constructor override only checked >= 1, bypassing the <= 3 limit the
config path enforces in CausalWanTransformer3DModel. Apply the same upper
bound with a clear error message.
This commit is contained in:
SolitaryThinker
2026-07-05 15:01:25 -07:00
parent fda43fc610
commit 4d8713f6e4
+8 -3
View File
@@ -64,9 +64,14 @@ class WanCausalModel(WanModel, CausalModelBase):
self._streaming_caches: (dict[tuple[int, str], _StreamingCaches]) = {}
if num_frames_per_block is not None:
if int(num_frames_per_block) < 1:
raise ValueError("num_frames_per_block must be >= 1")
self.transformer.num_frame_per_block = int(num_frames_per_block)
num_frames_per_block = int(num_frames_per_block)
if not 1 <= num_frames_per_block <= 3:
# Same bound as CausalWanTransformer3DModel's config path
# (assert num_frame_per_block <= 3); this override must not
# bypass it.
raise ValueError("num_frames_per_block must be between 1 and 3, "
f"got {num_frames_per_block}")
self.transformer.num_frame_per_block = num_frames_per_block
# --- CausalModelBase override: clear_caches ---
def clear_caches(