Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Unslothai Unsloth Model Registry

From Leeroopedia
Revision as of 17:02, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Unslothai_Unsloth_Model_Registry.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Model_Management, Registry
Last Updated 2026-02-07 08:40 GMT

Overview

Concrete tool for managing quantized model metadata registration and lookup via a global model registry.

Description

The registry module defines the core data structures and registration logic for Unsloth's model registry. QuantType enumerates supported quantization types (BNB, UNSLOTH, GGUF, NONE, BF16). ModelInfo stores metadata for individual model variants including organization, name, version, size, and quantization type, auto-constructing HuggingFace-compatible model paths. ModelMeta templates bulk registration of model families. The global MODEL_REGISTRY dictionary and register_model / _register_models functions manage variant registration with duplicate detection.

Usage

Import ModelInfo and register_model when adding new model families to the Unsloth registry, or access MODEL_REGISTRY to look up supported model variants.

Code Reference

Source Location

Signature

class QuantType(Enum):
    BNB = "bnb"
    UNSLOTH = "unsloth"
    GGUF = "GGUF"
    NONE = "none"
    BF16 = "bf16"

@dataclass
class ModelInfo:
    org: str
    base_name: str
    version: str
    size: int
    name: str = None
    is_multimodal: bool = False
    instruct_tag: str = None
    quant_type: QuantType = None
    description: str = None

@dataclass
class ModelMeta:
    org: str
    base_name: str
    model_version: str
    model_info_cls: type[ModelInfo]
    model_sizes: list[str] = field(default_factory=list)
    instruct_tags: list[str] = field(default_factory=list)
    quant_types: list[QuantType] = field(default_factory=list)
    is_multimodal: bool = False

MODEL_REGISTRY: dict[str, ModelInfo] = {}

def register_model(
    model_info_cls: ModelInfo, org: str, base_name: str,
    version: str, size: int, instruct_tag: str = None,
    quant_type: QuantType = None, is_multimodal: bool = False,
    name: str = None,
) -> None:
    """Register a single model variant in the global registry."""

def _register_models(
    model_meta: ModelMeta, include_original_model: bool = False,
) -> None:
    """Bulk register model family variants from a ModelMeta template."""

Import

from unsloth.registry.registry import (
    ModelInfo, ModelMeta, QuantType,
    MODEL_REGISTRY, register_model,
)

I/O Contract

Inputs (register_model)

Name Type Required Description
model_info_cls type Yes ModelInfo class or subclass
org str Yes Organization name (e.g., "unsloth")
base_name str Yes Base model name (e.g., "Llama-3.1")
version str Yes Model version (e.g., "3.1")
size int Yes Model size parameter count
instruct_tag str No Instruction-tuned variant tag
quant_type QuantType No Quantization type
is_multimodal bool No Whether model is multimodal (default: False)

Outputs

Name Type Description
MODEL_REGISTRY dict[str, ModelInfo] Global dict mapping "org/name" to ModelInfo
ModelInfo.model_path str HuggingFace model path "org/name"

Usage Examples

Register a Model Family

from unsloth.registry.registry import (
    ModelMeta, ModelInfo, QuantType, _register_models,
)

meta = ModelMeta(
    org="meta-llama",
    base_name="Llama-3.1",
    model_version="3.1",
    model_info_cls=ModelInfo,
    model_sizes=["1B", "3B", "8B", "70B"],
    instruct_tags=["Instruct"],
    quant_types=[QuantType.BNB, QuantType.UNSLOTH],
)

_register_models(meta, include_original_model=True)

Look Up a Model

from unsloth.registry.registry import MODEL_REGISTRY

info = MODEL_REGISTRY.get("unsloth/Llama-3.1-8B-Instruct-bnb-4bit")
if info:
    print(f"Model: {info.model_path}")
    print(f"Quant: {info.quant_type}")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment