Skip to main content

Python class

HuggingFaceRepo

HuggingFaceRepo

class max.pipelines.lib.HuggingFaceRepo(repo_id, revision='main', trust_remote_code=False, repo_type=None, subfolder=None)

source

Bases: object

Handle for interacting with a Hugging Face repository (remote or local).

Parameters:

  • repo_id (str)
  • revision (str)
  • trust_remote_code (bool)
  • repo_type (Literal['online', 'local'] | None)
  • subfolder (str | None)

encoding_for_file()

encoding_for_file(file, preferred_encoding=None)

source

Infers the supported encoding for a given weight file path.

Parameters:

  • file (str | Path) – The weight file path.
  • preferred_encoding (SupportedEncoding | None) – If set and present in the repo’s supported encodings, return it directly. Useful for multi-encoding safetensors repos (e.g. FP4 repos that also contain BF16 norm weights).

Return type:

SupportedEncoding

file_exists()

file_exists(filename)

source

Returns whether the given file exists in the repo.

Parameters:

filename (str)

Return type:

bool

files_for_encoding()

files_for_encoding(encoding, weights_format=None)

source

Returns paths to weight files for the given encoding (and optionally format).

Parameters:

  • encoding (max.pipelines.lib.config.SupportedEncoding)
  • weights_format (WeightsFormat | None)

Return type:

dict[WeightsFormat, list[Path]]

formats_available

property formats_available: list[WeightsFormat]

source

Returns the weight formats available in this repo.

info

property info: ModelInfo

source

Returns Hugging Face model info (online repos only).

repo_id

repo_id: str

source

The Hugging Face repo id. While it’s called repo_id, it can be a HF remote or local path altogether.

repo_type

repo_type: Literal['online', 'local'] | None = None

source

The type of repo. This is inferred from the repo_id.

revision

revision: str = 'main'

source

The revision to use for the repo.

size_of()

size_of(filename)

source

Returns file size in bytes for online repos, or None.

Parameters:

filename (str)

Return type:

int | None

subfolder

subfolder: str | None = None

source

Optional subdirectory within the repo to scope weight discovery to.

supported_encodings

property supported_encodings: list[max.pipelines.lib.config.SupportedEncoding]

source

Returns encodings supported by this repo’s weight files.

trust_remote_code

trust_remote_code: bool = False

source

Whether to trust remote code.

weight_files

property weight_files: dict[WeightsFormat, list[str]]

source

Returns weight file paths grouped by format (safetensors, gguf).

When subfolder is set, only files within that subdirectory are returned. The returned paths are relative to the repo root (i.e. they include the subfolder prefix) so that they can be passed directly to hf_hub_download and local file resolution without further adjustment.