llm.runtime — Plugin Registries and Model Factory
The runtime layer wires extension points (model architectures,
attention, MLP, norms, generation backends) via the generic
:class:~llm.runtime.registry.Registry kernel. The model factory
turns a ModelConfig into an instantiated DecoderModel.
Registries
registry
Generic plugin registry for runtime extensibility.
Registry
Name-to-object registry with explicit registration and lookup.
源代码位于: src/llm/runtime/registry.py
decorator_register
Class decorator factory compatible with legacy register_model usage.
源代码位于: src/llm/runtime/registry.py
Model Factory
model_factory
Central model construction for training, serving, and compat loaders.
ModelFactory
Resolve registered model builders from typed or raw configuration.
源代码位于: src/llm/runtime/model_factory.py
build_decoder
build_decoder(*, vocab_size, hidden_size, num_layers, num_heads, max_seq_len=512, intermediate_size=None, embedding_dropout_p=0.1, attn_dropout_p=0.1, mlp_dropout_p=0.1, num_experts=0, top_k=0, num_kv_heads=None, use_glu=False, attn_impl='mha', mlp_impl='mlp', norm_eps=1e-05, norm_impl='layer_norm', device=None, dtype=None, **kwargs)
Construct a DecoderModel from explicit architecture kwargs.
源代码位于: src/llm/runtime/model_factory.py
build_regression_mlp
Construct a standalone MLP for the synthetic regression demo task.
源代码位于: src/llm/runtime/model_factory.py
decoder_kwargs_from_config
Map a ModelConfig into DecoderModel constructor kwargs.
源代码位于: src/llm/runtime/model_factory.py
Plugin Loader
plugins
Discover third-party plugins via setuptools entry points.
load_entry_point_registry
Load callables from entry points into a registry.
Returns names that were newly registered.
源代码位于: src/llm/runtime/plugins.py
load_entry_point_hooks
Invoke zero-arg registration hooks from entry points.