invoke-ai/InvokeAI · error · ValueError

Algorithm {algorithm} not available

Error message

Algorithm {algorithm} not available

What it means

ModelHash.__init__ raises ValueError when the requested algorithm is not 'blake3', not in hashlib.algorithms_available, and not the literal 'random'. InvokeAI only supports a fixed set of hashing algorithms for model identification.

Source

Thrown at invokeai/backend/model_hash/model_hash.py:76

        # MD5
        ModelHash("md5").hash("path/to/model/dir/") # "md5:a0cd925fc063f98dbf029eee315060c3"
        ```
    """

    def __init__(
        self, algorithm: HASHING_ALGORITHMS = "blake3_single", file_filter: Optional[Callable[[str], bool]] = None
    ) -> None:
        self.algorithm: HASHING_ALGORITHMS = algorithm
        if algorithm == "blake3_multi":
            self._hash_file = self._blake3
        elif algorithm == "blake3_single":
            self._hash_file = self._blake3_single
        elif algorithm in hashlib.algorithms_available:
            self._hash_file = self._get_hashlib(algorithm)
        elif algorithm == "random":
            self._hash_file = self._random
        else:
            raise ValueError(f"Algorithm {algorithm} not available")

        self._file_filter = file_filter or self._default_file_filter

    def hash(self, model_path: Union[str, Path]) -> str:
        """
        Return hexdigest of hash of model located at model_path using the algorithm provided at class instantiation.

        If model_path is a directory, the hash is computed by hashing the hashes of all model files in the
        directory. The final composite hash is always computed using BLAKE3.

        Args:
            model_path: Path to the model

        Returns:
            str: Hexdigest of the hash of the model
        """

        model_path = Path(model_path)

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Use a supported value: 'blake3', 'random', or any name in hashlib.algorithms_available (e.g. 'md5', 'sha1', 'sha256', 'sha512').
  2. Print sorted(hashlib.algorithms_available) to confirm the exact spelling your Python build accepts.
  3. If the algorithm is genuinely missing (e.g. blake3 variants beyond single), install the blake3 extra or pick an available hashlib algorithm.

Example fix

// before
hasher = ModelHash('blake3-multi')
// after
hasher = ModelHash('blake3')  # or 'sha256', 'random', etc.
Defensive patterns

Strategy: validation

Validate before calling

from invokeai.backend.model_hash.model_hash import ModelHash

def algorithm_is_supported(algorithm: str) -> bool:
    return algorithm in ('blake3', 'random') or algorithm in __import__('hashlib').algorithms_available

Type guard

def is_valid_algorithm(a: object) -> TypeGuard[str]:
    import hashlib
    return isinstance(a, str) and (a in ('blake3', 'random') or a in hashlib.algorithms_available)

Try / catch

try:
    hasher = ModelHash(algorithm)
except ValueError as e:
    logger.error(f'Unsupported hash algorithm: {e}; falling back to blake3')
    hasher = ModelHash('blake3')

Prevention

When it happens

Trigger: Constructing ModelHash(algorithm='xyz') where 'xyz' is a typo, an unsupported name (e.g. 'blake2' variant not linked into hashlib), or a hash name unavailable in the running Python build (some OpenSSL builds lack certain algorithms).

Common situations: Typo like 'sha1 ' with a trailing space or 'blake3s'; running on a Python/OpenSSL build where the algorithm isn't compiled in; config file carrying an algorithm name from a different tool (e.g. 'sha3-256' is fine, but 'sha3_256' naming mismatches fail).

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/b5abe2ddc9adcd54. Report an issue: GitHub.