Skip to content

huggingface

huggingface

logger module-attribute

logger = logging.getLogger('nnsight')

HUB_TIMEOUT_SECONDS module-attribute

HUB_TIMEOUT_SECONDS = 10.0

CheckpointUnreachable

Bases: Exception

The checkpoint could not be read — the Hub was slow, down, or refused.

Distinct from reading it and finding nothing, which every reader here reports as None. Collapsing the two is how a network problem comes to look like a fact about a model: a config that failed to download makes max_tp_size return None, and None is the answer meaning "this model cannot be split at all", so a perfectly shardable model gets placed across cards layer-by-layer and nothing says why.

HuggingFaceModel

HuggingFaceModel(repo_id: Any, *args: Any, revision: Optional[str] = None, **kwargs: Any)

Bases: Remotable

nnsight wrapper around a HuggingFace Hub model.

Builds the architecture on the meta device from the repo's config and loads real weights on dispatch, both via transformers. The transformers auto class is configurable through AUTO_CLASS so subclasses can target, e.g., AutoModelForCausalLM.

PARAMETER DESCRIPTION
repo_id

A HuggingFace repo id (e.g. "openai-community/gpt2") or an already-loaded torch.nn.Module.

TYPE: Any

revision

Optional git revision (branch/tag/commit) of the repo.

TYPE: Optional[str] DEFAULT: None

AUTO_CLASS class-attribute instance-attribute

AUTO_CLASS = 'AutoModel'

repo_id instance-attribute

repo_id = repo_id if isinstance(repo_id, str) else getattr(repo_id, 'name_or_path', None)

revision instance-attribute

revision = revision