(With the help of Claude - Thank you for all the work on Wan2GP!)
[Bug] Index TTS 2 fails to load — ImportError: cannot import name 'QuantizedCacheConfig' from 'transformers.cache_utils'
Environment
|
|
| Wan2GP version |
Latest (v11.66) |
| GPU |
NVIDIA RTX 4060 8 GB VRAM |
| OS |
Windows 11 |
| Python env |
env_venv |
Description
When selecting Index TTS 2 as the TTS engine, model loading fails immediately with an ImportError deep inside the bundled Index TTS 2 code. The error occurs because QuantizedCacheConfig was removed from transformers.cache_utils in transformers ≥ 4.57, but the file models/TTS/index_tts2/gpt/transformers_generation_utils.py still tries to import it unconditionally.
This is a known upstream issue in the index-tts repository (see index-tts/index-tts#508), but it needs to be addressed in the Wan2GP vendored copy of the file.
Steps to Reproduce
- Launch Wan2GP (latest version).
- Select Index TTS 2 as the TTS model.
- Attempt to generate with any prompt.
Error Log
Loading Model 'ckpts\index_tts2_gpt_fp16.safetensors' ...
Unable to use LM Engine 'vllm' as it requires a Memory Profile such as 1,3 or 3+ that loads entirely the Main Models in VRAM. Switching to Legacy LM Engine...
Traceback (most recent call last):
File "E:\Wan2GP\wgp.py", line 7354, in queue_worker_func
success = generate_video(task, send_cmd, plugin_data=plugin_data, **filtered_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Wan2GP\wgp.py", line 5953, in generate_video
wan_model, offloadobj = load_models(
^^^^^^^^^^^^
File "E:\Wan2GP\wgp.py", line 3518, in load_models
wan_model, pipe = model_type_handler.load_model(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Wan2GP\models\TTS\index_tts2_handler.py", line 234, in load_model
from .index_tts2.pipeline import IndexTTS2Pipeline
File "E:\Wan2GP\models\TTS\index_tts2\pipeline.py", line 17, in <module>
from .infer_v2 import IndexTTS2
File "E:\Wan2GP\models\TTS\index_tts2\infer_v2.py", line 24, in <module>
from .gpt.model_v2 import UnifiedVoice
File "E:\Wan2GP\models\TTS\index_tts2\gpt\model_v2.py", line 18, in <module>
from .transformers_gpt2 import GPT2PreTrainedModel, GPT2Model
File "E:\Wan2GP\models\TTS\index_tts2\gpt\transformers_gpt2.py", line 33, in <module>
from .transformers_generation_utils import GenerationMixin
File "E:\Wan2GP\models\TTS\index_tts2\gpt\transformers_generation_utils.py", line 28, in <module>
from transformers.cache_utils import (
ImportError: cannot import name 'QuantizedCacheConfig' from 'transformers.cache_utils' (E:\Wan2GP\env_venv\Lib\site-packages\transformers\cache_utils.py)
Error Queue autosaved successfully to error_queue.zip
Root Cause
QuantizedCacheConfig was removed from transformers.cache_utils in transformers 4.57+. The vendored file models/TTS/index_tts2/gpt/transformers_generation_utils.py imports it unconditionally at line 28.
Suggested Fix
Option A — Pin transformers in requirements
Pin the transformers dependency to ==4.55.0 for the Index TTS 2 code path, which is the last version known to include QuantizedCacheConfig.
Option B — Guard the import with a try/except in transformers_generation_utils.py
Replace the unconditional import at line 28 with:
try:
from transformers.cache_utils import QuantizedCacheConfig
except ImportError:
# QuantizedCacheConfig was removed in transformers >= 4.57
from dataclasses import dataclass
@dataclass
class QuantizedCacheConfig:
backend: str = "quanto"
nbits: int = 4
axis_key: int = 0
axis_value: int = 0
q_group_size: int = 64
residual_length: int = 128
compute_dtype: object = None
device: object = None
This is a non-breaking fallback — the stub exposes the same fields that the original dataclass had, and Index TTS 2 does not actually exercise quantized KV cache at inference time.
Workaround (until fixed)
Downgrade transformers manually inside the venv:
env_venv\Scripts\pip install "transformers==4.55.0"
References
(With the help of Claude - Thank you for all the work on Wan2GP!)
[Bug] Index TTS 2 fails to load —
ImportError: cannot import name 'QuantizedCacheConfig' from 'transformers.cache_utils'Environment
env_venvDescription
When selecting Index TTS 2 as the TTS engine, model loading fails immediately with an
ImportErrordeep inside the bundled Index TTS 2 code. The error occurs becauseQuantizedCacheConfigwas removed fromtransformers.cache_utilsin transformers ≥ 4.57, but the filemodels/TTS/index_tts2/gpt/transformers_generation_utils.pystill tries to import it unconditionally.This is a known upstream issue in the
index-ttsrepository (see index-tts/index-tts#508), but it needs to be addressed in the Wan2GP vendored copy of the file.Steps to Reproduce
Error Log
Root Cause
QuantizedCacheConfigwas removed fromtransformers.cache_utilsin transformers 4.57+. The vendored filemodels/TTS/index_tts2/gpt/transformers_generation_utils.pyimports it unconditionally at line 28.Suggested Fix
Option A — Pin
transformersin requirementsPin the
transformersdependency to==4.55.0for the Index TTS 2 code path, which is the last version known to includeQuantizedCacheConfig.Option B — Guard the import with a
try/exceptintransformers_generation_utils.pyReplace the unconditional import at line 28 with:
This is a non-breaking fallback — the stub exposes the same fields that the original dataclass had, and Index TTS 2 does not actually exercise quantized KV cache at inference time.
Workaround (until fixed)
Downgrade
transformersmanually inside the venv:env_venv\Scripts\pip install "transformers==4.55.0"References