← Latest papers
🤖 machine learning

OnlineCache: Learning Dynamic Caching Policies with Error Correction for Efficient Diffusion Inference

OnlineCache is a dynamic caching framework that employs a learnable policy and error corrector to adaptively allocate computational resources across varying prompts and timesteps, achieving significant inference speedups for diffusion models while preserving generation quality.

Original authors: Zhikang Xie, Xichen Ye, Yifan Wu, Haoshen Yu, Li chenan, Peizhu Gong, Weizhong Zhang, Cheng Jin

Published 2026-08-03
📖 7 min read🧠 Deep dive

Original authors: Zhikang Xie, Xichen Ye, Yifan Wu, Haoshen Yu, Li chenan, Peizhu Gong, Weizhong Zhang, Cheng Jin

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are trying to paint a masterpiece, but you are forced to repaint the entire canvas from scratch for every single brushstroke. That is essentially how modern AI image generators, known as diffusion models, work today. They start with a chaotic cloud of digital noise and slowly, step-by-step, refine it into a clear picture. While this process creates stunningly realistic images, it is incredibly slow and computationally expensive, like trying to build a skyscraper by laying one brick at a time and then checking your work by rebuilding the whole tower. To make these AI tools faster and more useful for real-time applications, scientists have been looking for ways to skip unnecessary steps. The most popular idea so far has been "caching," which is like keeping a copy of a previous brushstroke and reusing it if the picture hasn't changed much yet. However, the old way of doing this was rigid: it used a fixed schedule, deciding to skip steps based on a simple timer, regardless of whether the current image was easy or hard to draw.

This paper introduces a smarter, more flexible approach called OnlineCache. Instead of following a rigid rulebook, the authors trained a tiny, lightweight "coach" (a policy network) to watch the painting process in real-time. This coach decides, moment by moment, whether it's safe to reuse an old brushstroke or if it needs to do the full, heavy calculation. The paper argues that the difficulty of generating an image varies wildly depending on the prompt (some ideas are easy, some are complex) and that some moments in the painting process are more sensitive to errors than others. By teaching the AI to adapt its strategy on the fly and even include a "corrector" to fix small mistakes made by skipping steps, OnlineCache achieves massive speedups. On the FLUX.1-dev model, it nearly triples the speed (a 3× speedup) while keeping the image quality just as high as the slow, careful method. The authors demonstrate that this dynamic, learning-based approach consistently outperforms previous static methods across different image sizes, datasets, and even video generation tasks.

The Problem: The "One-Size-Fits-All" Trap

To understand why OnlineCache is a big deal, we first need to look at the problem it solves. Diffusion models are like artists who start with a blurry, noisy sketch and gradually sharpen it. To get a final image, they might take 30 or more steps. In the past, researchers tried to speed this up by saying, "Hey, steps 10, 11, and 12 look similar, so let's just reuse the result from step 10." This is called caching.

However, the existing methods were like a strict teacher who says, "You must skip steps 10, 11, and 12 for every student, no matter what." This is a static policy. The paper points out two major flaws with this approach:

  1. Different Prompts, Different Needs: Some image requests are simple (like "a red ball"), while others are complex (like "a cyberpunk city in the rain"). A static teacher treats them the same, wasting time on the easy ones and rushing the hard ones.
  2. Different Moments, Different Risks: In the painting process, some steps are critical for getting the shape right, while others are just adding texture. If you skip a critical step, the whole image might look wrong. Static rules don't know the difference; they might skip a crucial step or waste time on a boring one.

The authors argue that this rigidity is the bottleneck. They observed that the "difficulty" of the task changes from prompt to prompt and from step to step, yet old methods ignored this.

The Solution: A Smart Coach That Learns

OnlineCache changes the game by turning the caching decision into a learning problem. Instead of a fixed rule, the system uses a tiny neural network (the "policy") that acts like a smart coach watching the painting process.

How the Coach Decides:
The coach looks at a few key clues before deciding whether to skip a step:

  • The Current State: What does the image look like right now? (Is it still a mess, or is it almost done?)
  • The Cached State: What did the last saved step look like?
  • The Time: How far along are we in the process?

Based on these clues, the coach asks: "Is it safe to reuse the old result, or do we need to do the hard work?" If the coach thinks it's safe, it skips the heavy computation (saving time). If it thinks the image is tricky or the step is critical, it forces the AI to do the full calculation.

The "Bilevel" Twist (The Coach and the Fixer):
The paper introduces two versions of this system. The first is just the coach. The second, more advanced version (called Bilevel Optimization or BLO) adds a second character: a Corrector.

  • The Coach decides when to skip.
  • The Corrector is a tiny tool that fixes the small errors that happen when the coach skips a step.

Think of it like a fast-forwarding video player. The coach decides when to fast-forward. If the fast-forward skips too much, the picture might look blurry. The corrector is like a "sharpen" button that instantly fixes the blur, ensuring the fast-forwarded video still looks crisp. The system trains both the coach and the corrector together: the coach learns to skip only when the corrector can handle the fix, and the corrector learns to fix whatever the coach skips.

What the Experiments Showed

The authors tested this system on several powerful AI models, including FLUX.1-dev, DiT, and CogVideoX (for video). Here is what they found:

  • Speed vs. Quality: On the FLUX.1-dev model, OnlineCache achieved nearly a 3× speedup. This means it generated images three times faster than the standard method. Crucially, the quality didn't drop; in fact, the images were often sharper and more accurate than those made by other fast methods.
  • Adaptability: The system proved it could handle different scenarios. When asked to generate simple images, it skipped more steps. When the prompt was complex, it worked harder. It also figured out that some specific moments in the painting process were too important to skip, while others were safe to ignore.
  • Beating the Competition: The paper compared OnlineCache against other top-tier methods like ERTACache and TeaCache. In almost every test, OnlineCache produced better images with less error. For example, on one test, it reduced the visual error (L1 error) by 37.48% compared to a static method that used the same amount of skipping.
  • Generalization: The system was trained on one set of images (MSCOCO) but worked perfectly on completely different images (Parti-Prompts) and even different resolutions (from 512x512 to 1024x1024) without needing to be retrained. It even worked on video generation, showing that the "smart coach" idea isn't just for pictures.

Why This Matters

The paper suggests that the future of fast AI isn't about building bigger, faster computers, but about being smarter about how we use the computers we have. By moving away from rigid, "one-size-fits-all" rules and embracing a dynamic, learning-based approach, we can make AI generators significantly faster without sacrificing the quality that makes them amazing. The authors show that by letting the AI decide when to take a shortcut and how to fix the mistakes, we can get the best of both worlds: speed and perfection.

In short, OnlineCache teaches the AI to be a flexible artist rather than a rigid robot, resulting in faster, higher-quality creations that adapt to the task at hand.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →