Speed Up Z-Image with ComfyUI-meancache-z by Facok

Text logo for ComfyUI-meancache-z on a-digital translucent node panel

ComfyUI-meancache-z is a new custom node that accelerates inference for Z-Image Flow Matching models without requiring any model fine-tuning. The tool, similar to the Z-Image loras, achieves speedups between 1.4x and 2.0x while maintaining image quality by using a technique called average velocity correction instead of instantaneous velocity.

Developed by Facok, this extension integrates directly into ComfyUI as a custom node and targets users running Z-Image models locally. The project implements the MeanCache algorithm from the research paper

'From Instantaneous to Average Velocity for Accelerating Flow Matching Inference'

to optimize the ODE trajectory during sampling.

How ComfyUI-meancache-z speeds up image generation

  • Training-free acceleration requiring no model fine-tuning or modifications.
  • JVP-based velocity correction for more accurate ODE trajectory calculations.
  • PSSP scheduling algorithm that optimizes compute budget allocation.
  • Four preset profiles: Quality, Balanced, Speed, and Turbo for easy configuration.
  • Custom mode with manual parameter control for advanced users.

Digital artists and developers working with Z-Image models can benefit from faster generation times without sacrificing output quality. The preset system makes it simple to balance speed against image fidelity based on project needs, whether prioritizing quick iterations or final renders.

Technical implementation details

The algorithm works by computing a Jacoby-Vector Product approximation through finite differences, then using average velocity instead of instantaneous velocity for step calculations. A stability deviation metric determines when steps can be safely skipped during sampling.

The PSSP (Peak-Suppressed Shortest Path) scheduling uses dynamic programming to find the optimal trajectory while staying within a compute budget. The Balanced preset offers a 1.7x speedup with good quality tradeoffs and serves as the default setting.

You can grab ComfyUI-meancache-z on GitHub.