[Feature Request] Add DiCache for sample-adaptive caching in FLUX transformers
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- backend, machine-learning
Hướng nghiên cứu
Start by reading Diffusers’ existing caching API, cache-hook and state-management architecture, then inspect the FLUX transformer integration and its cache tests. The issue proposes adding a compatible DiCacheConfig with sample-adaptive probe decisions and trajectory-aligned residual reuse. Done means a FLUX-first integration without pipeline-specific monkey-patching, with regression tests and documentation; the issue provides no file paths or test names.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Diffusers already supports caching techniques such as FirstBlockCache, but additional speed–quality trade-offs may be possible through sample-adaptive cache decisions and trajectory-aligned residual reuse.
I would like to propose integrating [DiCache (ICLR 2026)](https://proceedings.iclr.cc/paper_files/paper/2026/hash/78288ef33b18a351c3cd679dc9a15c8d-Abstract-Conference.html), which uses shallow transformer probes to determine whether a full forward pass is necessary and applies trajectory-aligned reuse when skipping computation.
Describe the solution you'd like.
Add a DiCacheConfig compatible with Diffusers' existing caching API:
from diffusers import DiCacheConfig
pipe.transformer.enable_cache(
DiCacheConfig(threshold=0.2, probe_depth=1)
)
# Generate images
pipe.transformer.disable_cache()
This is a proposed API, not an existing implementation. I propose an initial FLUX integration using the existing cache-hook and state-management architecture, without pipeline-specific monkey-patching.
Describe alternatives you've considered.
I benchmarked DiCache against Diffusers' FirstBlockCache and two DiCache ablations on pretrained FLUX.1-dev.
| Method | Speedup | SSIM ↑ | LPIPS ↓ |
|---|---|---|---|
| FirstBlockCache (0.05) | 1.23× | 0.9851 | 0.0107 |
| DiCache (0.2) | 2.14× | 0.9419 | 0.0515 |
| DiCache (0.3) | 2.42× | 0.9102 | 0.0834 |
| FirstBlockCache (0.2) | 2.69× | 0.8779 | 0.1301 |
| Fixed-schedule DiCache | 2.12× | 0.9348 | 0.0557 |
| Last-residual-only DiCache | 2.13× | 0.9274 | 0.0686 |
These results suggest that DiCache provides an additional operating region in the speed–fidelity trade-off. They do not establish superiority over a fully threshold-tuned FirstBlockCache Pareto frontier.
Additional context.
Experimental setup:
- Model:
aniketppanchal/flux.1-dev-nf4-pkg, revisiondde39613d8f3d7abe59d7c59ff16838b14bcebf8 - Hardware: Tesla T4
- Resolution: 512×512, 30 denoising steps
- Evaluation: 10 prompts × 3 seeds × 7 variants, with 2 timing repetitions each
- Versions: Diffusers 0.35.1, Transformers 4.56.1
- Measurements: denoising-only runtime, SSIM, PSNR, LPIPS, CLIP alignment, latent error, and GPU memory
Validation results:
All 210 method–prompt–seed configurations completed with zero recorded failures. Cache-disabled inference achieved exact tensor parity with native FLUX inference. Deterministic cache-reset and interleaved-generation tests also passed.
Per-timestep instrumentation demonstrated sample-dependent scheduling: DiCache produced 6 distinct cache schedules at threshold 0.2 and 3 at threshold 0.3 across 30 trajectories, compared with 1 schedule for the fixed-schedule control.
Ablations indicated improvements from both adaptive decisions and residual-history reuse.
Limitations: The experiments use an NF4-quantized checkpoint, not the paper's original full-precision setup. Fidelity can vary significantly between samples, with minimum SSIM values of 0.8120 and 0.7362 for DiCache thresholds 0.2 and 0.3, respectively. Additional matched-fidelity comparisons and broader model coverage would be valuable.
References:
- Paper: https://proceedings.iclr.cc/paper_files/paper/2026/hash/78288ef33b18a351c3cd679dc9a15c8d-Abstract-Conference.html
- Official implementation: https://github.com/Bujiazi/DiCache
I have reproducible benchmark scripts, paired images, cache trajectories, and validation records available.
I can prepare a minimal FLUX-first integration with the existing Diffusers caching infrastructure, together with regression tests and documentation. I would be happy to align the implementation with the maintainers' preferred design.
Would the maintainers be interested in this contribution? Any guidance on the preferred integration approach would be greatly appreciated.
If approved, I am willing to implement this feature and submit a pull request. I would also request this issue be assigned to me if possible.
- Ngôn ngữ chính
- Python
- Star
- 34.9k
- Fork
- 7.5k
- Merge trung bình
- 3 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 65
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của huggingface/diffusers
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
huggingface/diffusers#15363 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`ZImageImg2ImgPipeline` / `ZImageInpaintPipeline`: explicit height/width different from the input image raises RuntimeErrorCó thể đã có người làm @chessing234 đã nhận 1 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
huggingface/diffusers#15337 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Multi-vector textual inversion uses only the first vector when the token has uppercase letters (transformers v5)Có thể đã có người làm @sunhouy đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
huggingface/diffusers#15313 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
TCDScheduler advances the generator on the final step of a strength-truncated custom scheduleCó thể đã có người làm @SIDDARTHAREDDY8 đã nhận 5 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
huggingface/diffusers#15288 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
unload_textual_inversion(token) leaves the extra tokens of a multi-vector embedding behind, so it can't be loaded againCó thể đã có người làm @sohailshk đã nhận 11 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
huggingface/diffusers#15211 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của huggingface/diffusers
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Unused loot bag group names left in dreamcraft en_US.langCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởStatus: Triage Suggestion
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
GTNewHorizons/GT-New-Horizons-Modpack#27789 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug frontend sev-5
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
-
core good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
b4b code health next
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ESCOMP/CTSM#4330 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày