Skip to content

fix: pad vace_input_frames to min spatial size to avoid 3×3 kernel underflow#696

Open
livepeer-tessa wants to merge 1 commit intomainfrom
fix/vace-spatial-kernel-underflow-557
Open

fix: pad vace_input_frames to min spatial size to avoid 3×3 kernel underflow#696
livepeer-tessa wants to merge 1 commit intomainfrom
fix/vace-spatial-kernel-underflow-557

Conversation

@livepeer-tessa
Copy link
Contributor

Summary

Fixes #557

Guards VaceEncodingBlock._encode_with_conditioning against inputs whose spatial dimensions are below the WAN VAE's 3×3 convolution minimum — the spatial analogue of the temporal guard in PR #674 / issue #673.

Root Cause

The WAN VAE encoder has a 3×3 spatial convolution kernel in its first layer. When vace_input_frames has height or width < 3 pixels, PyTorch raises:

RuntimeError: Calculated padded input size per channel: (2 x 513).
Kernel size: (3 x 3). Kernel size can't be greater than actual input size

Observed in Prod (2026-03-15)

Fix

In _encode_with_conditioning, after extracting (batch, channels, frames, height, width) from vace_input_frames:

  1. If height < 3 or width < 3, pad to the minimum safe size using F.pad
  2. vace_input_masks (if provided) is padded to match
  3. block_state.height/width are updated so the downstream resolution assertion still passes
  4. A WARNING is emitted so the unusual input remains visible in logs

Testing

The fix is a pure defensive guard — normal inputs (height ≥ 3, width ≥ 3) are completely unaffected. Abnormal inputs (< 3 on either axis) will now warn instead of crash.

Related: PR #674 (temporal kernel guard, same block)

…derflow

The WAN VAE encoder contains a 3×3 spatial convolution kernel.  When
the input chunk has spatial dimensions < 3 on either axis the forward
pass raises:

  RuntimeError: Calculated padded input size per channel: (2 x 513).
  Kernel size: (3 x 3). Kernel size can't be greater than actual input size

Observed in prod logs (2026-03-15, 10:48–10:59 UTC) on krea-realtime-video
pipeline, fal.ai job 5193400c-da0f-4eef-8bdd-dd0fdd26c1db: 2 372 errors
over 11 minutes (~4 errors/second) from an input with height=2 pixels.

Fix: in _encode_with_conditioning, detect when height or width < 3 and
pad to the minimum safe size using F.pad.  The corresponding masks tensor
is also padded to keep shapes consistent.  block_state.height/width are
updated so the downstream resolution check still passes.  A WARNING is
emitted so the unusual input remains visible in logs without a crash.

This is the spatial analogue of the 3×1×1 temporal kernel guard (issue #673,
PR #674).

Fixes #557
Signed-off-by: livepeer-robot <robot@livepeer.org>
@coderabbitai
Copy link

coderabbitai bot commented Mar 15, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8588b9f9-cc03-445d-b85a-4a084dd85548

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/vace-spatial-kernel-underflow-557
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

🚀 fal.ai Preview Deployment

App ID daydream/scope-pr-696--preview
WebSocket wss://fal.run/daydream/scope-pr-696--preview/ws
Commit 0d2e60a

Testing

Connect to this preview deployment by running this on your branch:

uv run build && SCOPE_CLOUD_APP_ID="daydream/scope-pr-696--preview/ws" uv run daydream-scope

🧪 E2E tests will run automatically against this deployment.

@github-actions
Copy link
Contributor

✅ E2E Tests passed

Status passed
fal App daydream/scope-pr-696--preview
Run View logs

Test Artifacts

Check the workflow run for screenshots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VaceEncodingBlock fails on extremely narrow input images (kernel size > input size)

1 participant