Budget-Constrained Step-Level Diffusion Caching#4
Draft
remyx-ai[bot] wants to merge 1 commit into
Draft
Conversation
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.
Why this paper for this team
The
diffusersteam's work on 'Add LLaDA2 Discrete Diffusion Pipeline' and broad support for diffusion models makes inference efficiency a continuous priority. This paper directly bridges with the 'Model Efficiency' research interest by introducing BudCache, a method that optimizes caching policies to preserve output quality under a fixed compute budget. This is highly relevant fordiffusersas it enables granular control over inference cost for iterative denoising processes, ensuring optimal performance for large models like Ideogram 4 or Cosmos 3 without sacrificing quality. It complements the existing performance and quantization efforts by offering a principled approach to resource allocation.Why this candidate (selected from the lookback pool)
BudCache's contribution (a budget-aware step-level caching schedule that decides per-denoising-step whether to reuse cached activations) maps directly onto the existing caching-hook contract: every sibling hook (FasterCache, MagCache, TaylorSeerCache) already implements exactly this skip-or-compute decision over transformer blocks via ModelHook, so BudCache adds a new XxxConfig+apply_xxx pair wired into hooks/init.py with no contract changes. It is the only caching-family candidate with real, permissively-licensed (Apache-2.0) reference code, making it a clean drop-in addition where ReCache [10] (license missing, compat 0.00) and the no-code budget-cache abstracts cannot anchor an implementation. The repo's 'Deepening Focus on Performance and Quantization' direction makes inference-cost control directly relevant.
License & code availability
🟢 Permissive license — safe to adopt.
Apache-2.0(class:permissive, compat: 1.00, source:github)Suggested experiment
Implement BudCache's Simulated Annealing with Hill Climbing for step selection within a diffusion pipeline in
diffusers(e.g., FLUX.1-dev or a widely used DiT). Evaluate the generation quality (e.g., LPIPS) under varying fixed compute budgets, comparing its performance against existing heuristic caching baselines provided by the library.What this PR delivers
Call site:
Public package API: exported viasrc/diffusers/init.pyandsrc/diffusers/hooks/init.pyasapply_budget_cache/BudgetCacheConfig, the same surface through which sibling caching hooks (apply_faster_cache,apply_first_block_cache, etc.) are reached.Delivers (from the paper):
BudgetCacheConfig+apply_budget_cachewired into the public package namespace (diffusers.__init__,hooks/__init__.py, dummy objects), matching the existingFasterCache/TaylorSeerCacheconfig+apply pattern.search_cache_schedulefixes acompute_budgetin advance and searches for the compute/skip schedule that best preserves output, combining Simulated Annealing (budget-preserving swaps under a cooling temperature) with deterministic Hill Climbing local refinement over a surrogate trajectory-error cost — deterministic given a seed, run fully offline so inference has no thresholding/search overhead.ModelHooks (head/tail/block hooks +BudgetCacheState): on scheduled-compute steps blocks run normally and the tail caches the input→output residual; on skipped steps the head reuses the cached residual (with shape-alignment fallbacks), wired across a module's transformer blocks byapply_budget_cache._uniform_schedulebudget-respecting heuristic baseline used when nostep_errorsprofile is supplied, plus config validation (budget range, first-step-always-computes, schedule length).Intentionally out of scope (not needed for this contribution):
step_errors) from a real model/calibration run is left to the caller; the search consumes a user-provided profile (e.g. MagCache-style residual ratios) or falls back to the uniform heuristic._schedule_costis a staleness-weighted heuristic rather than the paper's exact trajectory-error objective (offline search infra to evaluate true final-output error is out of scope).This delivers BudCache's central result — a budget-first (rather than threshold-first) step-level cache policy found by an offline SA+Hill-Climbing search and replayed at inference with zero online overhead — packaged as a first-class public diffusers caching hook (
BudgetCacheConfig/apply_budget_cache) that mirrors the existingapply_faster_cache-style API exactly. Like every sibling caching hook, it is user-invoked through the public package namespace rather than auto-called by a pipeline, so no pre-existing pipeline auto-exercises it, but it is properly wired into the product's public optimization surface (not just reachable from tests). Intentionally scoped out as unnecessary for that core value: the paper's tight-budget schedule alignment, automatic step-error calibration, and the FLUX/Wan quality benchmarks — each of which needs model weights or scheduler-coupling infra not hosted in-tree.Test results
ℹ️ Tests could not run in CI — the runner lacks this repo's dependencies (a collection/import error, not a code failure). Run the suite locally to validate.
Opened by the Remyx Recommendation orchestrator.