TL;DR
Generating high-resolution images and videos with modern Flow Matching models is painfully slow because they spend just as much effort computing simple, static backgrounds as they do intricate, dynamic foregrounds. CUBIC speeds up these models by ~2.5×—without any retraining—by measuring the geometric "curvature" of the generation path on the fly, safely coasting on cached calculations in smooth regions while saving fresh compute for areas taking sharp turns.
What Problem Does This Paper Address?
If you have generated an image with Flux.1 or a video with Wan2.1 lately, you are watching Flow Matching (FM) in action. Unlike older diffusion models that slowly chip away at random noise, Flow Matching learns a continuous velocity field—a set of directional arrows—that transports random noise along a smooth trajectory into a crisp image or video using an Ordinary Differential Equation (ODE) solver.
Because these models rely on Diffusion Transformers (DiTs) with full attention over massive sequences of tokens, they are notoriously slow (generating a single 5-second clip on HunyuanVideo can eat up nearly an hour on an NVIDIA A100 GPU).
A popular training-free shortcut is feature caching: reusing intermediate calculations across adjacent generation steps rather than recomputing everything from scratch. However, existing caching methods hit two walls:
- The Granularity Dilemma: Skipping entire steps or layers ignores the fact that flat backgrounds converge much faster than detailed subjects, leading to blurry artifacts. Yet caching individual tokens fragments GPU memory access, eating up the speedup in system overhead.
- Blind Heuristics: Existing methods rely on hand-tuned, model-specific rules rather than a mathematical understanding of how much error caching actually introduces.
Methods
The authors reframe caching geometrically: reusing a velocity calculation for $\tau$ steps is mathematically identical to taking a $\tau$-times larger step in your ODE solver. If a token's trajectory is a dead-straight line, you can take huge steps (heavy caching) with zero error. If the trajectory curves sharply, you need tiny steps (frequent updates).
CUBIC turns this insight into an anchor-selective inference loop that alternates between two phases:
- Anchor Steps (The Brain): Periodically, CUBIC runs a full forward pass to refresh all tokens and plan the next caching schedule:
- Lightweight Curvature Proxy: Computing true mathematical curvature requires a massive Jacobian matrix—a total non-starter at runtime. Instead, CUBIC projects where each token is headed (its predicted final endpoint) and measures how much that prediction drifts between anchor steps via simple subtraction. Zero drift means a straight line; big drift means high curvature.
- Adaptive Block Partitioning: Rather than scheduling individual tokens, CUBIC groups neighboring tokens with similar curvature into rectangular blocks, preserving spatial locality and GPU efficiency.
- Closed-Form Optimization: Using a derived truncation error bound (which scales linearly with curvature $\kappa$ and quadratically with interval $\tau^2$), CUBIC uses Lagrange multipliers to allocate an exact update interval to each block ($\tau_b^\star \propto \kappa_b^{-2/5}$) to hit a user-specified speedup target.
- Selective Steps (The Muscle): Between anchors, a sparse execution engine computes only the active blocks scheduled for an update. Frozen tokens skip the heavy transformer math. To prevent active tokens from losing visual context, their attention layers query a full Key/Value (KV) sequence reconstructed from cached frozen tokens, updating active KV entries dynamically in-place.
Datasets
Because CUBIC is completely training-free, no training datasets are used. For evaluation, the authors use three established benchmarks (no new datasets are introduced):
- t2i-diversity-eval for text-to-image generation (on Flux-1-dev).
- PIE-Bench++ for instruction-guided image editing (on FireRed-Image-Edit-1.0).
- VBench for text-to-video generation (on Wan2.1-T2V-1.3B).
Key Insights and Ideas
- Algebra Beats Calculus at Runtime: Replacing exact auto-diff Jacobian curvature with "endpoint prediction drift" cuts monitoring overhead on Flux from 603.9 ms down to 1.64 ms—over two orders of magnitude faster—while exhibiting a 0.931 log-correlation with true curvature.
- Why Finer Granularity Can Hurt Quality: Surprisingly, scheduling caches per-token actually degrades image quality compared to block-wise scheduling (worsening FID from 37.5 to 57.4). Neighboring tokens attend heavily to one another; if adjacent tokens hold cached Keys and Values from different timesteps, that temporal mismatch corrupts representations across layers. Keeping neighbors on the same block schedule fixes both memory fragmentation and local consistency.
- Block Size Cancels Out: When solving the compute-budget optimization, a block's token count weights both the total error and the compute cost—meaning spatial size neatly cancels out! Update frequency depends purely on curvature.
Key Results
Tested on NVIDIA H100 GPUs against leading training-free caching baselines (PAB, TeaCache, ToCa, and TaylorSeer), CUBIC consistently dominates the quality-efficiency Pareto frontier:
- Text-to-Image (Flux-1): CUBIC (fast) hits a 2.40× speedup (4.82s vs. 11.59s baseline) with a PSNR of 25.14, outperforming TeaCache (1.86×, 22.88 PSNR) and ToCa (1.81×, 19.68 PSNR). Its standard setting achieves 1.89× speedup at 27.78 PSNR.
- Image Editing (FireRed): Achieves 2.14× speedup with 30.67 PSNR (standard) and 2.33× speedup at 27.81 PSNR (fast), handily beating TeaCache at a similar speed (2.31×, 23.80 PSNR).
- Text-to-Video (Wan 2.1): Cuts generation latency from 101.54s down to 37.32s (2.72× speedup) with 26.39 PSNR and a slightly improved VBench score (80.03 vs. 79.90 baseline), whereas TaylorSeer drops to 15.80 PSNR at 2.59× speedup.
- Memory Offloading: For video models where layer-wise KV caches grow large (17.68 GB on Wan 2.1), asynchronous CPU offloading eliminates the extra GPU memory footprint entirely for just a ~5% latency penalty.
Limitations and Future Work
- Simple Solver Assumptions: The error bounds rely on a first-order forward-Euler ODE abstraction. Extending the math to higher-order, multi-step, or native Stochastic Differential Equation (SDE) samplers—where random diffusion noise interacts with cached drift—remains open.
- Static Compute Budgets: CUBIC holds the user's target speedup constant across the entire generation run. Because trajectory curvature naturally flattens out in later steps, dynamically shifting the compute budget over time could squeeze out even better performance, provided future curvature can be predicted cheaply.
- System Heuristics Remain: While the interval allocation rule is theoretically derived, the length of the window between anchor steps and the exact block partitioning granularity remain empirical, model-dependent choices.
Summary updated