Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
Register registers a model constructor by architecture name. Called from init() in model packages. Panics on duplicate registration.
func RegisterDraft ¶ added in v0.23.1
RegisterDraft registers a draft model constructor by architecture name.
Types ¶
type DraftModel ¶ added in v0.23.1
type DraftModel interface {
// Draft fuses b.Hidden (the target hidden state) into its own forward and
// returns the head's hidden plus the projected hidden seeding the next step.
Draft(b *batch.Batch, caches []cache.Cache) (hidden, projected *mlx.Array)
// Unembed projects a hidden state to vocabulary logits.
Unembed(x *mlx.Array) *mlx.Array
// DraftCaches selects the draft model's own KV caches from the full
// per-request slice — any subset, or nil when the draft keeps no KV.
DraftCaches(caches []cache.Cache) []cache.Cache
// LoadWeights assigns manifest tensors to the draft head's fields.
LoadWeights(tensors map[string]*mlx.Array) error
}
DraftModel is an auxiliary model alongside a target that proposes speculative tokens.
type Model ¶
type Model interface {
Forward(b *batch.Batch, cache []cache.Cache) *mlx.Array
Unembed(x *mlx.Array) *mlx.Array
NumLayers() int
Tokenizer() *tokenizer.Tokenizer
MaxContextLength() int
// LoadWeights receives all tensors loaded from the manifest and assigns
// them to model fields. Model-specific logic (MLA absorption, expert
// stacking, quantized layer creation) happens here.
LoadWeights(tensors map[string]*mlx.Array) error
}
Model is the interface that model implementations must satisfy.
type SelfDraft ¶ added in v0.30.11
type SelfDraft interface {
SelfDraft() DraftModel
}
SelfDraft is implemented by models whose draft head ships inline with the target weights; it returns the head, or nil when the checkpoint shipped none.
Click to show internal directories.
Click to hide internal directories.