Skip to content

Auto resolution cache

inference_models.models.auto_loaders.auto_resolution_cache

Classes

AutoResolutionCache

Bases: ABC

Source code in inference_source/inference_models/inference_models/models/auto_loaders/auto_resolution_cache.py
class AutoResolutionCache(ABC):

    @abstractmethod
    def register(
        self, auto_negotiation_hash: str, cache_entry: AutoResolutionCacheEntry
    ) -> None:
        pass

    @abstractmethod
    def retrieve(
        self, auto_negotiation_hash: str
    ) -> Optional[AutoResolutionCacheEntry]:
        pass

    @abstractmethod
    def invalidate(self, auto_negotiation_hash: str) -> None:
        pass

    def find_compatible(
        self,
        offline_compatibility_hash: str,
    ) -> Optional[Tuple[str, AutoResolutionCacheEntry]]:
        """Return the newest matching entry when the cache can enumerate.

        Custom cache implementations remain source-compatible and may opt in
        by overriding this method.
        """

        return None

    def find_compatible_candidates(
        self,
        offline_compatibility_hash: str,
    ) -> List[Tuple[str, AutoResolutionCacheEntry]]:
        """Return compatible entries in preferred order when supported.

        The default wraps the original single-result extension point so custom
        cache implementations that only override ``find_compatible`` keep
        working without changes.
        """

        compatible_entry = self.find_compatible(
            offline_compatibility_hash=offline_compatibility_hash
        )
        return [] if compatible_entry is None else [compatible_entry]

    def find_model_candidates(
        self,
        model_id: str,
        credential_hash: Optional[str] = None,
    ) -> List[Tuple[str, AutoResolutionCacheEntry]]:
        """Return entries for an exact requested identity and credential."""

        return []
Functions
find_compatible
find_compatible(offline_compatibility_hash)

Return the newest matching entry when the cache can enumerate.

Custom cache implementations remain source-compatible and may opt in by overriding this method.

Source code in inference_source/inference_models/inference_models/models/auto_loaders/auto_resolution_cache.py
def find_compatible(
    self,
    offline_compatibility_hash: str,
) -> Optional[Tuple[str, AutoResolutionCacheEntry]]:
    """Return the newest matching entry when the cache can enumerate.

    Custom cache implementations remain source-compatible and may opt in
    by overriding this method.
    """

    return None
find_compatible_candidates
find_compatible_candidates(offline_compatibility_hash)

Return compatible entries in preferred order when supported.

The default wraps the original single-result extension point so custom cache implementations that only override find_compatible keep working without changes.

Source code in inference_source/inference_models/inference_models/models/auto_loaders/auto_resolution_cache.py
def find_compatible_candidates(
    self,
    offline_compatibility_hash: str,
) -> List[Tuple[str, AutoResolutionCacheEntry]]:
    """Return compatible entries in preferred order when supported.

    The default wraps the original single-result extension point so custom
    cache implementations that only override ``find_compatible`` keep
    working without changes.
    """

    compatible_entry = self.find_compatible(
        offline_compatibility_hash=offline_compatibility_hash
    )
    return [] if compatible_entry is None else [compatible_entry]
find_model_candidates
find_model_candidates(model_id, credential_hash=None)

Return entries for an exact requested identity and credential.

Source code in inference_source/inference_models/inference_models/models/auto_loaders/auto_resolution_cache.py
def find_model_candidates(
    self,
    model_id: str,
    credential_hash: Optional[str] = None,
) -> List[Tuple[str, AutoResolutionCacheEntry]]:
    """Return entries for an exact requested identity and credential."""

    return []