Skip to content

[Bug] ImportError: cannot import name 'SlidingWindowCache' #49

@dorpxam

Description

@dorpxam

Probably out of date with a fresh basic installation:

modeling_keye_vl_1_5.py", line 34, in <module>
    from transformers.cache_utils import Cache, DynamicCache, SlidingWindowCache, StaticCache

But SlidingWindowCache is not longer in latest transformers and never used in the code.

# packages in environment at C:\anaconda3\envs\ltx2caption:
#
# Name                    Version                   Build  Channel
annotated-doc             0.0.4                    pypi_0    pypi
anyio                     4.12.1                   pypi_0    pypi
av                        16.1.0                   pypi_0    pypi
bzip2                     1.0.8                h2bbff1b_6
ca-certificates           2025.12.2            haa95532_0
certifi                   2026.1.4                 pypi_0    pypi
charset-normalizer        3.4.4                    pypi_0    pypi
click                     8.3.1                    pypi_0    pypi
colorama                  0.4.6                    pypi_0    pypi
einops                    0.8.2                    pypi_0    pypi
expat                     2.7.4                hd7fb8db_0
filelock                  3.20.0                   pypi_0    pypi
fsspec                    2025.12.0                pypi_0    pypi
h11                       0.16.0                   pypi_0    pypi
hf-xet                    1.2.0                    pypi_0    pypi
httpcore                  1.0.9                    pypi_0    pypi
httpx                     0.28.1                   pypi_0    pypi
huggingface-hub           1.4.1                    pypi_0    pypi
idna                      3.11                     pypi_0    pypi
jinja2                    3.1.6                    pypi_0    pypi
keye-vl-utils             1.5.2                    pypi_0    pypi
libexpat                  2.7.4                hd7fb8db_0
libffi                    3.4.4                hd77b12b_1
libzlib                   1.3.1                h02ab6af_0
markdown-it-py            4.0.0                    pypi_0    pypi
markupsafe                3.0.2                    pypi_0    pypi
mdurl                     0.1.2                    pypi_0    pypi
mpmath                    1.3.0                    pypi_0    pypi
networkx                  3.6.1                    pypi_0    pypi
numpy                     2.3.5                    pypi_0    pypi
opencv-python             4.13.0.92                pypi_0    pypi
openssl                   3.0.19               hbb43b14_0
packaging                 25.0            py312haa95532_1
pillow                    12.0.0                   pypi_0    pypi
pip                       26.0.1             pyhc872135_0
pygments                  2.19.2                   pypi_0    pypi
python                    3.12.12              h716150d_1
pyyaml                    6.0.3                    pypi_0    pypi
regex                     2026.2.19                pypi_0    pypi
requests                  2.32.5                   pypi_0    pypi
rich                      14.3.3                   pypi_0    pypi
safetensors               0.7.0                    pypi_0    pypi
setuptools                80.10.2         py312haa95532_0
shellingham               1.5.4                    pypi_0    pypi
sqlite                    3.51.1               hda9a48d_0
sympy                     1.14.0                   pypi_0    pypi
tk                        8.6.15               hf199647_0
tokenizers                0.22.2                   pypi_0    pypi
torch                     2.9.1+cu130              pypi_0    pypi
torchaudio                2.9.1+cu130              pypi_0    pypi
torchvision               0.24.1+cu130             pypi_0    pypi
tqdm                      4.67.3                   pypi_0    pypi
transformers              5.2.0                    pypi_0    pypi
triton-windows            3.6.0.post25             pypi_0    pypi
typer                     0.24.0                   pypi_0    pypi
typer-slim                0.24.0                   pypi_0    pypi
typing-extensions         4.15.0                   pypi_0    pypi
tzdata                    2025c                he532380_0
ucrt                      10.0.22621.0         haa95532_0
urllib3                   2.6.3                    pypi_0    pypi
vc                        14.3                h2df5915_10
vc14_runtime              14.44.35208         h4927774_10
vs2015_runtime            14.44.35208         ha6b5a95_10
wheel                     0.46.3          py312haa95532_0
xz                        5.6.4                h4754444_1
zlib                      1.3.1                h02ab6af_0
config.json: 2.03kB [00:00, 47.1kB/s]
configuration_keye_vl_1_5.py: 12.9kB [00:00, 1.02MB/s]
A new version of the following files was downloaded from https://huggingface.co/Kwai-Keye/Keye-VL-1.5-8B:
- configuration_keye_vl_1_5.py
. Make sure to double-check they do not contain any added malicious code. To avoid downloading new versions of the code file, you can pin a revision.
Unrecognized keys in `rope_parameters` for 'rope_type'='default': {'mrope_section'}
modeling_keye_vl_1_5.py: 133kB [00:00, 4.04MB/s]
A new version of the following files was downloaded from https://huggingface.co/Kwai-Keye/Keye-VL-1.5-8B:
- modeling_keye_vl_1_5.py
. Make sure to double-check they do not contain any added malicious code. To avoid downloading new versions of the code file, you can pin a revision.
Traceback (most recent call last):
  File "C:\AI\ltx2-captioner\main.py", line 63, in <module>
    main(args.input_path, args.output_path, args.captioner_type)
  File "C:\AI\ltx2-captioner\main.py", line 41, in main
    processor = Processor(captioner_type)
                ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\AI\ltx2-captioner\main.py", line 28, in __init__
    self.captioner = create_captioner(captioner_type)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\AI\ltx2-captioner\utils\captioner.py", line 16, in create_captioner
    return KeyeVL(**kwargs)
           ^^^^^^^^^^^^^^^^
  File "C:\AI\ltx2-captioner\models\keye.py", line 33, in __init__
    self.load_model(
  File "C:\AI\ltx2-captioner\models\keye.py", line 125, in load_model
    self.model = AutoModel.from_pretrained(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\anaconda3\envs\ltx2caption\Lib\site-packages\transformers\models\auto\auto_factory.py", line 356, in from_pretrained
    model_class = get_class_from_dynamic_module(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\anaconda3\envs\ltx2caption\Lib\site-packages\transformers\dynamic_module_utils.py", line 583, in get_class_from_dynamic_module
    return get_class_in_module(class_name, final_module, force_reload=force_download)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\anaconda3\envs\ltx2caption\Lib\site-packages\transformers\dynamic_module_utils.py", line 309, in get_class_in_module
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 999, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "C:\Users\dorpx\.cache\huggingface\modules\transformers_modules\Kwai_hyphen_Keye\Keye_hyphen_VL_hyphen_1_dot_5_hyphen_8B\b4d413e4f42a3999af1f5ba0e281c7d51d6b93de\modeling_keye_vl_1_5.py", line 34, in <module>
    from transformers.cache_utils import Cache, DynamicCache, SlidingWindowCache, StaticCache
ImportError: cannot import name 'SlidingWindowCache' from 'transformers.cache_utils' (C:\anaconda3\envs\ltx2caption\Lib\site-packages\transformers\cache_utils.py)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions