From 5fc8fd76dea55164c6f6b912e5540477ef3f45a8 Mon Sep 17 00:00:00 2001 From: hitoshic1982 Date: Sat, 29 Aug 2026 01:37:39 +0800 Subject: [PATCH] Fix cache_text_encoder device preset missing in BaseModel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BaseModel.set_device_state_preset() has no branch for the 'cache_text_encoder' preset, so when TextEmbeddingCachingMixin calls set_device_state_preset('cache_text_encoder') the active_modules list stays empty and the text encoder is placed on CPU. With cache_text_embeddings enabled on a BaseModel arch (e.g. chroma), every caption is then encoded on CPU — with a quantized T5-XXL this took ~6.5 minutes per caption (~21 hours for a 205-image dataset) while the GPU sat idle. StableDiffusion.set_device_state_preset() already has this branch; this adds the same two lines to BaseModel. --- toolkit/models/base_model.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/toolkit/models/base_model.py b/toolkit/models/base_model.py index 9aadeea..243fd8a 100644 --- a/toolkit/models/base_model.py +++ b/toolkit/models/base_model.py @@ -1567,6 +1567,8 @@ class BaseModel: active_modules = ['vae'] if device_state_preset in ['cache_clip']: active_modules = ['clip'] + if device_state_preset in ['cache_text_encoder']: + active_modules = ['text_encoder'] if device_state_preset in ['generate']: active_modules = ['vae', 'unet', 'text_encoder', 'adapter', 'refiner_unet']