class

MicroGPT::Router

Inherits Reference < Object

Constructors

new(n_routed : Int32)
Source

Instance methods

adam_mats

Adam state matrices (2 per weight mat: m, v)

Source
backward(d_router_probs : Mat, lr : Float64) : Mat

Backward: given d_router_probs [seq_len, n_routed], compute gradients and return d_stream contribution from router. Updates own params.

Source
describe

Human-readable description

Source
epsilon

Exploration rate (ε-greedy)

Source
epsilon=(epsilon : Float64)

Exploration rate (ε-greedy)

Source
forward(input_ids : Array(Int32), stream : Mat) : Mat

Forward: compute per-position blended router probs [seq_len, n_routed] Also caches state needed for backward.

Source
grad_mats

Gradient matrices (same order as weight_mats)

Source
n_routed

Number of routed experts

Source
param_count

Parameter count

Source
weight_mats

Weight matrices for serialization (WeightStore)

Source