`apply_*` cache functions don't reach `cache_context` after the model already ran (follow-up to #14037)
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 18/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Domaine
- machine-learning
Piste de recherche
The bug is in the public apply_* cache functions (apply_first_block_cache, apply_pyramid_attention_broadcast, apply_faster_cache, apply_taylorseer_cache, apply_mag_cache), which should invalidate the child-registry cache the way apply_sea_cache already does, as enable_cache does after #14093. Start by comparing those functions with apply_sea_cache and the enable_cache path, then run the reproduction script to confirm the 'No cache context is set' error. Done means the post-run apply_* call works under cache_context and MagCache's cond and uncond outputs match a fresh pipeline. An open linked pull request (#15372) already addresses this, so check it before starting.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Describe the bug
Follow-up to #14037. #14093 invalidates the child-registry cache in enable_cache, but the public apply_* functions don't (apply_first_block_cache, apply_pyramid_attention_broadcast, apply_faster_cache, apply_taylorseer_cache, apply_mag_cache; only apply_sea_cache does). Every pipeline call builds that cache through cache_context, so a cache applied afterwards with apply_* never gets the context:
- FirstBlockCache, PAB, FasterCache and TaylorSeer raise
No cache context is set, even though the call is wrapped. - MagCache doesn't raise, but cond and uncond share one state, so the output changes (max abs diff 0.091 vs a fresh pipeline with true CFG).
enable_cache in the same flow works.
Reproduction
import torch
from diffusers import FirstBlockCacheConfig, FluxTransformer2DModel, apply_first_block_cache
model = FluxTransformer2DModel(
patch_size=1, in_channels=4, num_layers=1, num_single_layers=1, attention_head_dim=16,
num_attention_heads=2, joint_attention_dim=32, pooled_projection_dim=32, axes_dims_rope=[4, 4, 8],
)
inputs = dict(
hidden_states=torch.randn(1, 16, 4), encoder_hidden_states=torch.randn(1, 8, 32),
pooled_projections=torch.randn(1, 32), img_ids=torch.randn(16, 3), txt_ids=torch.randn(8, 3),
timestep=torch.tensor([1.0]),
)
with model.cache_context("cond"): # what every pipeline call does
model(**inputs)
apply_first_block_cache(model, FirstBlockCacheConfig(threshold=0.8))
with model.cache_context("cond"):
model(**inputs)
ValueError: No cache context is set. Wrap the denoiser call in `model.cache_context(name, ...)` before calling it.
System Info
diffusers main (ed3267270), torch 2.15.0, Python 3.12, CPU.
Who can help?
@sayakpaul @DN6
- Langage dominant
- Python
- Étoiles
- 35k
- Forks
- 7.5k
- Merge moyen
- 2 j 22 h
- PR mergées (30 j)
- 58
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de huggingface/diffusers
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
huggingface/diffusers#15436 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
InpaintProcessor crashes when padding_mask_crop is set and a dimension is omittedPeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
huggingface/diffusers#15433 ·
Les mainteneurs répondent en général sous 1 jour
-
LTXEulerAncestralRFScheduler skips signal scaling with s_noise=0Peut-être pris @hparik11 l’a pris il y a 3 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
huggingface/diffusers#15423 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Docs: 13 docstrings document parameters their functions don't havePeut-être pris @M-Colley l’a pris il y a 3 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
huggingface/diffusers#15363 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
`ZImageImg2ImgPipeline` / `ZImageInpaintPipeline`: explicit height/width different from the input image raises RuntimeErrorPeut-être pris @chessing234 l’a pris il y a 11 jours. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
huggingface/diffusers#15337 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de huggingface/diffusers
Issues similaires
-
[19.0] pos_sale: settling an order with a 0 down payment line crashes (reading 'reward_id') and leaves a wrong amount duePeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 79/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 79/100
developmentseed/titiler-covjson#164 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
awslabs/visual-asset-management-system#2164 ·
Les mainteneurs répondent en général sous 1 jour
-
needs-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
MakazhanAlpamys/Soup#3589 ·
Les mainteneurs répondent en général sous 1 jour
-
channels status reports the wrong Enabled value for Feishu instances and default-enabled WebSocketOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
Les mainteneurs répondent en général sous 1 jour