Skip to content

KeyError: 'optimum.quanto' for _is_package_available #41981

@kaixuanliu

Description

@kaixuanliu

System Info

When i run pytest -rA tests/models/video_llama_3/test_modeling_video_llama_3.py::VideoLlama3ModelTest::test_generate_with_quant_cache, it will fail and return error:

pkg_name = 'optimum.quanto', return_version = True

    def _is_package_available(pkg_name: str, return_version: bool = False) -> tuple[bool, str] | bool:
        """Check if `pkg_name` exist, and optionally try to get its version"""
        spec = importlib.util.find_spec(pkg_name)
        package_exists = spec is not None
        package_version = "N/A"
        if package_exists and return_version:
            try:
                # importlib.metadata works with the distribution package, which may be different from the import
                # name (e.g. `PIL` is the import name, but `pillow` is the distribution name)
>               distributions = PACKAGE_DISTRIBUTION_MAPPING[pkg_name]
E               KeyError: 'optimum.quanto'

src/transformers/utils/import_utils.py:56: KeyError

I suggest one approach to solve this is add KeyError to except line in L61, is it OK?

Who can help?

@SunMarc FYI

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

  1. git clone https://github.com/huggingface/transformers.git
  2. pip install optimum-quanto
  3. export RUN_SLOW=1
  4. pytest -rA tests/models/video_llama_3/test_modeling_video_llama_3.py::VideoLlama3ModelTest::test_generate_with_quant_cache

Expected behavior

The test case is expected to pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions