{{ message }}
Repository navigation
[Community] Add CachedSearch script: cheaper best-of-N for video pipelines - #14735
Merged
yiyixuxu merged 1 commit intoSep 9, 2026
Merged
Conversation
…lines Test-time search where every candidate runs under FirstBlockCache and only the winning seed is regenerated at full compute. Paper: https://huggingface.co/papers/2607.23159
Contributor
Contributor
Author
|
Self-review notes and test log, per the contribution guide. Test CPU check with the tiny Wan components from video, seed, scores = cached_search(pipe, prompt, verifier, n=3, threshold=0.5, num_inference_steps=12, **kw)
ref = pipe(prompt=prompt, num_inference_steps=12, generator=torch.Generator().manual_seed(seed), **kw).frames[0]Output: Self-review notes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #14745
What does this PR do?
Adds a community script, CachedSearch: cheaper best-of-N for video pipelines, to
examples/community/README_community_scripts.md.Best-of-N search over seeds is the simplest way to spend more compute on a video model, and it costs N full rollouts per delivered video. CachedSearch (code) generates every candidate with a training-free cache enabled, lets the verifier rank the cached drafts, and regenerates only the winning seed with caching off. Sampling is seed-deterministic, so the delivered video is exactly the full-compute sample; caching only affects which candidate is chosen. On Wan2.1-1.3B the paper measures 94.7% of best-of-8's gain at 63% of its cost.
The script is about 35 lines on top of Diffusers' own
FirstBlockCacheConfig(enable_cache/disable_cache), takes any pipeline whose denoiser supports caching (Wan, HunyuanVideo, LTX-Video, CogVideoX, Flux), and any verifier callable(frames, prompt) -> float. The example uses Wan2.1-1.3B with an ImageReward verifier, the scorer the paper uses.Checked on CPU with the tiny Wan components from
tests/pipelines/wan: drafts skip most blocks under the cache, the committed video is bit-identical to a plain run with the winning seed, and the cache hooks are removed afterwards.Before submitting
Who can review?
@asomoza @sayakpaul