Skip to content

fix(memflow): snap invalid resolution to nearest multiple of 16 (#931)#932

Open
livepeer-tessa wants to merge 1 commit intomainfrom
fix/931-memflow-resolution-snap
Open

fix(memflow): snap invalid resolution to nearest multiple of 16 (#931)#932
livepeer-tessa wants to merge 1 commit intomainfrom
fix/931-memflow-resolution-snap

Conversation

@livepeer-tessa
Copy link
Copy Markdown
Contributor

Problem

The memflow pipeline crashes with a ValueError when given a resolution that isn't divisible by 16 (e.g. 674×389 from a free-form canvas resize). The pipeline is then marked as failed and the session is unusable.

Observed in prod on 2026-04-13: session 0e48d66d, 4 occurrences.

Fixes #931

Solution

Instead of hard-failing, auto-snap the resolution down to the nearest valid multiple of 16 and log a warning:

WARNING  scope.core.pipelines.utils: Snapping resolution from 674×389 to 672×384 (both dimensions must be divisible by 16)

Changes

  • utils.py: Add snap_to_multiple() helper. Extend validate_resolution() with optional snap=True flag — when set, rounds down and warns instead of raising. Returns (height, width) tuple in all paths (previously returned None).
  • memflow/pipeline.py: Use snap=True so non-standard input resolutions are accepted. Applies the snapped values back to config.height/config.width.
  • test_utils_resolution.py: 11 new unit tests covering both error and snap paths.

Other pipelines unaffected

longlive, reward_forcing, streamdiffusionv2, and krea_realtime_video all call validate_resolution without snap=True and continue to raise on invalid input (no behaviour change).

…ad of hard-failing

Previously, passing a resolution like 674×389 to the memflow pipeline
caused an immediate ValueError and marked the pipeline as failed.

This change:
- Extends validate_resolution() with a snap=True flag that rounds down
  width/height to the nearest valid multiple and logs a warning, instead
  of raising.
- Updates MemFlowPipeline.__init__ to use snap=True so non-standard
  resolutions (common when users resize the canvas freely) are accepted
  gracefully.
- Adds snap_to_multiple() as a standalone helper for reuse.
- Adds 11 unit tests covering both error and snap paths.

Other pipelines that call validate_resolution() are unaffected; they
continue to raise ValueError on invalid input (snap defaults to False).

Fixes #931

Signed-off-by: Tessa (livepeer-tessa) <tessa@livepeer.org>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 13, 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: d17c2997-9be8-4449-a077-7bbdd2b8499e

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
  • Commit unit tests in branch fix/931-memflow-resolution-snap

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions
Copy link
Copy Markdown
Contributor

🚀 fal.ai Preview Deployment

App ID daydream/scope-pr-932--preview
WebSocket wss://fal.run/daydream/scope-pr-932--preview/ws
Commit af7c22d

Livepeer Runner

App ID daydream/scope-livepeer-pr-932--preview
WebSocket wss://fal.run/daydream/scope-livepeer-pr-932--preview/ws
Auth private

Testing Livepeer Mode

SCOPE_CLOUD_MODE=livepeer SCOPE_CLOUD_APP_ID="daydream/scope-livepeer-pr-932--preview/ws" uv run daydream-scope

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.

[fal.ai] memflow pipeline: Invalid resolution 674×389 — width/height must be divisible by 16

1 participant